Repository navigation
Fix __actionName, add tests for internal functions direct call - #62287
Conversation
|
This is an automated comment for commit 4ea2b5e with description of existing statuses. It's updated for the latest CI running ❌ Click here to open a full report in a separate page
Successful checks
|
| if (function_node.getFunctionName() == "__actionName") | ||
| { | ||
| result = toString(function_node.getArguments().getNodes().at(1)->as<ConstantNode>()->getValue()); | ||
| /// Perform sanity check, because user may call this function with unexpected arguments |
There was a problem hiding this comment.
This function should not be allowed to be called by user. This is a implementation specific function.
There was a problem hiding this comment.
How can we forbid it? One option I considered is to have a specific setting in context that allows creating such functions, but it become more tricky to distinguish cases when query comes from remote server. Probably, __actionName cannot be transferred to remote, but I'm not sure (maybe some complex case with Merge over Distributed).
There was a problem hiding this comment.
We have ClientInfo in the context check if query come from user or from another server. The initiator should throw an exception if user calls this function.
There was a problem hiding this comment.
Maybe let's merge this PR and backport since it's a trivial one and prevents segfault, and then discuss something more sophisticated to forbid __actionName call from SQL ?
94dc436 to
7668ed4
Compare
3b482ba to
4ce35b1
Compare
Checking..
|
Backport #62287 to 24.3: Fix __actionName, add tests for internal functions direct call
|
Hi @vdimir — while reviewing this PR I found the following:
Could you review the test PR and add the |
Relax the type restriction on __actionName's first argument: the original all-arguments-must-be-String guard (added in #62287 as a fuzzer crash workaround) was overly broad — the actual bug was empty action names from the second argument, not a type mismatch on the first. Now only the second argument (the desired name) is required to be String; the first argument (the wrapped expression) can be any type. In buildQueryTreeDistributed, after ReplaseAliasColumnsVisitor inlines ALIAS columns, scan the projection for structurally identical expressions (same tree hash ignoring aliases). Wrap subsequent duplicates in __actionName(expr, 'column_alias') which forces the planner to use the column alias as the action-node name — guaranteed unique since column aliases within a table are unique by definition. No nesting, no collisions, works on both initiator and shard. Also fix typo: "nad" → "and" in error messages. Closes: #106403 Co-authored-by: Yakov Olkhovskiy <[email protected]>
Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes to CHANGELOG.md):
...
close #62271