Repository navigation
Conversation
|
Workflow [PR], commit [ebaceca] Summary: ✅
AI ReviewSummaryThis PR removes the client-side Findings
Tests
Final VerdictChanges requested. LLVM Coverage Report
Changed lines: Changed C/C++ lines covered: 4/5 (80.00%) · Uncovered code |
|
A bit concerned about potential security implications of this. |
I can limit it to SELECT, SET and EXPLAIN. Otherwise it requires extra steps to debug queries that uses external tables with |
|
Please merge with current master to trigger the CI again |
65e4494 to
350947c
Compare
|
Hi @AVMusorin please, once a PR starts reviews we recommend to avoid force pushes unless totally necessary to simplify reviews of subsequent changes ;) |
There was a problem hiding this comment.
Looking a bit more into this change, this seems to suppress the exception but does not short-circuit this last call on every single non-SELECT query in interactive mode. Suppose a set. So the complete payload is re-uploaded anyways.
I think we must early return to avoid this somehow.
There was a problem hiding this comment.
I agree with the concern, but I don't think we should try to enumerate every query kind that may need external tables. Looks like the safe approach is to keep the general behavior correct and only short-circuit a small set of queries that are guaranteed not to resolve external tables, such as SET.
|
Hi @AVMusorin Any progress on this? DO you need any help or support from our side? |
If it is a non-interactive client and non select -- the query will be rejected
| @@ -0,0 +1,66 @@ | |||
| #!/usr/bin/expect -f | |||
There was a problem hiding this comment.
Is it possible to make this test as pure sql+reference pair instead of .expect?
Or in the worst case an integration test?
There was a problem hiding this comment.
Is it possible to make this test as pure sql+reference pair instead of .expect?
No, because I want to test it in interactive mode
Or in the worst case an integration test?
Looks like yes, I found some useful helpers in the codebase
|
📊 Cloud Performance Report 🟢 AI verdict: This sync PR changes only the command-line client's interactive-mode external-table handling (src/Client/ClientBase.cpp) plus a doc line and a new integration test — the server's query-execution hot path is untouched, so none of these per-query deltas can plausibly be caused by the PR. The flagged clickbench improvements (Q13/Q15/Q16/Q18/Q30/Q31) and the Q28 +7.4% regression are off-path and have been downgraded to not-sure as run-to-run variance. Three very large deltas (clickbench Q23 ×2.4 faster, tpch Q7 ×8.4 faster, Q8 ×2.2 faster) are locked by the large-delta trust override and left as improvements, but given the client-only diff they almost certainly reflect a baseline/environment difference rather than a real code effect. clickbench🟢 1 improved · Flagged queries (8 of 43)
Change = percent below ×2; the ratio of medians (×N faster/slower) beyond, where percent understates the scale. q-value = BH-FDR adjusted p; smaller is stronger evidence. MIRAI flags a query when q < fdr_q (default 0.10) — the value the verdict is based on. tpch_adapted_1_official🟢 2 improved Flagged queries (2 of 22)
Change = percent below ×2; the ratio of medians (×N faster/slower) beyond, where percent understates the scale. q-value = BH-FDR adjusted p; smaller is stronger evidence. MIRAI flags a query when q < fdr_q (default 0.10) — the value the verdict is based on. Debug info
|
Ergus
left a comment
There was a problem hiding this comment.
Thanks for waiting ;)
The change LGTM. Please merge the master branch to trigger the CI and try to get a green CI.
|
@Ergus everything seems nice except private sync |
|
Hi @AVMusorin Very thanks for the patience ;) Yes the issue seems unrelated in private, but produced many tests failures there. We are restricting the CI conditions to merge so let's be good guys ;). Please merge again with master, hopefully the error is fixed now. When done, please, remember to ping me here so I can check again. In case public CI fails and the error seems unrelated, just merge again (I know it is not a perfect system, but let's reduce the risk for potential errors). |
| const auto * select = parsed_query->as<ASTSelectWithUnionQuery>(); | ||
| if (!select && !external_tables.empty()) | ||
| throw Exception(ErrorCodes::BAD_ARGUMENTS, "External tables could be sent only with select query"); | ||
| if (!select && !external_tables.empty() && !is_interactive) |
There was a problem hiding this comment.
Allowing every interactive non-SELECT through this branch also means the external table now exists for unqualified DDL. With clickhouse-client --external --name=users ..., a later DETACH TABLE users or DROP TABLE users no longer targets the real default.users: Context::resolveStorageID prefers the just-uploaded external users first, and InterpreterDropQuery then routes the statement down the temporary-table path instead of the ordinary table path. In current master that means DETACH TABLE users starts throwing the temporary-table syntax error, while DROP / TRUNCATE never reach the real table. Please keep the interactive exemption to statement kinds that legitimately inspect external tables (DESCRIBE / EXPLAIN / similar), or only attach external tables when the current AST actually references them.
| const auto * select = parsed_query->as<ASTSelectWithUnionQuery>(); | ||
| bool has_external_data = !external_tables.empty() || !external_scalars.empty(); | ||
| if (!select && has_external_data) | ||
| if (!select && has_external_data && !is_interactive) |
There was a problem hiding this comment.
Allowing every interactive non-SELECT through this branch also enables mutating INSERTs against query-scoped external tables. executeQuery loads the uploaded external table before InterpreterInsertQuery::getTable resolves the destination, and that resolver still goes through Context::resolveStorageID, which prefers an external table in the current query context first. Concretely, start clickhouse-client --external --name=users ..., then run INSERT INTO users VALUES (...): the target resolves to the temporary external users, the insert succeeds there, and the rows disappear with the query context instead of reaching default.users. Please either keep the interactive exemption away from write statements, or add a collision check for unqualified write targets before allowing this path.
LLVM Coverage Report
Changed lines: Changed C/C++ lines covered: 4/5 (80.00%) · Uncovered code |
`master` moved the documentation from the Docusaurus tree under `docs/en/**/*.md` to the Mintlify tree at `docs/**/*.mdx`, deleting every file this branch edits. The edits are replayed at the new paths: - `docs/en/engines/table-engines/special/external-data.md` -> `docs/reference/engines/table-engines/special/external-data.mdx`
|
Dear @Ergus, 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. |
| const auto * select = parsed_query->as<ASTSelectWithUnionQuery>(); | ||
| bool has_external_data = !external_tables.empty() || !external_scalars.empty(); | ||
| if (!select && has_external_data) | ||
| if (!select && has_external_data && !is_interactive) |
There was a problem hiding this comment.
This still leaves the interactive exemption too broad: once executeQuery loads the uploaded tables before interpretation, any unqualified statement that resolves its target with ResolveAll will prefer the temporary external table. INSERT/DROP already have threads, but the same applies to ALTER TABLE, OPTIMIZE TABLE, and CHECK TABLE (InterpreterAlterQuery::executeToTable, InterpreterOptimizeQuery::execute, InterpreterCheckQuery::executeImpl). For example, clickhouse-client --external --name=users ... followed by ALTER TABLE users COMMENT COLUMN id 'x' or OPTIMIZE TABLE users never reaches default.users; it hits the ephemeral uploaded users instead. Please keep this path to statement kinds that intentionally inspect external tables, or only attach external tables when the analyzed AST actually references them.
Build profile diff (arm_release)Comparing ✅ No significant changes. Binary sizes
Only the stripped binary is compared: the official master build keeps debug symbols while PR builds strip them, so the other binaries differ by construction. Compile time of recompiled translation units7 translation units recompiled, 17 s compile time in total, 7 of them have a recent master baseline. |
Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):
Allow using external tables with any queries in the interactive mode
Documentation entry for user-facing changes
Workflow [PR]
Sync PR [sync-upstream/pr/97091]