8000 ddl: support interval type in format by DifferentialOrange · Pull Request #117 · tarantool/ddl · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

ddl: support interval type in format #117

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Oct 23, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 15 additions & 7 deletions .github/workflows/publish.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ jobs:
if: github.ref == 'refs/heads/master'
< 8000 /td> runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4
- uses: tarantool/rocks.tarantool.org/github-action@master
with:
auth: ${{ secrets.ROCKS_AUTH }}
Expand All @@ -31,16 +31,24 @@ jobs:
needs: version-check
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v2
- uses: tarantool/setup-tarantool@v1
- uses: actions/checkout@v4
- uses: tarantool/setup-tarantool@v2
with:
tarantool-version: '2.5'
tarantool-version: '2.11'

- name: Prepare apt repo
run: curl -L https://tarantool.io/release/2/installer.sh | bash

- name: Install tt cli
run: sudo apt install -y tt
env:
DEBIAN_FRONTEND: noninteractive

# Make a release
- run: echo TAG=${GITHUB_REF##*/} >> $GITHUB_ENV
- run: tarantoolctl rocks new_version --tag ${{ env.TAG }}
- run: tarantoolctl rocks install ddl-${{ env.TAG }}-1.rockspec
- run: tarantoolctl rocks pack ddl ${{ env.TAG }}
- run: tt rocks new_version --tag ${{ env.TAG }}
- run: tt rocks install ddl-${{ env.TAG }}-1.rockspec
- run: tt rocks pack ddl ${{ env.TAG }}

- uses: tarantool/rocks.tarantool.org/github-action@master
with:
Expand Down
67 changes: 39 additions & 28 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@ jobs:
strategy:
fail-fast: false
matrix:
tarantool: ['1.10', '2.5', '2.6', '2.7']
tarantool: ['1.10', '2.5', '2.6', '2.7', '2.8', '2.10']
coveralls: [false]
include:
- tarantool: '2.8'
- tarantool: '2.11'
coveralls: true
# There are problems with current version of the
# setup-tarantool action on Ubuntu Jammy (ubuntu-latest or
Expand All @@ -22,39 +22,41 @@ jobs:
# [1]: https://github.com/tarantool/setup-tarantool/issues/36
runs-on: [ubuntu-20.04]
steps:
- uses: actions/checkout@v2
- uses: tarantool/setup-tarantool@v1
- uses: actions/checkout@v4

- uses: tarantool/setup-tarantool@v2
with:
tarantool-version: ${{ matrix.tarantool }}

- name: Prepare apt repo
run: curl -L https://tarantool.io/release/2/installer.sh | bash

- name: Install tt cli
run: sudo apt install -y tt
env:
DEBIAN_FRONTEND: noninteractive

# Setup luatest and luacheck
- name: Cache rocks
uses: actions/cache@v2
uses: actions/cache@v3
10000 id: cache-rocks
with:
path: .rocks/
key: cache-rocks-${{ matrix.runs-on }}-06
-
run: tarantoolctl rocks install luacheck
if: steps.cache-rocks.outputs.cache-hit != 'true'
-
run: tarantoolctl rocks install luatest
if: steps.cache-rocks.outputs.cache-hit != 'true'
-
run: tarantoolctl rocks install luacov
if: steps.cache-rocks.outputs.cache-hit != 'true'
-
run: tarantoolctl rocks install luacov-coveralls 0.2.3-1 --server=https://luarocks.org
key: cache-rocks-${{ matrix.runs-on }}-07

- name: Install test dependencies
run: ./deps.sh
if: steps.cache-rocks.outputs.cache-hit != 'true'

- run: echo $PWD/.rocks/bin >> $GITHUB_PATH

- run: tarantoolctl rocks list
- run: tarantoolctl rocks install cartridge
- run: tt rocks list
- run: tt rocks install cartridge
env:
CMAKE_DUMMY_WEBUI: true
- run: tarantoolctl rocks remove ddl --force
- run: tt rocks remove ddl --force

- run: tarantoolctl rocks make
- run: tt rocks make
- run: cmake -S . -B build
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
Expand All @@ -70,13 +72,13 @@ jobs:
if: ${{ matrix.coveralls }}

# Cleanup cached paths
- run: tarantoolctl rocks remove cartridge
- run: tarantoolctl rocks remove ddl
- run: tt rocks remove cartridge
- run: tt rocks remove ddl
benchmark:
strategy:
fail-fast: false
matrix:
tarantool: ['1.10', '2.5', '2.6', '2.7']
tarantool: ['2.11']
# There are problems with current version of the
# setup-tarantool action on Ubuntu Jammy (ubuntu-latest or
# ubuntu-22.04). Use Ubuntu Focal (ubuntu-20.04) until they
Expand All @@ -85,20 +87,29 @@ jobs:
# [1]: https://github.com/tarantool/setup-tarantool/issues/36
runs-on: [ubuntu-20.04]
steps:
- uses: actions/checkout@v2
- uses: tarantool/setup-tarantool@v1
- uses: actions/checkout@v4

- uses: tarantool/setup-tarantool@v2
with:
tarantool-version: ${{ matrix.tarantool }}

- name: Prepare apt repo
run: curl -L https://tarantool.io/release/2/installer.sh | bash

- name: Install tt cli
run: sudo apt install -y tt
env:
DEBIAN_FRONTEND: noninteractive

# Setup luatest
- name: Cache rocks
uses: actions/cache@v2
uses: actions/cache@v3
id: cache-rocks
with:
path: .rocks/
key: cache-rocks-${{ matrix.runs-on }}-bench-01

- run: tarantoolctl rocks install luatest
- run: tt rocks install luatest
if: steps.cache-rocks.outputs.cache-hit != 'true'

- run: tarantool ./test/bench_cache.lua
6 changes: 6 additions & 0 deletions CHANGELOG.md
8000
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,12 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).

## Unreleased

### Added

- Added support of `interval` type for Tarantool 2.10+ space format.

## [1.6.4] - 2023-07-05

### Added
Expand Down
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,8 @@ format = {
type = 'unsigned' | 'string' | 'varbinary' |
'integer' | 'number' | 'boolean' |
'array' | 'scalar' | 'any' | 'map' |
'decimal' | 'double' | 'uuid' | 'datetime'
'decimal' | 'double' | 'uuid' | 'datetime' |
'interval'
},
...
},
Expand Down
19 changes: 19 additions & 0 deletions ddl/check.lua
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ local function check_field(i, field, space)
double = true,
uuid = true,
datetime = true,
interval = true,
}

if known_field_types[field.type] == nil then
Expand All @@ -81,6 +82,13 @@ local function check_field(i, field, space)
space.name, field.name, _TARANTOOL
)
end

if not db.interval_allowed() and field.type == 'interval' then
return nil, string.format(
"spaces[%q].format[%q].type: interval type isn't allowed in your Tarantool version (%s)",
space.name, field.name, _TARANTOOL
)
end
end


Expand Down Expand Up @@ -215,6 +223,17 @@ local function check_index_part_type(part_type, index_type)
datetime = true,
}

local known_unsupported_part_types = {
interval = true,
}

if known_unsupported_part_types[part_type] then
return nil, string.format(
"%s field type is unsupported in indexes",
part_type
)
end

if not known_part_types[part_type] then
return nil, string.format(
"unknown type %q",
Expand Down
5 changes: 5 additions & 0 deletions ddl/db.lua
F438
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,10 @@ local function datetime_allowed()
return tarantool_version_at_least(2, 10)
end

local function interval_allowed()
return tarantool_version_at_least(2, 10)
end

-- https://github.com/tarantool/tarantool/issues/4083
local function transactional_ddl_allowed()
return tarantool_version_at_least(2, 2)
Expand Down Expand Up @@ -155,6 +159,7 @@ return {
multikey_path_allowed = multikey_path_allowed,
transactional_ddl_allowed = transactional_ddl_allowed,
datetime_allowed = datetime_allowed,
interval_allowed = interval_allowed,
exclude_null_allowed = exclude_null_allowed,

call_atomic = call_atomic,
Expand Down
29 changes: 26 additions & 3 deletions deps.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,30 @@

set -e

if ! [ -x "$(command -v tt)" ]; then
TTCTL=tarantoolctl
else
TTCTL=tt
fi

# Test dependencies:
tarantoolctl rocks install luatest
tarantoolctl rocks install luacov 0.13.0
tarantoolctl rocks install luacheck 0.26.0
$TTCTL rocks install luatest
$TTCTL rocks install luacov 0.13.0
$TTCTL rocks install luacheck 0.26.0

$TTCTL rocks install https://raw.githubusercontent.com/mpeterv/cluacov/master/cluacov-scm-1.rockspec
$TTCTL rocks install https://raw.githubusercontent.com/LuaDist/dkjson/master/dkjson-2.5-2.rockspec
$TTCTL rocks install https://raw.githubusercontent.com/keplerproject/luafilesystem/master/luafilesystem-scm-1.rockspec
$TTCTL rocks install https://raw.githubusercontent.com/moteus/lua-path/master/rockspecs/lua-path-scm-0.rockspec

# Most of this code is the workaround for
# https://github.com/moteus/luacov-coveralls/pull/30
# Remove it, when the pull request will be merged.
TMPDIR="$(mktemp -d)"
LUACOV_COVERALLS_ROCKSPEC_URL="https://raw.githubusercontent.com/moteus/luacov-coveralls/master/rockspecs/luacov-coveralls-scm-0.rockspec"
LUACOV_COVERALLS_ROCKSPEC_FILE="${TMPDIR}/luacov-coveralls-scm-0.rockspec"
curl -fsSL "${LUACOV_COVERALLS_ROCKSPEC_URL}" > "${LUACOV_COVERALLS_ROCKSPEC_FILE}"
sed -i -e 's@git://@git+https://@' "${LUACOV_COVERALLS_ROCKSPEC_FILE}"
$TTCTL rocks install "${LUACOV_COVERALLS_ROCKSPEC_FILE}"
rm "${LUACOV_COVERALLS_ROCKSPEC_FILE}"
rmdir "${TMPDIR}"
21 changes: 21 additions & 0 deletions test/check_schema_test.lua
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,12 @@ function g.test_datetime_index_part_type()
end
end

function g.test_interval_index_part_type()
local ok, err = ddl_check.check_index_part_type('interval', 'TREE')
t.assert_not(ok)
t.assert_equals(err, "interval field type is unsupported in indexes")
end

function g.test_index_part_path()
local index_info = {type = 'HASH'}

Expand Down Expand Up @@ -1156,6 +1162,21 @@ function g.test_field()
_TARANTOOL
))
end

local ok, err = ddl_check.check_field(
1, {name = 'x', type = 'interval', is_nullable = false}, space_info
)
if db.v(2, 10) then
t.assert(ok)
t.assert_not(err)
else
t.assert_not(ok)
t.assert_equals(err, string.format(
[[spaces["space"].format["x"].type: interval type ]] ..
[[isn't allowed in your Tarantool version (%s)]],
_TARANTOOL
))
end
end

function g.test_scalar_types()
Expand Down
5 changes: 5 additions & 0 deletions test/helper.lua
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,11 @@ function helpers.test_space_format()
table.insert(space_format, {name = 'datetime_nullable', type = 'datetime', is_nullable = true})
end

if db.v(2, 10) then
table.insert(space_format, {name = 'interval_nonnull', type = 'interval', is_nullable = false})
table.insert(space_format, {name = 'interval_nullable', type = 'interval', is_nullable = true})
end

return table.deepcopy(space_format)
end

Expand Down
0