-
Notifications
You must be signed in to change notification settings - Fork 738
[25.3.1] The ability to specify not null, default, family in any order #30149
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
base: stable-25-3-1
Are you sure you want to change the base?
[25.3.1] The ability to specify not null, default, family in any order #30149
Conversation
Проблема в следующем.
Есть запрос:
```sql
CREATE TABLE series_with_families (
series_id Uint64,
title Utf8,
series_info Utf8 NOT NULL FAMILY family_large,
release_date Uint64,
PRIMARY KEY (series_id),
FAMILY default (
DATA = "ssd",
COMPRESSION = "off"
),
FAMILY family_large (
DATA = "rot",
COMPRESSION = "lz4"
)
);
```
Такой запрос является на данный момент неверным на уровне грамматики. Ругается на строку \``series_info Utf8 NOT NULL FAMILY family_large`\` Однако запрос, в котором NOT NULL и FAMILY поменяны местами, отрабатывает корректно:
```sql
CREATE TABLE series_with_families (
series_id Uint64,
title Utf8,
series_info Utf8 FAMILY family_large NOT NULL,
release_date Uint64,
PRIMARY KEY (series_id),
FAMILY default (
DATA = "ssd",
COMPRESSION = "off"
),
FAMILY family_large (
DATA = "rot",
COMPRESSION = "lz4"
)
);
```
В этом Pull Request'е я меняю грамматику таким образом, чтобы была возможность задавать "опции" колонки (DEFAULT, NOT NULL, FAMILY).
Особое внимание стоит обратить внимание на тест `CreateTableDefaultAndNotNullInOrderSpace`: в нем показывается, что можно использовать синтаксис
```sql
CREATE TABLE tbl (
k Uint64,
v Bool DEFAULT false NOT NULL,
PRIMARY KEY (k)
);
```
И такое поведение означает именно DEFAULT (false NOT NULL), то есть DEFAULT true. Дело в том, что выражение "false NOT NULL" эквивалентно "false IS NOT NULL", что является, безусловно, истиной. Ровно для того, чтобы была вообще возможность одновременно указать и default, и not null, было добавлено расширение синтаксиса: теперь можно указывать скобки для указания опций столбца, а сами опции внутри них можно перечислять через запятую:
```sql
CREATE TABLE tbl (
k Uint64,
v Bool (DEFAULT false, NOT NULL),
PRIMARY KEY (k)
);
```
Запрос выше означает, что столбец должен по умолчанию заполняться false'ами, но при этом он должен быть NOT NULL.
commit_hash:67cc27a5fe6ae73f8725b051b232c2ca0d1ec54f
|
🟢 |
|
⚪ ⚪ Ya make output | Test bloat | Test bloat
⚪ Ya make output | Test bloat | Test bloat | Test bloat
🟢
*please be aware that the difference is based on comparing your commit and the last completed build from the post-commit, check comparation |
|
⚪
🟢
*please be aware that the difference is based on comparing your commit and the last completed build from the post-commit, check comparation |
|
⚪
🟢
*please be aware that the difference is based on comparing your commit and the last completed build from the post-commit, check comparation |
|
⚪ ⚪ Ya make output | Test bloat | Test bloat
⚪ Ya make output | Test bloat | Test bloat | Test bloat
🟢
*please be aware that the difference is based on comparing your commit and the last completed build from the post-commit, check comparation |
Changelog entry
...
Changelog category
Description for reviewers
...