Skip to content

Fix several LOGICAL_ERRORs around setting alias of invalid AST nodes#77445

Merged
Algunenano merged 4 commits intoClickHouse:masterfrom
Algunenano:pedro_pedro_pedro
Mar 13, 2025
Merged

Fix several LOGICAL_ERRORs around setting alias of invalid AST nodes#77445
Algunenano merged 4 commits intoClickHouse:masterfrom
Algunenano:pedro_pedro_pedro

Conversation

@Algunenano
Copy link
Copy Markdown
Member

Changelog category (leave one):

  • Bug Fix (user-visible misbehavior in an official stable release)

Changelog entry (a user-readable short description of the changes that goes to CHANGELOG.md):

Fix several LOGICAL_ERRORs around setting alias of invalid AST nodes

Consciously not marking this as critical since a) it's impact is minimal and b) my impression is that is has some risks related to the validation (maybe something that was allowed before it's now disallowed by mistake and we don't notice it).

Closes #72537

Documentation entry for user-facing changes

  • Documentation is written (mandatory for new features)

@clickhouse-gh
Copy link
Copy Markdown
Contributor

clickhouse-gh bot commented Mar 11, 2025

Workflow [PR], commit [cd186e0]

@clickhouse-gh clickhouse-gh bot added the pr-bugfix Pull request with bugfix, not backported by default label Mar 11, 2025
@novikd novikd self-assigned this Mar 12, 2025
Comment on lines +75 to +76
if (array_join_expression->hasAlias())
array_join_expression_ast->setAlias(array_join_expression->getAlias());
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.

There's not difference. I'd remove if

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.

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.

Without the if it tries to set an empty alias to the ast. Even if it's empty, it's not allowed to set aliases to things like ASTAsterisk.

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.

Okay, I see the problem. Let's then add a comment with an explanation. It's not obvious why it's so important.

Comment on lines +19 to +23
$CLICKHOUSE_CLIENT -q "CREATE VIEW x AS (SELECT $FUNCTION_NAME(*)); -- { serverError BAD_ARGUMENTS }"
$CLICKHOUSE_CLIENT -q "CREATE VIEW x AS (SELECT $FUNCTION_NAME(t.*) FROM t); -- { serverError BAD_ARGUMENTS }"
$CLICKHOUSE_CLIENT -q "CREATE VIEW x AS (SELECT $FUNCTION_NAME(COLUMNS(''))); -- { serverError BAD_ARGUMENTS }"
$CLICKHOUSE_CLIENT -q "CREATE VIEW x AS (SELECT $FUNCTION_NAME(COLUMNS('t.*'))); -- { serverError BAD_ARGUMENTS }"
$CLICKHOUSE_CLIENT -q "CREATE VIEW x AS (SELECT $FUNCTION_NAME(COLUMNS('t.t*')) FROM t); -- { serverError BAD_ARGUMENTS }"
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.

It's probably possible to support it with enabled analyzer, but i'm ok to forbit it.

@Algunenano Algunenano requested a review from novikd March 13, 2025 13:37
Comment on lines +75 to +76
if (array_join_expression->hasAlias())
array_join_expression_ast->setAlias(array_join_expression->getAlias());
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.

Okay, I see the problem. Let's then add a comment with an explanation. It's not obvious why it's so important.

@Algunenano Algunenano added this pull request to the merge queue Mar 13, 2025
Merged via the queue into ClickHouse:master with commit 87b81d9 Mar 13, 2025
123 of 126 checks passed
@Algunenano Algunenano deleted the pedro_pedro_pedro branch March 13, 2025 20:02
@robot-ch-test-poll3 robot-ch-test-poll3 added the pr-synced-to-cloud The PR is synced to the cloud repo label Mar 13, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

pr-bugfix Pull request with bugfix, not backported by default pr-synced-to-cloud The PR is synced to the cloud repo

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Logical Error: Can't set alias of * of Asterisk

3 participants