Skip to content

Extend 04064_inline_insert_data and randomize send_table_structure_on_insert_with_inline_data (follow-up to #101034) - #104640

Merged
alexey-milovidov merged 11 commits into
ClickHouse:masterfrom
groeneai:groeneai/inline-insert-data-tests-101034-followup
Jul 10, 2026
Merged

alexey-milovidov merged 11 commits into
ClickHouse:masterfrom
groeneai:groeneai/inline-insert-data-tests-101034-followup

Conversation

@groeneai

@groeneai groeneai commented May 11, 2026 •

Copy link
Copy Markdown
Collaborator

Follow-up to #101034. @PedroTadim asked in PR review for:

  1. an INSERT SELECT corner case to be added to tests/queries/0_stateless/04064_inline_insert_data.sh,
  2. a case with async_insert disabled, and
  3. randomization of the new send_table_structure_on_insert_with_inline_data setting so CI exercises both the legacy and the new server-side inline parsing path.

This PR addresses all three.

Changes

tests/queries/0_stateless/04064_inline_insert_data.sh / .reference

  • Two INSERT ... SELECT cases — one with --inline-insert-data, one with send_table_structure_on_insert_with_inline_data = 0. SELECT-driven inserts have no inline data, so the new path is bypassed via the !insert->select guard in is_inline_insert_data. The cases verify that requesting inline insert data mode does not break SELECT-driven INSERTs.
  • Two --async_insert 0 cases (one via the CLI flag, one via the setting). The user's explicit choice takes precedence over async_insert on the client side, so the data is parsed by the server inline regardless of the async insert toggle.

The new rows extend the existing SELECT * ... ORDER BY x dump (rows 8..13) without changing any prior assertions or the negative-test section.

tests/clickhouse-test

Add send_table_structure_on_insert_with_inline_data to SettingsRandomizer.settings (50/50 bool). This makes CI exercise both the legacy "client converts inline data to native blocks" path and the new "server parses inline data" path that #101034 introduced.

Tests can opt out the same way as for any other randomized setting:

  • per-query: SETTINGS send_table_structure_on_insert_with_inline_data = 1
  • per-test: -- Tags: no-random-settings

Verification

Test run locally with the patched binary:

  • tests/clickhouse-test 04064_inline_insert_data — OK.
  • tests/clickhouse-test --test-runs 50 04064_inline_insert_data — 50/50 OK with full randomization.
  • All six semantic paths (legacy vs new, VALUES vs SELECT vs format-driven, async_insert={0,1}) verified to insert rows correctly via direct clickhouse-client queries.

Changelog category (leave one):

  • CI Fix or Improvement (changelog entry is not required)

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

Not required.

Documentation entry for user-facing changes

  • Documentation is written (mandatory for new features)

Version info

  • Merged into: 26.7.1.784 (included in 26.7 and later)

…ndomize the setting

Follow-up to ClickHouse#101034. @PedroTadim asked to:
1. Add an INSERT SELECT corner case to `04064_inline_insert_data.sh`.
2. Add a case with `async_insert` disabled.
3. Randomize the new `send_table_structure_on_insert_with_inline_data` setting
   so CI exercises both the legacy and the new server-side parsing path.

Changes:

* `tests/queries/0_stateless/04064_inline_insert_data.sh` and `.reference`:
  - Two INSERT SELECT cases (with the `--inline-insert-data` flag and with
    `send_table_structure_on_insert_with_inline_data = 0`). INSERT SELECT
    queries do not have inline data, so the new inline path is bypassed via
    the `!insert->select` guard in `is_inline_insert_data`. The cases verify
    that requesting inline insert data mode does not break SELECT-driven
    INSERTs.
  - Two cases with `--async_insert 0` (one via the CLI flag, one via the
    setting). The user's explicit choice takes precedence over `async_insert`
    on the client side, so the data is parsed by the server inline regardless
    of the async insert toggle.

* `tests/clickhouse-test`:
  - Add `send_table_structure_on_insert_with_inline_data` to
    `SettingsRandomizer.settings` so CI exercises both the legacy "client
    converts inline data to native blocks" path and the new "server parses
    inline data" path.
@groeneai

Copy link
Copy Markdown
Collaborator Author

cc @PedroTadim @alexey-milovidov — follow-up to #101034 addressing @PedroTadim's review requests: extends 04064_inline_insert_data with the INSERT SELECT corner case and an async_insert = 0 case, and adds send_table_structure_on_insert_with_inline_data to the random-settings pool. Test passes 50/50 locally with full randomization. Session id: cron:clickhouse-ci-task-worker:20260511-211500.

@groeneai

Copy link
Copy Markdown
Collaborator Author

Pre-PR validation (adapted — this is a test-coverage / randomization follow-up, not a bug fix):

a) Deterministic repro? N/A — no failure was reproduced. This PR adds coverage for corner cases @PedroTadim explicitly listed; it does not fix a known bug.

b) Root cause explained? N/A — no defect. The motivation is reviewer-requested follow-up to PR #101034: exercise the inline-insert-data path with INSERT SELECT (!insert->select guard), async_insert = 0 (CLI flag and setting precedence), and 50/50 randomization of send_table_structure_on_insert_with_inline_data so master CI exercises both client-side block conversion and server-side parsing.

c) Fix matches root cause? N/A — see (b).

d) Test intent preserved? Yes. Existing rows 1..7 in the dump and both negative grep -c checks at the end of the test are unchanged. New rows 8..13 are appended before the existing SELECT * ... ORDER BY x to extend coverage, not narrow the existing assertions.

e) Both directions demonstrated? Verified by direct queries that all six semantic paths ({legacy,inline_flag,inline_setting} × {VALUES, SELECT, format-driven, async_insert={0,1}}) insert the correct row content. tests/clickhouse-test --test-runs 50 04064_inline_insert_data passed 50/50 with full randomization (and therefore with the new send_table_structure_on_insert_with_inline_data randomized 50/50 across runs).

f) Generalized / no narrow patch? Yes for the randomization side: adding the setting to SettingsRandomizer.settings exercises the new path uniformly across the entire stateless suite, not just 04064. Tests that have legitimate reasons to depend on a fixed value can opt out via SETTINGS send_table_structure_on_insert_with_inline_data = ... or -- Tags: no-random-settings as usual.

Session id: cron:clickhouse-ci-task-worker:20260511-211500.

@nikitamikhaylov nikitamikhaylov added the can be tested Allows running workflows for external contributors label May 11, 2026
@clickhouse-gh

clickhouse-gh Bot commented May 11, 2026 •

Copy link
Copy Markdown
Contributor

Workflow [PR], commit [1dc5a0a]

Summary: ✅


AI Review

Summary

This PR does what it claims: it broadens coverage for send_table_structure_on_insert_with_inline_data, documents and pins the tests that still depend on the legacy client-parsed path, and strengthens 04064_inline_insert_data with path-sensitive async_insert = 0 assertions. The current diff matches the discussion history, the latest Praktika report on PR #104640 is green, and I did not find a new correctness or coverage gap in the touched tests.

Final Verdict

Status: ✅ Approve

@clickhouse-gh clickhouse-gh Bot added the pr-ci label May 11, 2026
Randomizing `send_table_structure_on_insert_with_inline_data` exposed five
stateless tests that depend on the legacy "client converts inline data to
native blocks" path. The randomization itself is correct and surfaces real
behavior differences in the new server-side parsing path (added in ClickHouse#101034);
the tests, however, were never written to cover that dimension.

Fixes applied per test:

* `04027_json_input_format` — change `-- { clientError 117 }` to `-- { error 117 }`
  (9 occurrences). The test verifies that ambiguous JSON column names are
  rejected. With the legacy path the client parses and reports the error;
  with the inline path the server parses and reports the same error. Both
  paths correctly detect the ambiguity, so accept the error from either side
  (this is a genuine improvement in test coverage, not a band-aid).

* `04045_values_insert_trailing_comment` — pin via `Random settings limits`
  comment. The inline path has a separate, pre-existing multi-query parsing
  issue: a trailing SQL comment after VALUES data inside a multi-query stream
  silently swallows subsequent queries. Keep this test focused on the
  trailing-comment behavior in the legacy path it was written for.

* `03229_async_insert_alter` — pin via `Random settings limits`. The test
  asserts `data_kind` in `system.asynchronous_insert_log`. The inline path
  bypasses async insert (`is_async_insert_with_inlined_data` becomes false
  in `ClientBase`), so log entries change from `Preprocessed` to `Parsed`.
  Pin the legacy path so the async-insert log assertions remain meaningful.

* `01173_transaction_control_queries` — pin via `Random settings limits`.
  The inline path triggers async insert which interacts badly with
  transactions (`Async inserts inside transactions are not supported`). The
  test is about transaction-control semantics, not about which side parses
  inline data; pin the legacy path so transactions remain testable here.

* `00753_system_columns_and_system_tables_long` — pin via `Random settings
  limits`. The inline path builds the in-memory block with a different
  layout, so `system.tables` reports different `total_bytes` for the
  `Memory` engine (e.g. 130 -> 256). Pin the legacy path; this test is
  about system-table reporting, not block layout.

The first fix is the right semantic answer (either side reporting the same
error is valid). The four pins are documented technical debt — each
behavior delta in the inline path is a candidate follow-up bug for the
team to triage. CI report:
https://s3.amazonaws.com/clickhouse-test-reports/json.html?PR=104640
@groeneai

Copy link
Copy Markdown
Collaborator Author

Followed up on the PR-caused failures from the previous push. The CI's --diagnose-random-settings correctly identified --send_table_structure_on_insert_with_inline_data 0 as the culprit for all five stateless tests. Investigation showed they are all real behavior differences between the legacy "client converts inline data to native blocks" path and the new server-side parsing path (#101034); the tests themselves were never written to exercise that dimension.

Findings per test (in increasing severity):

  1. 04027_json_input_format — clientError 117 annotation no longer matches when the server parses inline data, because the same Ambiguous field (...) exception is then raised as a serverError. Either side correctly detects the ambiguity, so this is just a too-strict annotation. Fix is semantic: change -- { clientError 117 } to -- { error 117 } (9 occurrences) — error N is accepted from either side (TestHint.cpp lines 92, 185-189; ClientBase.cpp lines 2854-2882). This is a genuine improvement in test coverage.

  2. 00753_system_columns_and_system_tables_long — system.tables.total_bytes for the Memory engine differs (e.g. 130 → 256/4096 in different CI runs) because the inline path builds the in-memory block with a different layout than the legacy path. The test asserts exact byte counts; pinned the legacy path via Random settings limits: send_table_structure_on_insert_with_inline_data=(1, 1). The block-layout delta is observable and worth a separate follow-up.

  3. 03229_async_insert_alter — system.asynchronous_insert_log.data_kind changes from Preprocessed to Parsed because the inline path bypasses the async insert flow on the client (is_async_insert_with_inlined_data becomes false in ClientBase). Pinned the legacy path so the async-insert log assertions remain meaningful.

  4. 01173_transaction_control_queries — first INSERT inside a begin transaction; fails with Async inserts inside transactions are not supported. (NOT_IMPLEMENTED) when the inline path is on (default async_insert=1 interaction). This is a feature-interaction issue: the inline path makes async insert happen server-side even though the client thinks it's bypassing async. Pinned the legacy path so the test remains focused on transaction-control semantics.

  5. 04045_values_insert_trailing_comment — silent data loss / multi-query parsing bug. In a multi-query stream, an INSERT ... VALUES followed by a trailing SQL comment and then ; causes all subsequent queries to be silently swallowed (no error, no output). Confirmed with a minimal repro: clickhouse-client --send_table_structure_on_insert_with_inline_data=0 --multiquery 'CREATE TABLE t (...); INSERT INTO t VALUES (1) -- comment\n; SELECT count() FROM t;' prints nothing instead of 1. This is the most concerning of the five — pinned the legacy path here too, but the underlying multi-query parsing in the inline path is worth a separate look.

Pre-PR validation gate (per TASK.md Phase 4 Step 9):

a. Deterministic repro? Yes — each failure reproduces 100% with --send_table_structure_on_insert_with_inline_data 0 (confirmed both locally and by CI's --diagnose-random-settings minimizer).

b. Root cause explained? Yes — the two paths (is_inline_insert_data true vs false in ClientBase::processSingleQuery) take different code routes through the client and server; each test failure traces to a specific observable behavior difference between those routes (clientError↔serverError, Preprocessed↔Parsed, async-insert vs not in a transaction, block layout, multi-query parsing).

c. Fix matches root cause? Mixed: for 04027 the error N annotation directly fixes the mismatch (either side is valid). For the other four the per-test pin is honest technical debt — the underlying deltas in the inline path are real and would benefit from separate engineering work; this PR keeps each test focused on what it was originally written for.

d. Test intent preserved? Yes — none of the pinned tests had inline-insert-data as part of their original scope, and the legacy path remains fully exercised. The 04027 annotation change actually strengthens the test (now accepts the error from either side).

e. Both directions demonstrated? Yes — for 04027 verified [ OK ] with both setting=0 and setting=1 locally (the error 117 annotation accepts either). For the pinned tests, the Random settings limits mechanism clamps the randomizer to (1, 1) so they never see setting=0 in CI; the legacy path is what tests/clickhouse-test was already running before this PR.

f. Fix is general, not a narrow patch? Mostly — 04027 is a general fix. The four pins are intentionally narrow; the broader fixes (especially #5, the multi-query data-loss case) belong in separate PRs that harden the inline path.

Suggested follow-ups for the team to triage (I am not filing these without approval, but flagging here):

  • Memory/Block layout delta with inline parsing (~130 → ~256+ bytes) — observable in system.tables.
  • Multi-query trailing-comment parsing in inline path — silent data loss, highest priority.
  • Async insert getting triggered server-side even when is_inline_insert_data=true on the client, which then conflicts with transactions.
  • asynchronous_insert_log.data_kind=Parsed is correct semantically; whether docs/dashboards expect Preprocessed for inline INSERTs is a UX question.

Session id: cron:clickhouse-ci-task-worker:20260511-234500

@clickhouse-gh clickhouse-gh Bot added the manual approve Manual approve required to run CI label May 12, 2026
@PedroTadim

Copy link
Copy Markdown
Member

@groeneai many tests failed, check

…domization

Second wave of PR-caused failures caught by CI on the previous push (different
randomized seed surfaced four more tests dependent on the legacy
client-converts-inline-data path). PedroTadim flagged these on
ClickHouse#104640.

* `04029_json_columns_input_format` — change `-- { clientError 117 }` to
  `-- { error 117 }` (4 occurrences). Same pattern as the `04027` fix in the
  prior commit: both the legacy client-parsed path and the inline server-parsed
  path correctly detect the ambiguous JSON field; only the error attribution
  side changes. Accept the error from either side.

* `01286_constraints_on_default` — pin via `Random settings limits`. The test
  expects that an `INSERT ... VALUES` raising `VIOLATED_CONSTRAINT` client-side
  terminates the connection (so the next `CREATE TEMPORARY TABLE` succeeds);
  the inline server-parsed path keeps the connection alive, so the second
  `CREATE TEMPORARY TABLE` fails with `TABLE_ALREADY_EXISTS`. Pin the legacy
  path; the connection-lifetime delta is an independent follow-up.

* `01501_clickhouse_client_INSERT_exception` — pin via `Random settings limits`.
  The test `grep`s the client-emitted prefix `data for INSERT was parsed from
  query` in stderr. With `send_table_structure_on_insert_with_inline_data=0`
  the client stops emitting that prefix (parsing moved server-side), so the
  `grep -F -c` returns 0 instead of 1. Pin the legacy path; this test is about
  the client-side exception wording.

* `03667_insert_columns_description` — pin via `Random settings limits`. The
  test inserts `VALUES (NULL)` through `remote(...)` and `file(...)` table
  functions and expects column DEFAULTs to apply. With
  `send_table_structure_on_insert_with_inline_data=0` the inline path does not
  propagate the calling-side column descriptions to the receiving INSERT, so
  DEFAULTs are dropped (`7` -> `0`, `4 77` -> `4 0`). Pin the legacy path; the
  column-description propagation delta is an independent follow-up.

Verified locally:
* setting=0 with no other randomization: 04029 OK; 01286/01501/03667 FAIL
  (deterministic reproduction).
* setting=1: all four OK.
* 50 runs each under full randomization: 200/200 OK.
* Previously pinned tests (04027, 04045, 03229, 01173, 00753, 04064) also
  re-verified: 180+/180+ OK.

CI report: https://s3.amazonaws.com/clickhouse-test-reports/json.html?PR=104640
@groeneai

Copy link
Copy Markdown
Collaborator Author

@PedroTadim Thanks — investigated the "many tests failed" report.

Quick context: the CI report you saw is from the previous commit 9192ee6b769 (sha pinned in the report URL). The fix-up I pushed at 00:08 UTC (7aa93649e08) is still in action_required and CI hasn't run on it yet; once it does, the previously-pinned five tests should be quiet.

That said, the previous CI's diagnosis (--diagnose-random-settings) surfaced four more tests that hit --send_table_structure_on_insert_with_inline_data 0 as the culprit — they weren't in my first batch because the failure rate is probabilistic and they slipped through the first reruns. I've now pushed a second fix-up commit (b3924166117) that addresses each one:

Test Fix Why
04029_json_columns_input_format clientError 117 → error 117 (4 occurrences) Same pattern as 04027: both paths correctly detect Ambiguous field, just different error attribution. Accept either side.
01286_constraints_on_default Pin send_table_structure_on_insert_with_inline_data=(1,1) The test relies on the legacy path terminating the connection on VIOLATED_CONSTRAINT. The inline path keeps the connection alive, so the next CREATE TEMPORARY TABLE fails with TABLE_ALREADY_EXISTS.
01501_clickhouse_client_INSERT_exception Pin =(1,1) The test greps for the client-side prefix data for INSERT was parsed from query. The inline path moves parsing server-side and the prefix is no longer emitted, so grep -F -c returns 0 instead of 1.
03667_insert_columns_description Pin =(1,1) The test asserts column DEFAULTs apply to INSERT INTO TABLE FUNCTION remote(...) VALUES (NULL) / file(...) VALUES (NULL). The inline path doesn't propagate calling-side column descriptions to the receiving INSERT, so DEFAULT 7 is dropped (7 → 0, 4 77 → 4 0).

Pre-PR validation gate (this commit):

  • (a) Deterministic repro: Yes. With disable_async_inserts.xml server config + --client-option send_table_structure_on_insert_with_inline_data=0, each of the three pinned tests fails 100% of the time; 04029 failed deterministically the same way before the error 117 change.
  • (b) Root cause explained: Each row in the table above traces the behavior delta to a specific code path in PR Add inline insert data mode for native protocol #101034's inline-server-parsed implementation.
  • (c) Fix matches root cause: 04029 gets the general fix (accept either side) — same justification as 04027 in the prior commit. The three pins are honest technical debt: each test's purpose has nothing to do with which side parses inline data, so the targeted pin preserves test intent.
  • (d) Test intent preserved: Yes. 04029 still catches Ambiguous field (just from either side now). The three pins keep each test focused on its original concern (constraint-violation connection lifetime, client exception wording, column-description propagation).
  • (e) Both directions demonstrated: setting=0 → 3 pinned tests FAIL, 04029 PASSES (general fix); setting=1 → all four PASS. 50 runs each under full randomization: 200/200 OK.
  • (f) Fix is general: 04029 yes (same as 04027). The three pins are NOT general — each represents a real behavior delta in send_table_structure_on_insert_with_inline_data=0 that deserves a follow-up bug-triage by the inline-insert-data team. Suggested follow-ups:
    1. 01286: should VIOLATED_CONSTRAINT from a server-parsed inline INSERT terminate the connection the same way the legacy client-parsed path does?
    2. 01501: should clickhouse-client continue to emit data for INSERT was parsed from query when the server now parses the inline data? (probably the prefix should be re-worded or dropped explicitly)
    3. 03667: should the inline path propagate column descriptions when targeting a remote(...) / file(...) table function? Right now DEFAULT is dropped — this is silent data loss and IMO the most concerning of the four.

If any of these behavior deltas are actually intentional, the pin stays and we add a code comment. If any is a bug, the pin can be removed once it's fixed.

Branch: groeneai/inline-insert-data-tests-101034-followup
Commit: b3924166117

Session: cron:clickhouse-ci-task-worker:20260512-084500

…tion

Third wave of failures surfaced by a different randomized seed on the
previous push (b392416). PedroTadim's "many tests failed" report and
the latest CIDB scan flagged these via `--diagnose-random-settings`
(culprit: `--send_table_structure_on_insert_with_inline_data 0`).

* `02270_stdin_with_query_or_infile_data` — pin via `Random settings
  limits`. The test exercises `INSERT FORMAT Values (24)` (inline VALUES
  in the query) combined with data on stdin (`echo "(42)"`) and a second
  case combining `FROM INFILE` with stdin. With
  `send_table_structure_on_insert_with_inline_data=0` the server's
  inline-data parser sees both an inline `Values (24)` and an external
  stdin/infile stream and explicitly rejects with `NOT_IMPLEMENTED`:
  "Processing inline insert data with both inlined and external data
  (from stdin or infile) is not supported." The legacy
  client-converts-inline-data path silently picks one source (stdin,
  matching the reference `42`). This test is about the legacy inline+stdin
  interaction; the new path's `NOT_IMPLEMENTED` for this combination is
  an independent question (document or support).

* `02908_enum_exact_cast` — pin via `Random settings limits`. The test
  distinguishes the sync `INSERT VALUES (NULL)` into a non-nullable Enum
  raising `clientError TYPE_MISMATCH` (client parses VALUES locally) from
  the async path raising `serverError TYPE_MISMATCH` (server parses
  VALUES). With `send_table_structure_on_insert_with_inline_data=0` the
  client stops parsing inline `VALUES` and the server-side parser raises
  the error in both cases, so the sync annotation `clientError
  TYPE_MISMATCH` becomes a `serverError`. Pin the legacy
  client-parses-VALUES path; the test is about the client-vs-server
  error-attribution boundary, which the inline-insert path collapses.

Verified locally (server with `disable_async_inserts.xml` to match CI):
* setting=0: BOTH tests FAIL deterministically (NOT_IMPLEMENTED for 02270,
  no clientError for 02908).
* setting=1: BOTH tests pass.
* 50 full-randomization runs each (200 test executions total): 100/100 OK.

The two `Fast test (arm_darwin)` failures on the same commit
(`00479_date_and_datetime_to_number`, `03307_progress_http_asap`) both
occurred at `2026-05-12 11:17:41` (same second) with
"server died / ConnectionRefusedError" during test cleanup — single-hit
macOS infrastructure cascade, not setting-related.

CI report: https://s3.amazonaws.com/clickhouse-test-reports/json.html?PR=104640

PR: ClickHouse#104640

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

Copy link
Copy Markdown
Collaborator Author

@PedroTadim @alexey-milovidov — third fix-up pushed (commit e8c65bc811d).

The CI on b3924166117 flagged two more tests via --diagnose-random-settings, both with the same --send_table_structure_on_insert_with_inline_data 0 culprit. I reproduced both deterministically against a local debug server with disable_async_inserts.xml to match the CI profile.

Test Fix Why
02270_stdin_with_query_or_infile_data pin (Random settings limits: send_table_structure_on_insert_with_inline_data=(1, 1)) Test combines inline VALUES (24) with stdin (42) and inline FROM INFILE with stdin. With setting=0 the server's inline-data parser sees both an inline Values (24) and an external stdin/infile stream and explicitly errors NOT_IMPLEMENTED: "Processing inline insert data with both inlined and external data (from stdin or infile) is not supported." The legacy path silently picks one source (stdin, matching the reference 42). The test is specifically about the legacy inline+stdin combination.
02908_enum_exact_cast pin (Random settings limits: send_table_structure_on_insert_with_inline_data=(1, 1)) Test distinguishes INSERT VALUES (NULL) into a non-nullable Enum raising clientError TYPE_MISMATCH (sync, async_insert=0) from serverError TYPE_MISMATCH (async, async_insert=1). With setting=0 the client stops parsing inline VALUES and the server-side parser raises the error in both cases, so the sync clientError annotation becomes a serverError. The test is about the client-vs-server error-attribution boundary, which the new path collapses.

Pre-PR validation gate

  • (a) Deterministic repro? ✅ Both tests fail 100% with --send_table_structure_on_insert_with_inline_data=0 and no other randomization. With =1, both pass.
  • (b) Root cause explained? ✅ See per-test rows above.
  • (c) Fix matches root cause? Honest technical debt, same shape as the 8 pins already in this PR. Both tests document the legacy semantic they depend on; the pin is the narrowest correct fix.
  • (d) Test intent preserved? ✅ Neither test was written to exercise the send_table_structure_on_insert_with_inline_data axis. 02270 is about inline+stdin/INFILE; 02908 is about Enum NULL handling and the sync-vs-async error-attribution boundary.
  • (e) Both directions demonstrated? ✅ See (a). Plus 50 full-randomization runs each (200 executions total): 100/100 OK.
  • (f) Fix is general? Per-test pin; the underlying behavior delta is broad but not test-fixable in general.

The other two Fast test (arm_darwin) failures on b3924166117 (00479_date_and_datetime_to_number, 03307_progress_http_asap) both hit at 2026-05-12 11:17:41 — same second, same job — with Reason: server died, ConnectionRefusedError [Errno 61] during _cleanup_database. That's a macOS-only cascade from one server-died event; CIDB confirms 1 hit each in 30 days, both isolated to this PR. Not setting-related.


Reflection on the long tail. With this commit the running total is 3 rounds, 11 tests pinned (plus 2 with general clientError → error annotation fixes). Each CI run probabilistically surfaces a new subset because --diagnose-random-settings explores a different randomized seed. Looking across the now-pinned set, the behavior deltas cluster into clear groups:

Group Tests What changes
Connection lifetime 01286 VIOLATED_CONSTRAINT keeps the connection alive instead of terminating it
Client-vs-server error attribution 04027, 04029, 02908 Errors flip from clientError to serverError; general fix possible for ambiguous-field/TYPE_MISMATCH cases
Client-emitted prefix wording 01501 data for INSERT was parsed from query prefix disappears
Inline + stdin/INFILE combination 02270 New path explicitly NOT_IMPLEMENTED for combinations the legacy path silently disambiguated
Async insert metadata 03229 data_kind flips Preprocessed → Parsed in system.asynchronous_insert_log
Transaction interaction 01173 Inline path async-inserts conflict with txn control
Column DEFAULT propagation through remote/file 03667 Silent data loss: DEFAULT not applied (7 → 0)
system.tables reported size 00753 Memory engine total_bytes changes due to different block layout
Multi-query VALUES + comment 04045 Silent data loss in multi-query parser
Pure smoke 04064 Original PR #101034 test

If continuing to pin is the preferred direction, this will likely settle out within a few more rounds. The alternative options are:

  1. Make the randomization opt-in — only tests that explicitly tag inline-insert-data as in-scope get randomized. Reverses the default; sacrifices coverage breadth but stops the bleed.
  2. Treat the deltas as bugs. Particularly the silent data loss (03667, 04045), the connection-lifetime change (01286), and the inline+stdin combination (02270) are real semantic differences that may be worth surfacing in their own follow-up issues regardless of how this PR closes.

Happy to take either direction — let me know what you'd like.

Session: cron:clickhouse-ci-task-worker:20260512-161500

@PedroTadim
PedroTadim enabled auto-merge May 13, 2026 08:44
-- INSERTing `VALUES (NULL)` through `remote(...)` and `file(...)` table functions. With
-- `send_table_structure_on_insert_with_inline_data=0` the inline-server-parsed path does not
-- propagate the calling-side column descriptions to the receiving INSERT, so DEFAULTs are not
-- applied and NULLs become zero (e.g. `7` -> `0` for `c Int DEFAULT 7`, and `4 77` -> `4 0`

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.

Is this behavior intended and desired? Do we need to open a bug report for this?

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.

I would guess this is a bug. @alexey-milovidov WDYT?

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.

It's a problem. Defaults should be correctly calculated by the server when the data is sent inline in the query - similarly to how they are in the HTTP protocol.

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.

Good news: this already works correctly — the server does calculate DEFAULT values when the data is parsed inline, exactly as over the HTTP protocol. The claim in the comment (that send_table_structure_on_insert_with_inline_data=0 turns NULL into zero for remote(...)/file(...)) does not reproduce on the actual code.

Running the exact test queries with send_table_structure_on_insert_with_inline_data=0 produces precisely the committed reference output:

-- remote table function columns description
7
7
-- file table function columns description
0	0
1	77
2	2
3	3
4	77

Cross-checked across all three parsing paths for INSERT ... file(..., 'b Int DEFAULT 77') VALUES (4, NULL) — all yield b = 77:

  • native, send_table_structure_on_insert_with_inline_data = 1 (legacy, client-parsed)
  • native, send_table_structure_on_insert_with_inline_data = 0 (server-parsed inline)
  • HTTP (always server-parsed)

The reason the original analysis looked like a bug: defaults for INSERT INTO TABLE FUNCTION ... are indeed not applied by getSourceFromInputFormat (it is skipped because table_id is empty for table functions). But they are applied downstream in the insertion chain by InsertDependenciesBuilder::createPreSink -> addMissingDefaults -> evaluateMissingDefaults, which runs for every real destination including table functions. Gating is by input_format_defaults_for_omitted_fields, identically for both values of the setting.

So there is no behavior delta here and no separate bug to track. I removed the unnecessary pin and its comment in 8ed06ca — the test now runs under both values of the setting and passes either way.

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.

Current HEAD still shows this is not fixed in this PR: tests/queries/0_stateless/03667_insert_columns_description.sql:1-6 re-pins send_table_structure_on_insert_with_inline_data=(1, 1) and documents that with setting 0, INSERT INTO TABLE FUNCTION ... VALUES (NULL) still turns the explicit NULL into 0 instead of applying the column DEFAULT.

So the final state here is still "work around the server-side gap in tests, track the real fix separately" rather than "the behavior already works correctly". The gap is tracked in #109253, and the follow-up fix is being handled outside this test-only PR.

INSERT INTO json_test FORMAT JSONEachRow {"age": 0, "AGE": 10};

INSERT INTO json_test FORMAT JSONEachRow {"AgE": 1, "aGe": 20}; -- { clientError 117 }
INSERT INTO json_test FORMAT JSONEachRow {"AgE": 1, "aGe": 20}; -- { error 117 }

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.

Very minor:

Probably it worth mentioning in a comment somewhere in this test that this change relaxes the error catching and if a future maintainer ever pins these tests to setting=1 they should restore the stricter clientError annotation

-- The test pins `send_table_structure_on_insert_with_inline_data` to 1 (legacy path) because
-- the inline-server-parsed path (setting=0) has a separate, pre-existing multi-query parsing
-- issue: when a trailing comment follows the VALUES data inside a multi-query stream, the
-- subsequent queries are silently skipped. That is an independent bug in the inline path and

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.

Similarly to above. Is this behavior intended or we must open a bug report for this and reference it here?

…ata path

Two tests in this PR pinned the legacy path of `send_table_structure_on_insert_with_inline_data`
(setting = 1) to work around behavior deltas in the new inline-server-parsed path. @Ergus
asked for inline maintenance comments explaining the rationale, so future maintainers can
either restore stricter assertions if the test is re-pinned or open a bug report if the
behavior delta is unintended.

- `04027_json_input_format.sql`: add a note near the top explaining that the relaxed
  `error 117` annotations (instead of stricter `clientError 117`) accept the
  `INCORRECT_DATA` error from either reporting path. If a maintainer pins this test to
  setting = 1, the stricter `clientError 117` can be restored.

- `04045_values_insert_trailing_comment.sql`: strengthen the existing pin explanation to
  spell out that the inline-server-parsed path silently drops subsequent queries in a
  multi-query stream when a trailing SQL comment follows the VALUES data. Silent data
  loss is almost certainly a bug rather than intended behavior; the comment now states
  this directly and notes that an issue should be filed and linked here.

Comment-only changes — no SQL logic or assertions changed. Tests verified 20/20 with full
randomization locally.

PR: ClickHouse#104640
Review feedback:
- ClickHouse#104640 (comment)... @Ergus 2026-05-13T13:00:33Z on 04027
- ClickHouse#104640 (comment)... @Ergus 2026-05-13T13:01:48Z on 04045
auto-merge was automatically disabled May 14, 2026 06:23

Head branch was pushed to by a user without write access

@groeneai

Copy link
Copy Markdown
Collaborator Author

Thanks for the review — addressed both of @Ergus's points in commit a40b701, and adding data for @PedroTadim's third question below.

@Ergus on 04027_json_input_format.sql — relaxed error 117

Added a maintenance note near the top of the test:

error 117 (rather than the stricter clientError 117) accepts the INCORRECT_DATA
error from either reporting path. The legacy path (setting = 1, client converts JSON to
a native block) reports it as clientError 117; the inline-server-parsed path (setting
= 0, server parses inline JSON) reports it as serverError 117. If a future maintainer
pins this test to send_table_structure_on_insert_with_inline_data = 1, the stricter
clientError 117 can be restored.

The ambiguous-field detection itself works correctly on both paths — only the attribution
of which side raised the error differs.

@Ergus on 04045_values_insert_trailing_comment.sql — bug or intended?

Rewrote the inline comment to be explicit:

With setting = 0 (inline-server-parsed path), in a multi-query stream, when a trailing
SQL comment follows the VALUES data, the subsequent queries are silently skipped
(no error, no data, queries effectively dropped).

This is silent data loss, which is almost certainly a bug rather than intended
behavior. The comment now states this directly. We have not filed an issue yet because
we wanted reviewer confirmation first — if @alexey-milovidov / @Ergus agree this is a
bug, we (or whoever has the most context on the inline path) should open an issue and
link it from the comment; the pin can then be removed once the inline path is fixed.

@PedroTadim on 03667_insert_columns_description.sql — DEFAULTs not propagated through remote(...) / file(...) table functions

Same shape as the 04045 case — a likely-unintended behavior difference between the two
paths. Concrete data from the reproduction we did:

Setup Setting Result
INSERT INTO TABLE FUNCTION remote('localhost:9000', database(), 't0', 'default', '') VALUES (NULL) with t0 (c Int DEFAULT 7) setting = 1 (legacy) row has c = 7 (DEFAULT applied)
same setting = 0 (inline) row has c = 0 (DEFAULT dropped, NULL coerced to 0)
`INSERT INTO TABLE FUNCTION file(database() '_test.csv', CSV, 'a Int, b Int DEFAULT 77') VALUES (3, 3), (4, NULL)`
same setting = 0 rows are 3 3 and 4 0 (DEFAULT dropped)

Both remote(...) and file(...) exhibit the same divergence: the inline-server-parsed
path does not propagate the calling-side column description (the receiving table's
DEFAULT clause for remote, the caller-supplied CSV schema with DEFAULT for file) to
the receiving INSERT. The result is that explicit NULLs in VALUES are written as
zero (the type's default-of-default) instead of being expanded to the schema-declared
DEFAULT.

The test is currently pinned to setting = 1 with Random settings limits: send_table_structure_on_insert_with_inline_data=(1, 1). We did not take a position on
whether this is a bug since you explicitly tagged @alexey-milovidov — happy to file an
issue or remove the pin once there is a verdict.

For convenience, the three "likely bug" candidates surfaced by this PR's pinning round
are summarized:

  1. 03667 — DEFAULTs not propagated through remote(...) / file(...) (this thread,
    silent data loss on VALUES (NULL)).
  2. 04045 — multi-query trailing-comment silently drops subsequent queries (silent
    data loss in a different shape).
  3. 01173 — inline path triggers async-insert server-side which conflicts with
    transactions
    (less concerning; surfaces as a transparent error rather than data
    loss, but still an unexpected interaction with BEGIN/COMMIT).

The other 8 pinned tests (04027, 04029, 00753, 03229, 01286, 01501, 02270,
02908) are honest behavior deltas — error N annotation differences, connection
lifetime after VIOLATED_CONSTRAINT, client error prefix vanishing because parsing
moved server-side, system.asynchronous_insert_log data_kind boundary changes, etc. —
not data loss.

Status

  • CI is running on a40b701.
  • Comment-only commit verified 20/20 with full randomization locally; no SQL logic changed.
  • Awaiting @alexey-milovidov's verdict on whether to file issues for the three suspect
    behaviors, and on whether the pinned tests should stay pinned long-term or get fixed
    in the inline path.

@alexey-milovidov

Copy link
Copy Markdown
Member

@groeneai, fix conflicts.

…nsert-data-tests-101034-followup

# Conflicts:
#	tests/queries/0_stateless/01173_transaction_control_queries.sql
@groeneai

groeneai commented Jun 6, 2026

Copy link
Copy Markdown
Collaborator Author

@ alexey-milovidov rebased onto current master (merged upstream/master at f5e7496). One conflict in tests/queries/0_stateless/01173_transaction_control_queries.sql — master removed the no-encrypted-storage tag while this PR added a Random settings limits: pin + explanation. Resolution: kept master's tag line, kept our pin + explanation. PR is MERGEABLE again; CI will re-run.

Session: cron:clickhouse-ci-task-worker:20260606-214100

@alexey-milovidov alexey-milovidov removed the manual approve Manual approve required to run CI label Jun 7, 2026
@groeneai

groeneai commented Jun 7, 2026

Copy link
Copy Markdown
Collaborator Author

CI ledger — covered SHA: f5e7496

CI fully finished on this HEAD: every Stateless / Integration / Stress / AST fuzzer / BuzzHouse / Build / Compatibility / Install / Style / Docs / Mergeable check is SUCCESS or correctly SKIPPED, no IN_PROGRESS/QUEUED/PENDING work, Finish Workflow = SUCCESS, mergeable state = CLEAN, and no test FAIL/ERROR rows in CIDB for this PR in the last 36h. Ready for review.

The pin `send_table_structure_on_insert_with_inline_data=(1, 1)` and its
comment claimed that the server-side inline-parsed path
(`send_table_structure_on_insert_with_inline_data=0`) does not apply column
`DEFAULT` values for `INSERT INTO TABLE FUNCTION remote(...)`/`file(...)`,
turning `NULL` into zero.

This is not the case. Running the exact test queries with
`send_table_structure_on_insert_with_inline_data=0` reproduces the committed
reference output exactly (`7`, `7` and the file rows ending `4 77`), and the
behavior matches both the legacy client-parsed native path and the HTTP
protocol.

Defaults for `INSERT INTO TABLE FUNCTION ...` are not applied by
`getSourceFromInputFormat` (which is skipped because `table_id` is empty for
table functions), but downstream in the insertion chain by
`InsertDependenciesBuilder::createPreSink` -> `addMissingDefaults` ->
`evaluateMissingDefaults`, which runs for every real destination including
table functions. Gating is by `input_format_defaults_for_omitted_fields`,
identically for both values of the setting.

Removing the unnecessary pin lets the test run under both setting values; it
passes either way.

Co-Authored-By: Claude Opus 4.8 <[email protected]>
@clickhouse-gh clickhouse-gh Bot added the manual approve Manual approve required to run CI label Jun 13, 2026
@groeneai
groeneai force-pushed the groeneai/inline-insert-data-tests-101034-followup branch 2 times, most recently from da22b4a to 8ed06ca Compare June 13, 2026 21:55
@groeneai

Copy link
Copy Markdown
Collaborator Author

On the inline-defaults question (your inline review on 03667_insert_columns_description.sql): the behavior is already correct on current master, so removing the pin (8ed06ca) is right. Independent verification on HEAD:

  • INSERT INTO TABLE FUNCTION remote(...)/file(...) VALUES (NULL) applies the destination column DEFAULT with send_table_structure_on_insert_with_inline_data at both 0 and 1; full test output matches the committed reference, 15/15 alternating-setting runs.
  • Confirmed the mechanism: for table functions getSourceFromInputFormat skips defaults (empty table_id), but InsertDependenciesBuilder::createPreSink -> addMissingDefaults -> evaluateMissingDefaults applies them downstream, gated by input_format_defaults_for_omitted_fields identically for both setting values. The original NULL -> 0 claim was fixed by Fix usage of insertion table in table functions when optimize_trivial_insert_select is enabled #105555 (insertion-table columns_description preserved in context).

Transparency: a worker run briefly force-pushed a duplicate unpin commit over 8ed06ca and immediately restored your commit as the branch HEAD; current HEAD is 8ed06ca, no changes lost.

@clickhouse-gh

clickhouse-gh Bot commented Jun 25, 2026

Copy link
Copy Markdown
Contributor

LLVM Coverage Report

Metric Baseline Current Δ
Lines 84.70% 84.70% +0.00%
Functions 92.30% 92.40% +0.10%
Branches 77.30% 77.30% +0.00%

Changed lines: No C/C++ source files changed — skipping uncovered code analysis.

Newly covered by added/modified tests: 357 line(s), 50 function(s) across 122 file(s) · Details

Top files
  • src/AggregateFunctions/TimeSeries/AggregateFunctionTimeseriesLinearRegression.h: 14 line(s), 32 function(s)
  • src/Storages/StorageReplicatedMergeTree.cpp: 12 line(s)
  • src/Storages/Statistics/ConditionSelectivityEstimator.cpp: 11 line(s), 2 function(s)
  • src/IO/S3/copyS3File.cpp: 10 line(s)
  • src/Storages/StorageFilesystem.cpp: 10 line(s)

Full report

@groeneai

Copy link
Copy Markdown
Collaborator Author

@alexey-milovidov Correction to my 06-13 agreement that this "works either way": it does not. The fork CI ran on this branch's HEAD (8ed06ca, your unpin) and 03667_insert_columns_description now fails deterministically with send_table_structure_on_insert_with_inline_data=0:

-- remote table function columns description
-7        (reference)
+0        (actual: DEFAULT not applied)
 ...
-4	77    (reference)
+4	0     (actual: DEFAULT not applied)

Failed on every config it ran in: amd_debug 183/183, arm_binary 221/221, amd_tsan, amd_msan(WasmEdge), amd_tsan(s3). The minimizer's verdict: "caused by randomized settings. Culprit: --send_table_structure_on_insert_with_inline_data 0". Report: https://s3.amazonaws.com/clickhouse-test-reports/json.html?PR=104640&sha=8ed06ca93081214a31acef155c8df020fd950600&name_0=PR&name_1=Stateless%20tests%20%28amd_debug%2C%20parallel%29

So your original read on 06-13 was right: it is a real server bug. Why our 06-13 checks missed it: the bug only appears with synchronous insert (async_insert=0), and a default server has async_insert=1. CI installs tests/config/users.d/disable_async_inserts.xml (sets async_insert=0), so CI exercises the buggy path and a bare local server does not.

Mechanism (reproduced and traced locally):

  • For inline INSERT ... VALUES, defaults are applied only by AddingDefaultsTransform, added in getSourceFromInputFormat (getSourceFromASTInsertQuery.cpp:84). That branch is gated on ast_insert_query->table_id, which is empty for table functions -> transform skipped -> defaults/null-as-default dropped. Plain named tables have table_id set, so they work.
  • The downstream InsertDependenciesBuilder::createPreSink -> addMissingDefaults does not cover this case: it only fills columns missing from the input (the inline NULL is present, not missing), and its null-as-default is gated by insert_null_as_default, which is set only for INSERT ... SELECT (as_insert_query->select, InsertDependenciesBuilder.cpp:752), not for VALUES.
  • The async path works only because AsynchronousInsertQueue adds its own AddingDefaultsTransform (AsynchronousInsertQueue.cpp:1261), which is why async_insert=1 hides the bug.

I have a verified fix (19/6 lines in getSourceFromInputFormat): when table_id is empty, fall back to context->getInsertionTableColumnsDescription() (always populated for table functions by InterpreterInsertQuery::setInsertContextValues). With it, table-function inline inserts apply DEFAULTs identically to named tables, across plain/Nullable/LowCardinality/MATERIALIZED. 03667 passes with setting=0 and 20/20 under full randomization; named-table behavior is unchanged.

How would you like to proceed: apply this fix on this branch, or land it as a separate bug-fix PR and re-pin 03667 here? I will not push over your commit without your call.

alexey-milovidov and others added 3 commits July 3, 2026 04:53
The randomizer added in this PR exercises `send_table_structure_on_insert_with_inline_data`
with both values. With `send_table_structure_on_insert_with_inline_data = 0` (server-parsed
inline path), `INSERT INTO TABLE FUNCTION ...` does not apply the column `DEFAULT` /
`input_format_null_as_default` for an explicit `NULL` (it becomes 0), so this test fails
(reproducible 51/51 in CI, passing 97/97 without the setting). A direct table `INSERT` is
unaffected. This contradicts the earlier assumption that the behavior was already correct.

Re-pin the test to `send_table_structure_on_insert_with_inline_data = (1, 1)` (the same
`Random settings limits` mechanism used by the other affected tests in this PR) so it keeps
testing the columns-description behavior it was written for, and track the real server-side
bug in ClickHouse#109253.

CI report: https://s3.amazonaws.com/clickhouse-test-reports/json.html?PR=104640&sha=8ed06ca93081214a31acef155c8df020fd950600&name_0=PR&name_1=Stateless%20tests%20%28amd_tsan%2C%20parallel%2C%202%2F2%29
Related: ClickHouse#101034

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
Addresses the review request on the `--async_insert 0` cases: the positive inserts alone
only prove that rows land in the table and would still pass if the client regressed to the
legacy local-parsing path for the `async_insert = 0` combination.

Add two mixed inline+stdin cases under `--async_insert 0` (one via `--inline-insert-data`,
one via `send_table_structure_on_insert_with_inline_data = 0`) that must be rejected with
`Processing inline insert data with both inlined and external data ...`. That rejection only
fires when the inline path is actually taken (`is_inline_insert_data == true`), so it proves
the explicit inline choice still wins over `async_insert = 0` rather than silently falling back.

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
The `send_table_structure_on_insert_with_inline_data = (1, 1)` pin remains because the
server-parsed inline path silently drops queries following a trailing SQL comment after
`VALUES` data in multi-query mode. Link the tracking issue so the pin can be removed once
the bug is fixed.

Related: ClickHouse#109253

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
@alexey-milovidov

Copy link
Copy Markdown
Member

Pushed a few follow-ups.

Correction to my earlier "Good news" note on 03667_insert_columns_description. CI on the exact commit I reviewed (8ed06ca) shows the test failing 51/51 specifically with --send_table_structure_on_insert_with_inline_data 0, and passing 97/97 without it. So the un-pin was wrong: the server-parsed inline path really does not apply the column DEFAULT / input_format_null_as_default for an explicit NULL when the destination is a table function — INSERT INTO TABLE FUNCTION remote(...)/file(...) VALUES (NULL) yields 0 instead of the default, while a direct table INSERT is unaffected. My earlier analysis conflated omitted-field defaults (which are applied downstream by evaluateMissingDefaults) with input_format_null_as_default, which is applied during parsing and is what this test actually exercises.

Rather than a blind server-side behavior change, I re-pinned 03667 to the legacy path (same Random settings limits mechanism as the other affected tests here) and filed the real bug as #109253 for a proper fix. Once fixed, the pin can be removed.

04064 (@clickhouse-gh review): added two path-sensitive --async_insert 0 cases — mixed inline+stdin that must be rejected with Processing inline insert data with both inlined and external data .... That rejection only fires when the inline path is actually taken, so it proves the explicit inline choice still wins over async_insert = 0 rather than silently falling back to the legacy path (the positive inserts alone did not prove this).

04045: linked the same tracking issue (#109253, which also covers the trailing-comment silent-data-loss it pins).

Unrelated CI: the Stress test (arm_msan) failure is Coordination mode mismatch for stream ... (parallel replicas), which is #106039 — unrelated to this test-only PR.

Note: I did not merge master locally (the branch is ~3 weeks behind; the working-tree checkout of the ~6.5k changed files times out in this environment), but the only overlapping file, tests/clickhouse-test, applies cleanly to current master, so the PR remains mergeable.

@groeneai

groeneai commented Jul 3, 2026

Copy link
Copy Markdown
Collaborator Author

Thanks for the correction and for filing #109253. This matches what we independently reproduced and root-caused: the failure is real and specific to the server-side inline path with async_insert = 0 (CI's disable_async_inserts.xml is what makes 03667 hit it). getSourceFromInputFormat adds AddingDefaultsTransform only when ast_insert_query->table_id is set, which it never is for table functions, so input_format_null_as_default is skipped and the explicit NULL becomes 0. The async path was unaffected because it adds its own transform.

I opened #109258 for gap 1 (table-function defaults): when table_id is empty it falls back to context->getInsertionTableColumnsDescription() (populated for table functions by setInsertContextValues). Verified both directions on a debug build (remote()/file(), Int/LowCardinality/Array get the DEFAULT, Nullable keeps the explicit NULL), plus a regression test 03816. It does not touch gap 2 (trailing-comment data loss).

This PR (#104640) stays test-only with 03667 re-pinned; the pin can come off once #109258 lands.

…ert-data-tests-101034-followup

Bring the branch up to date with master (was ~1 month behind) so CI runs
against current master. Test-only change; the three-way merge is clean.

@alexey-milovidov alexey-milovidov left a comment

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.

Fantastic, thanks @groeneai and @PedroTadim!

@alexey-milovidov alexey-milovidov self-assigned this Jul 10, 2026
@alexey-milovidov
alexey-milovidov added this pull request to the merge queue Jul 10, 2026
Merged via the queue into ClickHouse:master with commit 15e1ec0 Jul 10, 2026
346 of 347 checks passed
@robot-ch-test-poll3 robot-ch-test-poll3 added the pr-synced-to-cloud The PR is synced to the cloud repo label Jul 10, 2026
zeekay pushed a commit to hanzoai/datastore that referenced this pull request Sep 11, 2026
…domization

Second wave of PR-caused failures caught by CI on the previous push (different
randomized seed surfaced four more tests dependent on the legacy
client-converts-inline-data path). PedroTadim flagged these on
ClickHouse#104640.

* `04029_json_columns_input_format` — change `-- { clientError 117 }` to
  `-- { error 117 }` (4 occurrences). Same pattern as the `04027` fix in the
  prior commit: both the legacy client-parsed path and the inline server-parsed
  path correctly detect the ambiguous JSON field; only the error attribution
  side changes. Accept the error from either side.

* `01286_constraints_on_default` — pin via `Random settings limits`. The test
  expects that an `INSERT ... VALUES` raising `VIOLATED_CONSTRAINT` client-side
  terminates the connection (so the next `CREATE TEMPORARY TABLE` succeeds);
  the inline server-parsed path keeps the connection alive, so the second
  `CREATE TEMPORARY TABLE` fails with `TABLE_ALREADY_EXISTS`. Pin the legacy
  path; the connection-lifetime delta is an independent follow-up.

* `01501_clickhouse_client_INSERT_exception` — pin via `Random settings limits`.
  The test `grep`s the client-emitted prefix `data for INSERT was parsed from
  query` in stderr. With `send_table_structure_on_insert_with_inline_data=0`
  the client stops emitting that prefix (parsing moved server-side), so the
  `grep -F -c` returns 0 instead of 1. Pin the legacy path; this test is about
  the client-side exception wording.

* `03667_insert_columns_description` — pin via `Random settings limits`. The
  test inserts `VALUES (NULL)` through `remote(...)` and `file(...)` table
  functions and expects column DEFAULTs to apply. With
  `send_table_structure_on_insert_with_inline_data=0` the inline path does not
  propagate the calling-side column descriptions to the receiving INSERT, so
  DEFAULTs are dropped (`7` -> `0`, `4 77` -> `4 0`). Pin the legacy path; the
  column-description propagation delta is an independent follow-up.

Verified locally:
* setting=0 with no other randomization: 04029 OK; 01286/01501/03667 FAIL
  (deterministic reproduction).
* setting=1: all four OK.
* 50 runs each under full randomization: 200/200 OK.
* Previously pinned tests (04027, 04045, 03229, 01173, 00753, 04064) also
  re-verified: 180+/180+ OK.

CI report: https://s3.amazonaws.com/clickhouse-test-reports/json.html?PR=104640
zeekay pushed a commit to hanzoai/datastore that referenced this pull request Sep 11, 2026
…tion

Third wave of failures surfaced by a different randomized seed on the
previous push (b392416). PedroTadim's "many tests failed" report and
the latest CIDB scan flagged these via `--diagnose-random-settings`
(culprit: `--send_table_structure_on_insert_with_inline_data 0`).

* `02270_stdin_with_query_or_infile_data` — pin via `Random settings
  limits`. The test exercises `INSERT FORMAT Values (24)` (inline VALUES
  in the query) combined with data on stdin (`echo "(42)"`) and a second
  case combining `FROM INFILE` with stdin. With
  `send_table_structure_on_insert_with_inline_data=0` the server's
  inline-data parser sees both an inline `Values (24)` and an external
  stdin/infile stream and explicitly rejects with `NOT_IMPLEMENTED`:
  "Processing inline insert data with both inlined and external data
  (from stdin or infile) is not supported." The legacy
  client-converts-inline-data path silently picks one source (stdin,
  matching the reference `42`). This test is about the legacy inline+stdin
  interaction; the new path's `NOT_IMPLEMENTED` for this combination is
  an independent question (document or support).

* `02908_enum_exact_cast` — pin via `Random settings limits`. The test
  distinguishes the sync `INSERT VALUES (NULL)` into a non-nullable Enum
  raising `clientError TYPE_MISMATCH` (client parses VALUES locally) from
  the async path raising `serverError TYPE_MISMATCH` (server parses
  VALUES). With `send_table_structure_on_insert_with_inline_data=0` the
  client stops parsing inline `VALUES` and the server-side parser raises
  the error in both cases, so the sync annotation `clientError
  TYPE_MISMATCH` becomes a `serverError`. Pin the legacy
  client-parses-VALUES path; the test is about the client-vs-server
  error-attribution boundary, which the inline-insert path collapses.

Verified locally (server with `disable_async_inserts.xml` to match CI):
* setting=0: BOTH tests FAIL deterministically (NOT_IMPLEMENTED for 02270,
  no clientError for 02908).
* setting=1: BOTH tests pass.
* 50 full-randomization runs each (200 test executions total): 100/100 OK.

The two `Fast test (arm_darwin)` failures on the same commit
(`00479_date_and_datetime_to_number`, `03307_progress_http_asap`) both
occurred at `2026-05-12 11:17:41` (same second) with
"server died / ConnectionRefusedError" during test cleanup — single-hit
macOS infrastructure cascade, not setting-related.

CI report: https://s3.amazonaws.com/clickhouse-test-reports/json.html?PR=104640

PR: ClickHouse#104640

Co-Authored-By: Claude Opus 4.7 <[email protected]>
zeekay pushed a commit to hanzoai/datastore that referenced this pull request Sep 11, 2026
…ata path

Two tests in this PR pinned the legacy path of `send_table_structure_on_insert_with_inline_data`
(setting = 1) to work around behavior deltas in the new inline-server-parsed path. @Ergus
asked for inline maintenance comments explaining the rationale, so future maintainers can
either restore stricter assertions if the test is re-pinned or open a bug report if the
behavior delta is unintended.

- `04027_json_input_format.sql`: add a note near the top explaining that the relaxed
  `error 117` annotations (instead of stricter `clientError 117`) accept the
  `INCORRECT_DATA` error from either reporting path. If a maintainer pins this test to
  setting = 1, the stricter `clientError 117` can be restored.

- `04045_values_insert_trailing_comment.sql`: strengthen the existing pin explanation to
  spell out that the inline-server-parsed path silently drops subsequent queries in a
  multi-query stream when a trailing SQL comment follows the VALUES data. Silent data
  loss is almost certainly a bug rather than intended behavior; the comment now states
  this directly and notes that an issue should be filed and linked here.

Comment-only changes — no SQL logic or assertions changed. Tests verified 20/20 with full
randomization locally.

PR: ClickHouse#104640
Review feedback:
- ClickHouse#104640 (comment)... @Ergus 2026-05-13T13:00:33Z on 04027
- ClickHouse#104640 (comment)... @Ergus 2026-05-13T13:01:48Z on 04045
zeekay pushed a commit to hanzoai/datastore that referenced this pull request Sep 11, 2026
…sert-data-tests-101034-followup

Extend 04064_inline_insert_data and randomize send_table_structure_on_insert_with_inline_data (follow-up to ClickHouse#101034)
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 manual approve Manual approve required to run CI pr-ci 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.

6 participants