Skip to content

Apply AST size limits to the query generated by table function eval - #110211

Open
groeneai wants to merge 13 commits into
ClickHouse:masterfrom
groeneai:groeneai/eval-ast-size-limits
Open

groeneai wants to merge 13 commits into
ClickHouse:masterfrom
groeneai:groeneai/eval-ast-size-limits

Conversation

@groeneai

@groeneai groeneai commented Jul 13, 2026 •

Copy link
Copy Markdown
Collaborator

Changelog category (leave one):

  • Improvement

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

The query generated by the eval table function is now subject to the same checks as a query executed directly: the AST size limits max_ast_depth and max_ast_elements, the set operation default modes, the order of global WITH expansion, and enforce_strict_identifier_format.

Description

Follow-up to #110132 (per @ alexey-milovidov's review request on src/TableFunctions/TableFunctionEval.cpp).

eval parses and stores the generated inner SELECT, but unlike executeQueryImpl it skipped several prechecks, so a tiny outer SELECT * FROM eval('...') got past them. Each now runs on the generated query from a context that already has that query's own SETTINGS applied, so an inner SETTINGS clause controls its own prechecks:

  • max_ast_depth / max_ast_elements were not applied at all, so a huge or very deep generated AST reached the analyzer.
  • The set operation default modes were resolved against the outer defaults, so an inner SETTINGS union_default_mode = 'DISTINCT' was rejected although the same query executed directly succeeds. Likewise for intersect_default_mode and except_default_mode, which live in separate branches of the visitor.
  • Global WITH aliases were expanded after the size limits instead of before, so a generated global CTE that grows past the limit once it is inlined slipped through.
  • enforce_strict_identifier_format was not applied, so eval('SELECT 1 AS "bad-name"') returned a bad-name column while SELECT 1 AS "bad-name" and view(SELECT 1 AS "bad-name") are both rejected with BAD_ARGUMENTS.

Regression tests in 04513_eval_table_function_ast_limits.

Two divergences are left, both pre-existing on master, identical with and without this PR, and both belonging to wrapNestedConstructionSettings rather than here. On a set operation root it does not consume the trailing SETTINGS, so eval('SELECT number AS n FROM numbers(5) EXCEPT SELECT 1 AS n SETTINGS filter = ''n > 2''') returns 4 rows against the direct query's 2, and the size check then measures the unwrapped tree. And because it runs after the normalization visitors, a set operation that a filter, select or order snippet introduces is never normalized and fails with BAD_ARGUMENTS, whether or not its mode is explicit.


Workflow [PR]
Sync PR [sync-upstream/pr/110211]

The eval table function parses and stores the generated inner SELECT but,
unlike executeQueryImpl, never applied the AST size limits. That made
max_ast_depth and max_ast_elements ineffective for the inner query: a tiny
outer SELECT * FROM eval('...') could smuggle a huge or very deep AST into
the analyzer, even though executing the same inner query directly would be
rejected.

Apply checkDepth/checkSize to the generated query, reading the limits from a
context that already has the generated query's own SETTINGS applied (resolved
before the normalization visitors rewrite the tree), so an inner SETTINGS
clause controls its own limits the same way it does for a standalone query.

Follow-up to ClickHouse#110132.

Co-Authored-By: Claude Opus 4.8 <[email protected]>
@groeneai

Copy link
Copy Markdown
Collaborator Author
Pre-PR validation gate (click to expand)
# Question Answer
a Deterministic repro? Yes. SELECT count() FROM eval('SELECT 1+2+...+10') SETTINGS max_ast_elements = 30 returns a result on master (limit ignored) and throws TOO_BIG_AST with the fix. Same for a deep inner query with max_ast_depth.
b Root cause explained? eval parses/stores the generated inner SELECT but, unlike executeQueryImpl, never applied the AST size limits, so max_ast_depth/max_ast_elements were skipped for the inner query.
c Fix matches root cause? Yes. Applies checkDepth/checkSize to the generated query, mirroring executeQueryImpl's checkASTSizeLimits.
d Test intent preserved / new tests added? New regression cases added to 04512_eval_table_function (tighten, relax, and inner-SETTINGS override). Existing assertions unchanged.
e Demonstrated in both directions? Yes. Fails on pristine build (Build ID d69aa46, no rejection); passes on fixed build (f2dd557, rejects). clickhouse-test 04512_eval_table_function = OK.
f Fix is general, not a narrow patch? The limits are applied to the whole generated SELECT/UNION tree; covers depth and element count. eval is the only table function that parses a runtime query string, so no sibling paths.
g Generalizes across inputs? Both limits covered; inner SETTINGS (tighten and relax) and UNION-form queries verified.
h Backward compatible? Yes. No setting default or format change; only enforces existing limits on a path that previously skipped them.
i Invariants/contracts preserved? Settings resolved into a private Context::createCopy before the normalization visitors rewrite the tree; outer context is untouched.

Session id: cron:clickhouse-worker-slot-0:20260713-042100

@groeneai

Copy link
Copy Markdown
Collaborator Author

cc @alexey-milovidov — follow-up to #110132 as requested: applies the AST size limits to the query generated by eval.

@PedroTadim PedroTadim added the can be tested Allows running workflows for external contributors label Jul 13, 2026
@clickhouse-gh

clickhouse-gh Bot commented Jul 13, 2026 •

Copy link
Copy Markdown
Contributor

Workflow [PR], commit [51f0d7c]

Summary: ❌

job_name test_name status info comment
Fast test (arm_darwin) FAIL
05495_part_moves_between_shards_step_retry FAIL cidb

AI Review

Summary

The PR applies AST size limits and strict identifier validation to queries generated by eval, and uses their own resolved settings for global WITH expansion and set-operation defaults. Reviewed head: 51f0d7c555392cffbe2a13d5f4aa1bd247af1f17. No new findings; the previously reported construction-settings limitation remains below as a deferred follow-up.

Missing context / blind spots
  • ⚠️ Regression queries were not rerun locally because this checkout has no executable or configured build. Current-head build/stateless checks were still pending when reviewed; completed CI execution of 04513_eval_table_function_ast_limits would close this verification gap.
Findings

⚠️ Majors — pre-existing follow-up

  • src/TableFunctions/TableFunctionEval.cpp:187 [dismissed by author -- https://github.com/Apply AST size limits to the query generated by table function eval #110211#discussion_r3865038345] Set operations introduced by construction settings still miss normalization: wrapNestedConstructionSettings runs after both set-operation visitors. For example, SELECT * FROM eval('SELECT 1 AS x SETTINGS filter = ''1 IN (SELECT 1 UNION ALL SELECT 1)''') reaches UnionNode with an unresolved mode and throws BAD_ARGUMENTS, while direct execution succeeds. The issue remains real because the current ordering still leaves newly parsed snippet ASTs unnormalized. The author confirmed it predates this PR and explicitly deferred it in the description; that scope decision is accepted. Follow-up: normalize the wrapped AST and add a focused stateless regression.
Final Verdict

✅ Approve the scoped change, subject to normal CI completion. The retained construction-settings issue is an accepted, pre-existing follow-up.

@clickhouse-gh clickhouse-gh Bot added the pr-bugfix Pull request with bugfix, not backported by default label Jul 13, 2026
The generated query's INTERSECT/EXCEPT and UNION normalization ran with the
outer context defaults, so an inner SETTINGS union_default_mode = 'DISTINCT'
still threw EXPECTED_ALL_OR_DISTINCT even though the same query executes fine
directly. Drive the normalization visitors from limits_context (the inner
query's resolved SETTINGS), same as the AST size limits already do.

Co-Authored-By: Claude Opus 4.8 <[email protected]>
@groeneai

Copy link
Copy Markdown
Collaborator Author

Fixed in f502546. The set-operation normalization visitors now read intersect_default_mode / except_default_mode / union_default_mode from limits_context->getSettingsRef() (the generated query's own resolved SETTINGS) instead of the outer context, same as the AST size limits already do. So an inner ... SETTINGS union_default_mode = 'DISTINCT' normalizes exactly as it would when the query is executed directly.

Verified both directions with your repro on a debug build:

  • Without the fix: SELECT count() FROM eval('SELECT 1 AS n UNION SELECT 1 AS n SETTINGS union_default_mode = ''DISTINCT''') throws EXPECTED_ALL_OR_DISTINCT.
  • With the fix: returns 1. The ambiguous ... UNION ... with no inner SETTINGS still throws EXPECTED_ALL_OR_DISTINCT (outer default preserved).

Added a regression in 04512_eval_table_function covering the inner union_default_mode = 'DISTINCT' case plus a paired assertion that the ambiguous UNION without inner settings still errors.

Pre-PR validation gate (click to expand)
# Question Answer
a Deterministic repro? Yes — the exact query in the review throws EXPECTED_ALL_OR_DISTINCT on demand before the fix.
b Root cause explained? The visitors at TableFunctionEval.cpp:166-172 drove SelectIntersectExceptQueryVisitor / NormalizeSelectWithUnionQueryVisitor from the OUTER settings, so NormalizeSelectWithUnionQueryVisitor saw an empty outer union_default_mode and rejected an ambiguous UNION even though the inner query set it to DISTINCT.
c Fix matches root cause? Yes — the visitors now read the three set-operation modes from limits_context (the inner query's resolved SETTINGS), matching how the AST size limits are already resolved.
d Test intent preserved / new tests added? Yes — added a regression for the inner-DISTINCT case and kept the outer-default ambiguous UNION error assertion, so both behaviors are pinned.
e Both directions demonstrated? Yes — fails (EXPECTED_ALL_OR_DISTINCT) without the fix, passes (1) with it; test OK against the fixed binary (Build ID a2f45ef).
f Fix is general across code paths? Yes — all three set-operation modes (intersect/except/union) are threaded from the inner context together; there is a single normalization site.
g Fix generalizes across inputs? Covered the parallel modes: intersect_default_mode and except_default_mode are switched to the inner context in the same change as union_default_mode, so an inner SETTINGS clause controls all three the same way a direct query would.
h Backward compatible? Yes — no setting default, format, or validation change; only which context the inner query's own SETTINGS are read from during normalization.
i Invariants and contracts preserved? Yes — limits_context is a private copy already used for the AST-size limits; the modes+selects invariant of the union AST is unaffected (normalization runs once, before the size check, same order as before).

Session id: cron:clickhouse-worker-slot-2:20260713-083200

Mirror executeQueryImpl ordering: run ApplyWithGlobalVisitor (gated by the
inner query's enable_global_with_statement) before the AST size checks, so a
global CTE that stays small before expansion but grows past max_ast_elements
once inlined into every UNION branch is rejected in eval like in a direct
query. Add a regression to 04512_eval_table_function.

Co-Authored-By: Claude Opus 4.8 <[email protected]>
@groeneai

Copy link
Copy Markdown
Collaborator Author

Fixed in efef3e9. eval now runs ApplyWithGlobalVisitor (gated by the inner query's own enable_global_with_statement) before checkDepth/checkSize, mirroring executeQueryImpl ordering, so the size limits see the post-WITH-expansion AST. Regression added to 04512_eval_table_function.

Pre-PR validation gate (click to expand)
# Question Answer
a Deterministic repro? Yes. eval('WITH 1+2+...+15 AS big SELECT big UNION ALL SELECT big x8 SETTINGS max_ast_elements = 100') passed in eval (pre-fix) while the same text executed directly throws TOO_BIG_AST.
b Root cause explained? eval checked max_ast_depth/max_ast_elements on the PRE-WITH-expansion AST. executeQueryImpl runs ApplyWithGlobalVisitor (under enable_global_with_statement) first, so a global CTE inlined into every branch grows past the limit only after expansion; eval skipped that step and let the over-limit query through.
c Fix matches root cause? Yes. Added ApplyWithGlobalVisitor::visit(query) gated by the inner query's enable_global_with_statement, ordered before the size checks, exactly as executeQueryImpl does.
d Test intent preserved / new tests added? New regression added; no assertions weakened.
e Demonstrated both directions? Yes. A/B'd pre-fix vs post-fix binaries: at max_ast_elements=100 the query passes on pre-fix eval and throws TOO_BIG_AST on post-fix eval (direct execution throws in both).
f General, not a narrow patch? The fix reuses the same visitor + ordering as executeQueryImpl, covering all global-WITH shapes (UNION/INTERSECT/EXCEPT branches, nested subqueries) rather than the single repro.
g Generalizes across inputs? N/A (ordering fix wiring the standard visitor; not an input-type-gated code path).
h Backward compatible? Yes. Gated by the existing enable_global_with_statement (default on); no format/setting-default change.
i Invariants/contracts preserved? Yes. Same visitor/ordering contract as executeQueryImpl; the inner query's own settings context drives expansion and limits.

Session id: cron:clickhouse-worker-slot-1:20260713-093100

@antaljanosbenjamin antaljanosbenjamin self-assigned this Jul 13, 2026
-- non-deterministic and potentially reading a system table, and is not cached by default.
SELECT * FROM eval('SELECT now()') SETTINGS use_query_cache = 1; -- { serverError QUERY_CACHE_USED_WITH_NONDETERMINISTIC_FUNCTIONS }
SELECT * FROM eval('SELECT * FROM system.one') SETTINGS use_query_cache = 1, query_cache_nondeterministic_function_handling = 'save'; -- { serverError QUERY_CACHE_USED_WITH_SYSTEM_TABLE }

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.

Could you add a new test instead of modifying existing one?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Done in a755995. Moved the new regressions into a dedicated 04513_eval_table_function_ast_limits.sql; 04512_eval_table_function.sql/.reference are restored to their pre-PR content.

Pre-PR validation gate (click to expand)
# Check Result
a Deterministic repro? N/A (test-file reorganization, no code change)
b Root cause explained? N/A
c Fix matches root cause? N/A
d Test intent preserved / new tests added? Yes: the seven assertions are byte-identical, only relocated; 04512 is back to its pre-PR state
e Demonstrated both directions? Yes: all 7 assertions verified against the fixed binary (inner DISTINCT -> 1, ambiguous UNION -> EXPECTED_ALL_OR_DISTINCT, outer/inner max_ast_elements -> TOO_BIG_AST, max_ast_depth -> TOO_DEEP_AST, inner relax -> 55, global-WITH expansion -> TOO_BIG_AST)
f Fix general, not a narrow patch? N/A (no code bug)
g Generalizes across inputs/types? N/A
h Backward compatible? N/A
i Invariants/contracts preserved? Yes: new test is parallel-safe (no shared state, no no-parallel)

Session id: cron:clickhouse-worker-slot-1:20260713-113700

groeneai and others added 2 commits July 13, 2026 11:40
Move the union_default_mode / max_ast_* / global-WITH regressions added by
this PR out of 04512_eval_table_function into a new 04513 test, restoring
04512 to its pre-PR content, as requested in review.

Co-Authored-By: Claude Opus 4.8 <[email protected]>
@groeneai

Copy link
Copy Markdown
Collaborator Author

CI finish ledger — a755995

Every failure below has an owner: a fixing PR (ours), or the private sync (exempt).

Check / test Reason Owner / fixing PR
Stateless (amd_asan_ubsan distributed/amd_debug/amd_msan WasmEdge/amd_tsan s3/arm_binary, sequential) / 02346_text_index_bug108519_qcc_skip_index flaky (randomized materialize_statistics_on_insert=True) #110260 (ours, merged 2026-07-13 15:05Z); this build predated it, merged master @ e68f5df to pick it up
AST fuzzer (amd_tsan) / Logical error 'or_argument_nodes.size() > 1' (STID 2508-3abc) trunk (single-arg or() aborts LogicalExpressionOptimizer; unrelated to this PR's TableFunctionEval diff) #107113 (ours, open)
Stateless (amd_tsan s3, sequential) / Scraping system tables infra (minio_audit_logs dump timeout on s3 configs) a fix task is moved to pending (investigating; fixing-PR link to follow here)
CH Inc sync - CH Inc sync (private, not actionable)

Session id: cron:our-pr-ci-monitor:20260713-183000

@groeneai

Copy link
Copy Markdown
Collaborator Author

Correction to the ledger above: the Scraping system tables / minio_audit_logs dump-timeout line has an existing fixing PR owner — #110099 (ours, open, info-only follow-up to merged #109837), not a new fix task.

The intersect_default_mode / except_default_mode branches of
SelectIntersectExceptQueryVisitor are driven from the inner query's own
settings, but 04513 only exercised UNION. Add a duplicate-sensitive INTERSECT
case and an EXCEPT case with inner default mode ALL over an outer DISTINCT, so
eval keeps duplicates the same way direct execution does.

Co-Authored-By: Claude Opus 4.8 <[email protected]>
@groeneai

Copy link
Copy Markdown
Collaborator Author

CI finish ledger — d9ed60b

Every failure below has an owner. Only CH Inc sync is exempt.

Check / test Reason Owner / fixing PR
Integration tests (amd_msan 7/8; amd_tsan 3/6) / test_replicated_database::test_replicated_table_structure_alter flaky (trunk Replicated-DB DDL-recovery race; 230 PRs / 41 master, 14d) #110030 (ours, open)
Sync — CH Inc sync (private, not actionable)

Session id: cron:our-pr-ci-monitor:20260714-093000

@clickhouse-gh

clickhouse-gh Bot commented Jul 29, 2026

Copy link
Copy Markdown
Contributor

LLVM Coverage Report

Metric Baseline Current Δ
Lines 86.30% 86.40% +0.10%
Functions 91.90% 91.90% +0.00%
Branches 78.50% 78.50% +0.00%

Changed lines: Changed C/C++ lines covered: 16/16 (100.00%) · Uncovered code

Full report · Diff report

@groeneai

Copy link
Copy Markdown
Collaborator Author

CI finish ledger — 442563c

Every failure below has an owner: a fixing PR (mine or external), or a full-effort fix task
whose fixing-PR link will be posted here when it opens. Only CH Inc sync is exempt.

Check / test Reason Owner / fixing PR
Stateless tests (amd_llvm_coverage, ParallelReplicas, s3 storage, parallel) / 01666_merge_tree_max_query_limit the per-table concurrency throttle is keyed on query id, and secondary parallel-replica reads are sent with an empty query id, so the holder query is rejected with 202 TOO_MANY_SIMULTANEOUS_QUERIES by its own secondary reads #112385 (mine, open)

This is a lane-reachability regression, not a defect in this PR: the test became reachable on the
ParallelReplicas lane when #111230 removed its parallel_replicas_blacklist.txt entry, and it
fails the same way on master. This PR's diff is src/TableFunctions/TableFunctionEval.cpp plus one
stateless test, which does not touch the concurrency throttle or parallel replicas.

Session id: cron:our-pr-ci-monitor:20260729-060000

@clickhouse-gh

clickhouse-gh Bot commented Aug 14, 2026

Copy link
Copy Markdown
Contributor

Dear @antaljanosbenjamin, you haven't been active on this PR for 30 days. You will be unassigned. Will you continue working on it? If so, please feel free to reassign yourself.

@groeneai groeneai added the groeneai-origin-unknown PR origin: unclassified (legacy task) label Aug 19, 2026
@antaljanosbenjamin

Copy link
Copy Markdown
Member

@groeneai can you merge latest master?

Requested by @ antaljanosbenjamin on the pull request.

Conflict in `src/TableFunctions/TableFunctionEval.cpp`: master added the
construction-settings passes to `eval` (`wrapPerArmConstructionSettings`,
`wrapNestedConstructionSettings`) in the same region this branch adds the AST
size limits and drives the set-operation normalization from the generated
query's own settings. Both are kept, ordered as in `executeQueryImpl`: the
per-arm pass stays ahead of the private context built by
`InterpreterSetQuery::applySettingsFromQuery`, so per-arm settings are not read
as query-level ones, and the size limits run last, after
`wrapNestedConstructionSettings`, so the AST that gets measured is the wrapped
one. Nothing from master is reverted: the merge result differs from master by
this branch's three files only.

Co-Authored-By: Claude Opus 5 <[email protected]>
@groeneai

Copy link
Copy Markdown
Collaborator Author

Merged master (d33f2116). The merge conflicted in src/TableFunctions/TableFunctionEval.cpp, where master had added the construction-settings passes to eval in the same block this branch uses for the AST size limits and the inner-settings set-operation normalization. I kept both, ordered as in executeQueryImpl: the per-arm pass ahead of InterpreterSetQuery::applySettingsFromQuery, and the size limits last, after wrapNestedConstructionSettings. Nothing from master is reverted (the merged tree differs from master by this branch's three files only), and 04512_eval_table_function, 04538_eval_construction_settings and 04513_eval_table_function_ast_limits all pass on it, 50 randomized runs each.

…n `eval`

`executeQueryImpl` runs the `enforce_strict_identifier_format` formatter pass
after a query's own `SETTINGS` clause is applied and before analysis, but
`TableFunctionEval::parseArguments` did not, so the setting was bypassed by
moving the query text into `eval`. With `enforce_strict_identifier_format = 1`,
`SELECT 1 AS "bad-name"` is rejected with `BAD_ARGUMENTS`, while
`SELECT * FROM eval('SELECT 1 AS "bad-name"')` returned a `bad-name` column.
`view(SELECT 1 AS "bad-name")` and a plain subquery are both rejected, because
their inner query is part of the outer AST that the pass formats, so `eval` was
the only mechanism that let such an identifier through.

Run the pass on the generated query, reading the flag from the generated query's
own resolved settings so an inner `SETTINGS enforce_strict_identifier_format = 1`
also applies. It runs next to the AST size limits, after the construction
settings are materialized, so it sees the AST that is stored and analyzed. That
also covers an identifier introduced only by the generated query's own `filter`
or `order`, which `executeQueryImpl` checks too. A generated query that is both
ambiguous in its set operation mode and carries a rejected identifier reports the
normalization error first, because `eval` has to resolve the modes from the inner
settings before it can measure the AST.

Reported by clickhouse-gh[bot] on the pull request.

Also trim the comments this pull request added in `parseArguments` down to the
local invariants; the motivation for each pass belongs in the commit messages.

Co-Authored-By: Claude Opus 5 <[email protected]>
}
{
NormalizeSelectWithUnionQueryVisitor::Data data{settings[Setting::union_default_mode]};
NormalizeSelectWithUnionQueryVisitor::Data data{inner_settings[Setting::union_default_mode]};

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.

union_default_mode now comes from inner_settings, but it still only reaches the AST that exists before wrapNestedConstructionSettings. Direct execution does the opposite: it materializes SETTINGS filter / select / order first and only then runs SelectIntersectExceptQueryVisitor / NormalizeSelectWithUnionQueryVisitor (executeQuery.cpp:2725-2784), so set operations introduced by those snippets inherit the generated query's own defaults too.

That means eval still diverges on this surface. A minimal repro is:

SELECT *
FROM eval(
    'SELECT 1 AS x SETTINGS filter = ''1 IN (SELECT 1 UNION SELECT 1)'', union_default_mode = ''DISTINCT'''
);

The scalar subquery inside filter is parsed only in wrapNestedConstructionSettings, after the normalization pass here has already run, so the later StorageView/analyzer path sees that UNION with union_default_mode still unspecified (or from the outer context) even though direct execution normalizes it as DISTINCT. The same hole exists for INTERSECT / EXCEPT subqueries introduced by construction settings. Please rerun the set-operation visitors on the wrapped AST, or move wrapNestedConstructionSettings ahead of them, and add a focused regression around a construction-setting-generated subquery.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Confirmed, and it is wider than union_default_mode: any set operation a construction snippet introduces is rejected outright, whatever its mode.

The parser only fills list_of_modes and leaves union_mode at UNION_DEFAULT; SelectIntersectExceptQueryVisitor and NormalizeSelectWithUnionQueryVisitor are what resolve it. A set operation that never reaches them arrives at UnionNode's constructor as a *_DEFAULT mode and throws there (src/Analyzer/UnionNode.cpp:53). So the snippet-introduced case does not inherit a wrong mode, it fails. Every row below is SELECT 1 AS x SETTINGS filter = '<snippet>', run directly and through eval:

<snippet> direct eval
1 IN (SELECT 1 UNION SELECT 1), plus union_default_mode = 'DISTINCT' 1 36 BAD_ARGUMENTS
1 IN (SELECT 1 UNION ALL SELECT 1) 1 36
1 IN (SELECT 1 INTERSECT SELECT 1) 1 36
1 IN (SELECT 1 EXCEPT SELECT 2) 1 36
1 IN (SELECT 1), control, no set operation 1 1

Every cell is identical on a master build at 82cfa6a, which does not contain this PR, so none of it is introduced or worsened here. That is a result and not a blind arm: the same harness does see this PR where the visitors run, with eval('SELECT 1 AS x UNION SELECT 1 AS x SETTINGS union_default_mode = ''DISTINCT''') returning 1 on this head and 558 on that master build.

I am not making that change here. Both remedies you list alter the query-construction settings passes (f447e3a, 4fa3556), whose ordering the comment above wrapPerArmConstructionSettings states is deliberate. A regression test would pin the current failure rather than the fixed behaviour, so I am not adding one either. Both remaining divergences are in the description now, with the measurements, for whoever owns that pass to decide.

@clickhouse-gh

clickhouse-gh Bot commented Aug 26, 2026 •

Copy link
Copy Markdown
Contributor

Build profile diff (arm_release)

Comparing 51f0d7c55 with master d2d24986c (stripped binary size, per-symbol sizes and ThinLTO time; compile times per translation unit against the most recent warmup build that recompiled it).

✅ No significant changes.

Binary sizes

programs/clickhouse-stripped: smaller than the master baseline by the known offset between the two builds, so the difference is not shown. A delta that differs from the offset by more than 50% of it is shown, in either direction.

The official master build is compiled with -g and a pull request build is not, and XRay counts debug instructions towards its instrumentation threshold, so master instruments thousands of functions more and its binary is ~0.4% larger no matter what the pull request does.

Compile time of recompiled translation units

7 translation units recompiled, 10 s compile time in total, 7 of them have a recent master baseline.

Job report

@groeneai

Copy link
Copy Markdown
Collaborator Author

CI finish ledger — 0b0d3fe

Every failure below has an owner: a fixing PR, or a full-effort fix task whose fixing-PR link gets posted here when it opens. Only CH Inc sync is exempt.

Check / test Reason Owner / fixing PR
Docs examples / Documentation examples stale docs known-failures entry: Function/catboostEvaluate#0 stopped failing once CatBoost was removed, so the runner reports a known failure that no longer exists #116566 (external, merged 2026-08-26T20:09:12Z) restores CatBoost and clears it. Its merge commit b3767133 is 191 commits ahead of this head, so the fix arrives with the next master merge
Stress test (arm_msan) / MemorySanitizer: use-of-uninitialized-value (STID: None) the MSan report lost its own stack (nested bug in the same thread, aborting), so the uninitialized read is unattributable #112008 (mine, open)
Stateless tests (amd_llvm_coverage, AsyncInsert, s3 storage, parallel) job hit the 9000s budget and was killed (exit code [-15]) after the test phase, so no test failed #116209 (mine, open)

No failure is PR-caused: this diff is src/TableFunctions/TableFunctionEval.cpp plus one stateless test, and none of the three rows reaches that path. Master's own Docs examples was red from 16:29Z to 21:19Z and green again at 22:24Z on b3767133.

Session id: cron:our-pr-ci-monitor:20260826-223000

@clickhouse-gh clickhouse-gh Bot added the comp-table-functions Table functions for temporary read/write to external systems (FROM ... tableFunction()). label Sep 4, 2026
groeneai and others added 2 commits November 4, 2026 13:41
Merges master at b306e87 to resolve the conflict in
src/TableFunctions/TableFunctionEval.cpp.

- Setting externs: master renamed allow_experimental_eval_table_function to
  enable_eval_table_function and dropped allow_experimental_analyzer (the old
  analyzer is gone). Kept master's extern and this branch's additional ones.
- ApplyWithGlobalVisitor::visit now takes max_expanded_ast_elements (master,
  e709ca8 / caed1b4). Pass it from the generated query's own
  settings, the same way executeQueryImpl passes it for a usual query, so the
  WITH expansion in eval is bounded like in direct execution.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…iscriminating

The outer query `SELECT count() FROM eval(...)` needs `max_ast_depth = 9` on its
own, so with `max_ast_depth = 3` it was rejected by its own check before `eval`
parsed the generated query, and `(((((1)))))` parses to the same depth as
`SELECT 1` anyway. The assertion passed with and without the check in `eval`.

Use a limit the outer query fits into (15, with a positive control) and a
generated query that needs depth 25: without the check `eval` returns 1, with it
`TOO_DEEP_AST`, same as executing the generated query directly.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@clickhouse-gh clickhouse-gh Bot added pr-improvement Pull request with some product improvements and removed pr-bugfix Pull request with bugfix, not backported by default labels Nov 4, 2026
@groeneai

groeneai commented Nov 4, 2026

Copy link
Copy Markdown
Collaborator Author

CI finish ledger - 51f0d7c

Every failure below has an owner: a fixing PR (mine or external), or a full-effort fix task
whose fixing-PR link will be posted here when it opens. Only CH Inc sync is exempt.

Check / test Reason Owner / fixing PR
Fast test (arm_darwin) / 05495_part_moves_between_shards_step_retry not from this PR (it changes only the eval table function): timeout on the macOS runner. The test is new on master (#129029, merged today) and timed out the same way on 2 other unrelated PRs in the same 3 hours (3 of about 105 arm_darwin runs). Its ALTER TABLE shard_src MOVE PART ... TO SHARD failed with PART_IS_TEMPORARILY_LOCKED (part not in the snapshot of previous virtual parts), so the polling loops never saw a move entry a fix task is created (investigating at full effort, fixing-PR link to follow here)
Mergeable Check, PR praktika rollups of the row above a fix task is created (the one for the row above)

CIDB has no other FAIL or ERROR row on this head.

Session id: cron:our-pr-ci-monitor:20261104-180026

@groeneai

groeneai commented Nov 5, 2026

Copy link
Copy Markdown
Collaborator Author

Fixing PR for Fast test (arm_darwin) / 05495_part_moves_between_shards_step_retry: #129409

This branch has not been deployed

No deployments
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 comp-table-functions Table functions for temporary read/write to external systems (FROM ... tableFunction()). groeneai-origin-unknown PR origin: unclassified (legacy task) pr-improvement Pull request with some product improvements

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants