Skip to content

Allow certain functions without parentheses in SQL#95949

Merged
novikd merged 35 commits intoClickHouse:masterfrom
AlyHKafoury:revert-95943-revert-94678-Allow-certain-functions-without-parentheses-in-SQL
Mar 5, 2026
Merged

Allow certain functions without parentheses in SQL#95949
novikd merged 35 commits intoClickHouse:masterfrom
AlyHKafoury:revert-95943-revert-94678-Allow-certain-functions-without-parentheses-in-SQL

Conversation

@AlyHKafoury
Copy link
Copy Markdown
Contributor

Changelog category (leave one):

  • New Feature

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

Allow certain functions without parentheses in SQL. Closes #52102

Documentation entry for user-facing changes

  • Documentation is written (mandatory for new features)

@AlyHKafoury
Copy link
Copy Markdown
Contributor Author

@novikd Can you enable CI on this PR please

@alexey-milovidov alexey-milovidov added the can be tested Allows running workflows for external contributors label Feb 5, 2026
@clickhouse-gh
Copy link
Copy Markdown
Contributor

clickhouse-gh bot commented Feb 5, 2026

Workflow [PR], commit [a9c669b]

Summary:

@clickhouse-gh clickhouse-gh bot added the pr-feature Pull request with new product feature label Feb 5, 2026
@AlyHKafoury
Copy link
Copy Markdown
Contributor Author

@vdimir @novikd The bug is clear now, in the current implementation if the identifier one of a named parameters in a function definition matches a function or a function alias that could be run without parenthesis, it gets evaluated causing an error. Would the correct approach for this is to detect that the identifier on the right side of an = sign ? or is there an easier approach ?

@AlyHKafoury
Copy link
Copy Markdown
Contributor Author

Specifically I can Ignore the following 3 aliases because they seem to be causing problems database , user , schema

@AlyHKafoury AlyHKafoury requested a review from vdimir February 6, 2026 06:58
@AlyHKafoury
Copy link
Copy Markdown
Contributor Author

AlyHKafoury commented Feb 6, 2026

@novikd @vdimir can you please check the failed tests, the flaky one seems strange it broke in a very strange place maybe lag in between when the 2 instances of now is executed ?

https://s3.amazonaws.com/clickhouse-test-reports/json.html?PR=95949&sha=65da2251e224f092adf4952ce2e8d187ba1b5bc2&name_0=PR

@AlyHKafoury
Copy link
Copy Markdown
Contributor Author

@novikd I believe this is ready for review

@alexey-milovidov
Copy link
Copy Markdown
Member

@AlyHKafoury, I've fixed many CI issues recently - let's merge with the latest master, so we can be more confident if the failures are related or not.

…-certain-functions-without-parentheses-in-SQL
@AlyHKafoury AlyHKafoury requested a review from novikd February 12, 2026 00:16
@AlyHKafoury
Copy link
Copy Markdown
Contributor Author

@novikd I believe this is ready for review ?

@AlyHKafoury
Copy link
Copy Markdown
Contributor Author

@alexey-milovidov I believe no unrelated failed tests now all passes

@alexey-milovidov
Copy link
Copy Markdown
Member

Yes, it's green! Waiting for the reviewer, @novikd

@AlyHKafoury AlyHKafoury force-pushed the revert-95943-revert-94678-Allow-certain-functions-without-parentheses-in-SQL branch from b338ca1 to c71cf9a Compare February 28, 2026 01:38
@AlyHKafoury
Copy link
Copy Markdown
Contributor Author

@novikd I believe this is ready for a review, all the comments before has been addressed also test cases has been added for them

@AlyHKafoury AlyHKafoury requested a review from novikd February 28, 2026 20:37
@alexey-milovidov
Copy link
Copy Markdown
Member

This is fantastic! Thank you so much 💌
Let's see if @vdimir or @novikd has any remaining comments.

@AlyHKafoury
Copy link
Copy Markdown
Contributor Author

@novikd @alexey-milovidov I believe this is good to merge, the failed tests are a stress test that looks like an early exit, and a flaky test 04003_cast_nullable_read_in_order_explain that has an issue open #98506

@alexey-milovidov
Copy link
Copy Markdown
Member

I can't merge before fixing 04003_cast_nullable_read_in_order_explain (I'll do it in another PR).

@alexey-milovidov
Copy link
Copy Markdown
Member

#98518

@AlyHKafoury
Copy link
Copy Markdown
Contributor Author

@alexey-milovidov @novikd all tests has passed nothing is failing, I believe it is ready for merge

@novikd novikd added this pull request to the merge queue Mar 5, 2026
Merged via the queue into ClickHouse:master with commit 3ab5a1b Mar 5, 2026
149 checks passed
@robot-clickhouse robot-clickhouse added the pr-synced-to-cloud The PR is synced to the cloud repo label Mar 5, 2026
else if (node_type == QueryTreeNodeType::FUNCTION)
{
resolveExpressionNode(alias_node, *scope_to_resolve_alias_expression, false /*allow_lambda_expression*/, false /*allow_table_expression*/);
resolveExpressionNode(alias_node, *scope_to_resolve_alias_expression, false /*allow_lambda_expression*/, false /*allow_table_expression*/, identifier_resolve_context.allow_to_resolve_niladic_functions);
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.

@AlyHKafoury @novikd Issue: resolveExpressionNode is called with 5 arguments. The 5th positional argument is ignore_alias (default false), but here we pass identifier_resolve_context.allow_to_resolve_niladic_functions (usually true) as the 5th arg. The intended allow_niladic_functions is the 6th arg and gets the default value of true.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

@zlareb1 good catch for that, let me run me pull it locally.

@@ -0,0 +1,66 @@
-- Tags: no-parallel
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.

@AlyHKafoury Please add few additional cases worth testing:

  1. Shorter aliases — DATABASE, SCHEMA, USER, CURDATE may be registered as separate function entries.
  2. CREATE TABLE ... DEFAULT — The allow_to_resolve_niladic_functions flag may not be propagated there:
    CREATE TABLE t (ts DateTime DEFAULT CURRENT_TIMESTAMP) ENGINE = Memory;
    INSERT INTO t VALUES;
    SELECT ts FROM t;
  3. INSERT ... SELECT — Different planner entry point, worth a sanity check:
    INSERT INTO t SELECT CURRENT_TIMESTAMP;

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

@zlareb1 should this be added to this branch or another branch with a new PR ?

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.

Can be done in same branch?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

can be same branch and new PR

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

@novikd I will open a new PR fixing this bug and adding those extra tests

github-merge-queue bot pushed a commit that referenced this pull request Mar 9, 2026
…Allow-certain-functions-without-parentheses-in-SQL

Follow up on : Allow certain functions without parentheses in SQL #95949
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

can be tested Allows running workflows for external contributors pr-feature Pull request with new product feature 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.

Allow certain functions without parentheses in SQL

6 participants