Skip to content

Remove the kql table function - #105101

Merged
alexey-milovidov merged 2 commits into
masterfrom
remove-kql-table-function
May 17, 2026
Merged

alexey-milovidov merged 2 commits into
masterfrom
remove-kql-table-function

Conversation

@alexey-milovidov

@alexey-milovidov alexey-milovidov commented May 16, 2026 •

Copy link
Copy Markdown
Member

The kql(...) table function was a low-quality bolted-on feature that hijacked function parsing in ExpressionListParsers.cpp and rewrote itself into a view(...) call. It is removed entirely. The KQL dialect (SET dialect = 'kusto') remains supported.

The internal ParserKQLTableFunction class — which is still needed by the KQL dialect to parse parenthesized KQL subqueries (e.g. inside the in operator) — is renamed to ParserKQLParenExpression to reflect what it actually does now.

Changelog category (leave one):

  • Backward Incompatible Change

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

Removed the kql table function. Use SET dialect = 'kusto' to run queries in the KQL dialect.

Documentation entry for user-facing changes

  • Documentation is written (mandatory for new features)

Version info

  • Merged into: 26.5.1.725

The `kql(...)` table function was a low-quality bolted-on feature that
hijacked function parsing in `ExpressionListParsers.cpp` and rewrote
itself into a `view(...)` call. It is removed entirely. The KQL dialect
(`SET dialect = 'kusto'`) remains supported.

The internal `ParserKQLTableFunction` class — which is still needed by
the KQL dialect to parse parenthesized KQL subqueries (e.g. inside the
`in` operator) — is renamed to `ParserKQLParenExpression` to reflect
what it actually does now.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
@clickhouse-gh

clickhouse-gh Bot commented May 16, 2026 •

Copy link
Copy Markdown
Contributor

Workflow [PR], commit [6f7dc71]

Summary: ✅


AI Review

Summary

This PR removes the parser hook that translated kql(...) into view(...), and renames the internal parser class to ParserKQLParenExpression for KQL parenthesized subqueries. The main remaining issue is test evidence: the PR deletes direct kql(...) stateless coverage but does not add a replacement regression test for the new backward-incompatible behavior.

Tests
  • ⚠️ Add a focused negative stateless test proving that kql(...) now fails with UNKNOWN_TABLE_FUNCTION (for example SELECT * FROM kql('x')). The PR removes both direct kql(...) tests and currently has no replacement guard for this contract.
Final Verdict
  • Status: ⚠️ Request changes
  • Minimum required action: add one focused stateless regression test that asserts the removed kql(...) table-function path now returns UNKNOWN_TABLE_FUNCTION.

@clickhouse-gh clickhouse-gh Bot added the pr-backward-incompatible Pull request with backwards incompatible changes label May 16, 2026
return std::make_unique<ViewLayer>(true);
if (function_name_lowercase == "kql")
return std::make_unique<KustoLayer>();
}

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.

This removes the kql table-function hook, but both direct kql(...) stateless tests are deleted in this PR and there is no replacement that asserts the new contract.

Please add a focused negative stateless test (for example, SELECT * FROM kql(...)) that verifies we now return UNKNOWN_TABLE_FUNCTION. For a backward-incompatible removal, that regression coverage is important so this behavior does not silently come back.

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.

We don't need that.

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.

This is still missing in the current diff: both former kql(...) stateless tests were deleted and there is no replacement check that asserts the new contract (kql(...) must fail with UNKNOWN_TABLE_FUNCTION).

For a backward-incompatible removal, please add a focused negative stateless test (for example SELECT * FROM kql('x')) with serverError UNKNOWN_TABLE_FUNCTION so this behavior cannot be reintroduced silently.

@alexey-milovidov

Copy link
Copy Markdown
Member Author

@groeneai, the following CI failures on this PR are unrelated to the change (removal of the kql table function — only src/Parsers/ExpressionListParsers.cpp, src/Parsers/Kusto/* and KQL stateless tests are touched). Please investigate and fix in separate PRs.

  1. Unit tests (asan_ubsan, function_prop_fuzzer) — FunctionsStress.stress

  2. Unit tests (asan_ubsan, function_prop_fuzzer) — AllTests

    • Same fuzzer run, same report; auto-rolled into the umbrella issue.
    • Tracked by: AllTests #105040
  3. CH Inc sync

    • Caused by Build (arm_tidy) failing in the sync PR ClickHouse/clickhouse-private#58151 with error: nested redundant #if; consider removing it in src/Processors/QueryPlan/ReadFromMergeTree.cpp:4627 and :4707. The public file is 4530 lines long and the public Build (arm_tidy) job is green on this PR, so the failure is in private-only code, not caused by this change.

@groeneai

Copy link
Copy Markdown
Collaborator

Thanks @alexey-milovidov — all three failures confirmed unrelated to this PR (KQL parser removal). Status of each:

1. FunctionsStress.stress — arrayResize 79s timeout on max_execution_time=15s
Tracked under chronic umbrella #104877 (FunctionsStress.stress, OPEN, labels testing/fuzz). The arrayResize(Array(Map(Int256, Float64)), Int256) shape is one of several non-determinism shapes in this family (indexOf, nullIf, caseWithExpression, if, etc.). No fix is in flight specifically for arrayResize yet — the family is being addressed piecewise as individual shapes get reproducers (#104804, #104858, #104989, #104992 have all landed for sibling shapes).

2. AllTests — function_prop_fuzzer roll-up
Tracked under #105040 (AllTests, OPEN, labels testing/fuzz). Auto-rolled from the same fuzzer run as (1).

3. CH Inc sync — Build (arm_tidy) nested redundant #if at ReadFromMergeTree.cpp:4627/:4707
Confirmed not actionable from the public repo. The public file is 4530 lines and public Build (arm_tidy) is green on this PR — the failure is in private-only code in ClickHouse/clickhouse-private#58151. Deferred to private CI ownership.

This PR is safe to merge as soon as the rest of CI completes.

@alexey-milovidov

Copy link
Copy Markdown
Member Author

@groeneai, please focus on "FunctionsStress.stress — arrayResize 79s timeout on max_execution_time=15s" - find a way to guard/limit these heavy invocations in the implementation and send a PR.

@clickhouse-gh

clickhouse-gh Bot commented May 17, 2026

Copy link
Copy Markdown
Contributor

LLVM Coverage Report

Metric Baseline Current Δ
Lines 84.10% 84.20% +0.10%
Functions 91.40% 91.40% +0.00%
Branches 76.50% 76.60% +0.10%

Changed lines: 100.00% (20/20) | lost baseline coverage: 2 line(s) · Uncovered code

Full report · Diff report

@groeneai

Copy link
Copy Markdown
Collaborator

@alexey-milovidov fix PR is up: #105147 — "Make arrayResize honor max_execution_time on heavy element types (#104877)".

Root cause. GatherUtils::resizeDynamicSize / resizeConstantSize call writeSlice once per output element from an inner for loop that never polls the cancellation flag. When the fuzzer hands arrayResize an Int256 size that's negative (here -550164762), the -static_cast<size_t>(size) arithmetic yields a positive length ≈ 5.5×10⁸, still below MAX_ARRAY_SIZE = 1 << 30, so the upper-bound check passes. On Map(Int256, Float64) each writeSlice is ~70 ns and the loop runs for ~40 s before the pipeline can observe the deadline.

Fix. A tiny helper DB::GatherUtils::checkQueryCancellation() (in GatherUtils.cpp so Common/CurrentThread.h doesn't leak into Algorithms.h) throws QUERY_WAS_CANCELLED when CurrentThread::isQueryCanceled() returns true. The four extend branches in resizeDynamicSize / resizeConstantSize call it every 16384 iterations (period is a power of two, so the modulo folds to a bit-and).

Verification. Reproducer SELECT length(arrayResize([map(toInt256(1), toFloat64(2))], materialize(toInt256(-550164762)))) with max_execution_time = 3: 41872 ms past deadline pre-fix vs. 3039 ms post-fix. Regression test at tests/queries/0_stateless/04252_104877_array_resize_max_execution_time.sql covers all three branches, passes 30/30 with --no-random-settings.

Once #105147 lands, #104694 (the ProcessList wire-up reverted by #105146) should be re-introducible without re-tripping P_TIMEOUT_NOT_HONORED on arrayResize. I'll keep watching #104877 and bisect any sibling "slow function" hits the fuzzer surfaces next.

@alexey-milovidov alexey-milovidov self-assigned this May 17, 2026
@alexey-milovidov
alexey-milovidov merged commit 259dd37 into master May 17, 2026
166 of 167 checks passed
@alexey-milovidov
alexey-milovidov deleted the remove-kql-table-function branch May 17, 2026 23:16
@robot-clickhouse-ci-1 robot-clickhouse-ci-1 added the pr-synced-to-cloud The PR is synced to the cloud repo label May 17, 2026
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-synced-to-cloud The PR is synced to the cloud repo

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants