Repository navigation
Add table schema to SQLInsert output - #114106
mishok2503 wants to merge 17 commits into
Conversation
|
Workflow [PR], commit [bc3709b] Summary: ❌
|
Build profile diff (arm_release)Comparing ✅ No significant changes. Binary sizes
The official master build is compiled with Object file sizes660 object files changed (+66.75 KiB total), 0 added.
716 more object files are built by the master warmup baseline only (it builds every object-file target, a pull request build only Compile time of recompiled translation units3170 translation units recompiled, 16073 s compile time in total, 3170 of them have a recent master baseline. |
Reject result types that cannot be stored in tables and duplicate column names before emitting a generated schema. Use client error hints in the regression tests and include the declaration of `backQuoteIfNeed` directly. PR: ClickHouse#114106 Review: ClickHouse#114106 (comment) CI: https://s3.amazonaws.com/clickhouse-test-reports/json.html?PR=114106&sha=c517fe15a8631eb21e13d990f19dec71f1ac9541&name_0=PR&name_1=Fast%20test CI: https://s3.amazonaws.com/clickhouse-test-reports/json.html?PR=114106&sha=94d8c4db5af2fc846a20f18df23bd569ddf3a3de&name_0=PR&name_1=Fast%20test CI: https://s3.amazonaws.com/clickhouse-test-reports/json.html?PR=114106&sha=94d8c4db5af2fc846a20f18df23bd569ddf3a3de&name_0=PR&name_1=Build%20%28arm_tidy%29
1f674d3 to
faa4a8f
Compare
Reject result types that cannot be stored in tables and duplicate column names before emitting a generated schema. Use client error hints in the regression tests and include the declaration of `backQuoteIfNeed` directly. PR: ClickHouse#114106 Review: ClickHouse#114106 (comment) CI: https://s3.amazonaws.com/clickhouse-test-reports/json.html?PR=114106&sha=c517fe15a8631eb21e13d990f19dec71f1ac9541&name_0=PR&name_1=Fast%20test CI: https://s3.amazonaws.com/clickhouse-test-reports/json.html?PR=114106&sha=94d8c4db5af2fc846a20f18df23bd569ddf3a3de&name_0=PR&name_1=Fast%20test CI: https://s3.amazonaws.com/clickhouse-test-reports/json.html?PR=114106&sha=94d8c4db5af2fc846a20f18df23bd569ddf3a3de&name_0=PR&name_1=Build%20%28arm_tidy%29
faa4a8f to
dd6853b
Compare
Apply `validateDataType` with current query settings before emitting a generated `CREATE TABLE` statement. This keeps schemas generated by `SQLInsert` replayable for setting-gated suspicious and experimental types. Add a regression for `LowCardinality(UInt8)`. PR: ClickHouse#114106 Review: ClickHouse#114106 (comment)
Reject schema output for types that require non-default settings, so generated scripts remain replayable in a default session. Related: ClickHouse#114106
…able-schema-84736 # Conflicts: # src/Processors/Formats/Impl/SQLInsertRowOutputFormat.cpp
Treat schema type names as non-textual output when they contain invalid UTF-8, so HTTP framing preserves generated scripts byte-for-byte. Related: ClickHouse#114106
…hema-comments-114106 # Please enter a commit message to explain why this merge is necessary, # especially if it merges an updated upstream into a topic branch. # # Lines starting with '#' will be ignored, and an empty message aborts # the commit.
Record `output_format_sql_insert_include_table_schema` under the current compatibility block after merging `master`, so `settings_changes_history` accepts the PR diff.
Keep generated `CREATE TABLE` and `INSERT` statements replayable when `output_format_sql_insert_quote_names` is disabled and headers contain unsafe identifiers.
The flaky-check runs changed tests five times concurrently. Keeping the new `SQLInsert` cases in the large `04512_framing_formats` test made all copies time out before reaching the added checks. CI: https://s3.amazonaws.com/clickhouse-test-reports/json.html?PR=114106&sha=3e3efc2d5bc26b28a314c933e1597a6c98c8244b&name_0=PR&name_1=Stateless%20tests%20%28amd_asan_ubsan%2C%20flaky%20check%29 PR: ClickHouse#114106
The generated `CREATE TABLE` uses `MergeTree`, whose persistent virtual column names cannot be used as physical columns. Reject all three reserved header names before emitting an unreplayable script. Review: ClickHouse#114106 (comment)
Validate `output_format_sql_insert_table_name` with `ParserCompoundIdentifier` before emitting a schema. This rejects values such as `a b` instead of producing an unreplayable script while leaving ordinary `SQLInsert` output unchanged. Review: ClickHouse#114106 (comment)
| @@ -124,13 +247,22 @@ void registerOutputFormatSQLInsert(FormatFactory & factory) | |||
| if (is_not_valid_utf8(settings.sql_insert.table_name)) | |||
There was a problem hiding this comment.
output_format_sql_insert_include_table_schema emits the canonical identifier from parseAndFormatSQLInsertTableName(), but this raw-bytes checker still looks at settings.sql_insert.table_name. Over HTTP a value such as output_format_sql_insert_table_name=t%20--%20%FF is formatted back as plain t in both statements, so the actual payload is valid UTF-8; nevertheless outputFormatProducesText() sees the ignored comment byte, marks the format as binary, and JSONEachPacketString rejects the query while EventStream base64-encodes it unnecessarily.
Please canonicalize the table name here as well when schema mode is enabled (using settings.max_parser_depth) and validate the formatted identifier bytes instead of the raw setting string. A focused framing regression for a trailing-comment table name would catch this.
|
Dear @nikitamikhaylov, 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. |
…able-schema-84736 Resolve the conflict with the move of the settings changes history into the setting declarations (ee6b44f): the history records this PR added to `SettingsChangesHistory.cpp` now live as trailing arguments of the `DECLARE` of each setting. - retargeted PR record [email protected] to 26.10 (settings-history check rule) Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Adds the
output_format_sql_insert_include_table_schemasetting for theSQLInsertoutput format. When enabled,SQLInsertprepends aCREATE TABLEstatement derived from the query result schema, making the generated SQL directly replayable into an empty database.The table definition uses the result column names and types with
MergeTreeandORDER BY tuple(). Source-table metadata such as keys, default expressions, codecs, TTLs, and indexes is not preserved. The setting is disabled by default and cannot be enabled together withoutput_format_sql_insert_use_replace.The change includes embedded documentation and stateless coverage for replaying the generated SQL, complex types, identifiers, empty results, batching, and incompatible settings.
Closes: #84736
Changelog category:
Changelog entry:
The
SQLInsertoutput format can now prepend aCREATE TABLEstatement with result column names and types. Enableoutput_format_sql_insert_include_table_schemato produce a ClickHouse SQL script that recreates the table and loads the exported data.Workflow [PR]
Sync PR [sync-upstream/pr/114106]