Skip to content

Restrict to use SELECT in columns default expressions. - #9481

Merged
alexey-milovidov merged 7 commits into
masterfrom
better_defaults
Mar 6, 2020
Merged

alexey-milovidov merged 7 commits into
masterfrom
better_defaults

Conversation

@alesapin

@alesapin alesapin commented Mar 3, 2020

Copy link
Copy Markdown
Member

I hereby agree to the terms of the CLA available at: https://yandex.ru/legal/cla/?lang=en

Changelog category (leave one):

  • Backward Incompatible Change

Changelog entry (a user-readable short description of the changes that goes to CHANGELOG.md):
Now it's not allowed to create columns or add columns with SELECT query as default expression.

Detailed description / Documentation draft:
We have no notions in the documentation about the ability to use SELECT in the DEFAULT section. So we can do nothing, or we can add information about allowed default expression:
all functions and expression except SELECT and arrayJoin function.


Block validateColumnsDefaultsAndGetSampleBlock(ASTPtr default_expr_list, const NamesAndTypesList & all_columns, const Context & context)
{
for (const auto & child : default_expr_list->children)

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@4ertus2 I think this check is enough, but maybe I have missed something.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Generally ASTSelectQuery appears inside of ASTSelectWithUnionQuery. So we'd better add both or none of them in check.

@4ertus2

4ertus2 commented Mar 3, 2020

Copy link
Copy Markdown
Contributor

return false;

const auto & col_mask = it->second;
return std::find(col_mask.begin(), col_mask.end(), true) != col_mask.end();

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok but it can be terribly slow.

@alexey-milovidov
alexey-milovidov merged commit 20d353c into master Mar 6, 2020
@alexey-milovidov
alexey-milovidov deleted the better_defaults branch March 6, 2020 00:23
@KochetovNicolai KochetovNicolai added the pr-improvement Pull request with some product improvements label Mar 16, 2020
@alexey-milovidov alexey-milovidov added pr-backward-incompatible Pull request with backwards incompatible changes and removed backward compatibility labels Apr 5, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

pr-backward-incompatible Pull request with backwards incompatible changes pr-improvement Pull request with some product improvements

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants