Repository navigation
Add setting to omit CSV quotes for date and time types - #107292
cristhiank wants to merge 33 commits into
Conversation
Add a backward-compatible CSV output setting that lets users emit date and time values without surrounding double quotes while preserving the existing quoted behavior by default. Co-authored-by: Copilot <[email protected]>
2bd5ffa to
e4dc85e
Compare
|
Workflow [PR], commit [de8e1bf] AI ReviewSummaryAdds Findings❌ Blockers
Tests
Missing context / blind spots
Final Verdict❌ Block — Fix both framing errors and add the focused round-trip regressions above. |
|
Gentle reminder on this one. This is my first time contributing, so please let me know if there’s anything else I need to do on my end. @nikitamikhaylov Thanks! |
|
📊 Cloud Performance Report ✅ AI verdict: This PR adds the output_format_csv_quote_date_time_types setting and reworks CSV serialization of Date/DateTime/Time types — it does not touch the query-execution path that ClickBench SELECTs run. Both flagged ClickBench queries (Q4 -17.6%, Q15 -19.8%) show apparent speedups, but the deterministic gates correctly kept them as no_change: both medians sit inside master's current variance band and the small source sample (6 runs) makes a consistent ~18-20% dip look like noise rather than signal. No real PR-attributable change here; nothing to action. clickbench🟢 No significant changes tpch_adapted_1_official🟢 No significant changes Debug info
|
|
@cristhiank could you please update your branch with master? The current branch is 26.7 so we should add the new setting to a 26.7 block in SettingsChangesHistory.cpp |
…v-quote-date-time-types
Co-authored-by: Copilot <[email protected]> Copilot-Session: 91cf4795-752a-44db-97d3-4a513bf1a63c
|
Thanks @yariks5s , I've pushed the changes to match the latest branch. |
Co-authored-by: Copilot <[email protected]> Copilot-Session: 91cf4795-752a-44db-97d3-4a513bf1a63c
Co-authored-by: Copilot <[email protected]> Copilot-Session: 91cf4795-752a-44db-97d3-4a513bf1a63c
CI report: https://s3.amazonaws.com/clickhouse-test-reports/json.html?PR=107292&sha=dd4baabf6fd6ab0db1e5d4f97bd906272d248d03&name_0=PR&name_1=Fast%20test PR: ClickHouse#107292 Co-authored-by: Copilot <[email protected]> Copilot-Session: 91cf4795-752a-44db-97d3-4a513bf1a63c
Review: ClickHouse#107292 (comment) PR: ClickHouse#107292 Co-authored-by: Copilot <[email protected]> Copilot-Session: 91cf4795-752a-44db-97d3-4a513bf1a63c
Review: ClickHouse#107292 (comment) PR: ClickHouse#107292 Co-authored-by: Copilot <[email protected]> Copilot-Session: 91cf4795-752a-44db-97d3-4a513bf1a63c
PR: ClickHouse#107292 Co-authored-by: Copilot <[email protected]> Copilot-Session: 91cf4795-752a-44db-97d3-4a513bf1a63c
PR: ClickHouse#107292 Co-authored-by: Copilot <[email protected]> Copilot-Session: 91cf4795-752a-44db-97d3-4a513bf1a63c
Review: ClickHouse#107292 (comment) PR: ClickHouse#107292 Co-authored-by: Copilot <[email protected]> Copilot-Session: 91cf4795-752a-44db-97d3-4a513bf1a63c
Review: ClickHouse#107292 (comment) PR: ClickHouse#107292 Co-authored-by: Copilot <[email protected]> Copilot-Session: 91cf4795-752a-44db-97d3-4a513bf1a63c
PR: ClickHouse#107292 Co-authored-by: Copilot <[email protected]> Copilot-Session: 91cf4795-752a-44db-97d3-4a513bf1a63c
|
Dear @yariks5s, 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. |
Co-authored-by: Copilot <[email protected]> Copilot-Session: 2b8fb69c-169e-45bf-8ff9-c78ca9dd6a9f
Co-authored-by: Copilot <[email protected]> Copilot-Session: 2b8fb69c-169e-45bf-8ff9-c78ca9dd6a9f
Head branch was pushed to by a user without write access
Move the setting history entry from 26.7 to the current 26.8 block after merging the latest master. CI: https://s3.amazonaws.com/clickhouse-test-reports/json.html?PR=107292&sha=ff86df444238429a07c6abfa5271b55d48e8c8ff&name_0=PR&name_1=Style%20check PR: ClickHouse#107292 Co-authored-by: Copilot <[email protected]> Copilot-Session: 2b8fb69c-169e-45bf-8ff9-c78ca9dd6a9f
Use the outer field settings for the final tuple element in both the writer and reader whole-field gates. Add direct and inverse-delimiter regressions for `CustomSeparated` and `Template`. Co-authored-by: Copilot <[email protected]> Copilot-Session: 2b8fb69c-169e-45bf-8ff9-c78ca9dd6a9f
Make `SerializationTuple` quote-capability checks mirror its own interior and final-element settings. This prevents a nested whole-field fallback from creating a partially quoted outer tuple field while preserving safe flattened output. Co-authored-by: Copilot <[email protected]> Copilot-Session: 2b8fb69c-169e-45bf-8ff9-c78ca9dd6a9f
Build profile diff (arm_release)Commit See the job log for details. |
Match CSV quote capability checks to the single-field representation used by `SerializationNullable`, and cover leading, trailing, and nested tuple boundaries. Review: ClickHouse#107292 (comment) Co-authored-by: Copilot <[email protected]> Copilot-Session: 2b8fb69c-169e-45bf-8ff9-c78ca9dd6a9f
Co-authored-by: Copilot <[email protected]> Copilot-Session: 2b8fb69c-169e-45bf-8ff9-c78ca9dd6a9f
Reuse the format-owned `PeekableReadBuffer` so ambiguous `Template` and `CustomSeparated` tuple fields can retry without losing delimiter bytes across input chunks. Review: ClickHouse#107292 (comment) Co-authored-by: Copilot <[email protected]> Copilot-Session: 2b8fb69c-169e-45bf-8ff9-c78ca9dd6a9f
ClickHouse#107292 Co-authored-by: Copilot <[email protected]> Copilot-Session: 2b8fb69c-169e-45bf-8ff9-c78ca9dd6a9f
ClickHouse#107292 (comment) Co-authored-by: Copilot <[email protected]> Copilot-Session: 2b8fb69c-169e-45bf-8ff9-c78ca9dd6a9f
Propagate row-aware CSV quote decisions through `Variant` and `Dynamic` while preserving flattened safe and NULL rows. Related: ClickHouse#107292 (comment) Co-authored-by: Copilot <[email protected]> Copilot-Session: 2b8fb69c-169e-45bf-8ff9-c78ca9dd6a9f
…quote-date-time-types 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) Also resolved conflicts in: - `src/DataTypes/Serializations/SerializationDynamic.cpp` - `src/Formats/EscapingRuleUtils.cpp` Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
…quote-date-time-types # Conflicts: # src/DataTypes/Serializations/SerializationTuple.cpp
| const bool writes_fractional_part = scale > 0 | ||
| && (!cut_trailing_zeros_align_to_groups_of_thousands | ||
| || value.value % DecimalUtils::scaleMultiplier<DateTime64::NativeType>(scale) != 0); | ||
| return delimiter == '-' || delimiter == ':' || delimiter == ' ' || (writes_fractional_part && delimiter == '.'); |
There was a problem hiding this comment.
[P1] Preserve dot delimiters even when the timestamp has no fractional output
The quote decision must also account for what the reader can consume. readDateTimeTextImpl for DateTime64 always accepts a following . and consumes the subsequent digits, including when scale == 0. Thus an otherwise valid CustomSeparated round trip now fails:
SELECT * FROM format(
CustomSeparated, 'dt DateTime64(0), n UInt8',
formatRow('CustomSeparated', toDateTime64('2024-01-18 09:45:01', 0), 42::UInt8))
SETTINGS output_format_csv_quote_date_time_types = 0,
format_custom_escaping_rule = 'CSV',
format_custom_field_delimiter = '.',
format_custom_row_after_delimiter = '\n',
input_format_custom_detect_header = 0;The writer emits 2024-01-18 09:45:01.42, and the timestamp reader consumes .42, leaving no separator or second column. The same problem affects whole-second DateTime64(3) values with trailing-zero cutting enabled, including the flattened tuple output asserted by the new test. Please retain quotes for this boundary or make the reader field-bounded, and add round-trip coverage rather than only checking the emitted bytes.
| && *peekable_buf.position() == settings.csv.tuple_delimiter | ||
| && !settings.csv.tuple_delimiter_matches_field_delimiter; | ||
|
|
||
| if (tuple_delimiter_follows && boundary_follows && may_use_whole_csv_field) |
There was a problem hiding this comment.
[P1] Preserve ambiguous flattened tuples without temporal leaves
Whole-field detection runs for quoted non-temporal tuples too, but the legacy-flattened preference here is restricted to may_use_whole_csv_field. For Tuple(String, Int8) that flag is false, so a tuple-shaped first string is mistaken for the entire tuple when the outer delimiter matches the beginning of the interior delimiter plus the next value. This breaks existing input even with the new setting left at its default:
SELECT * FROM format(
CustomSeparated, 't Tuple(String, Int8), n UInt8',
formatRow('CustomSeparated', tuple('(''y'',-5)', -5::Int8), 42::UInt8))
SETTINGS format_csv_delimiter = '.',
format_custom_escaping_rule = 'CSV',
format_custom_field_delimiter = '.-',
format_custom_row_after_delimiter = '\n',
input_format_custom_detect_header = 0;The valid flattened bytes are "('y',-5)".-5.-42. Both boundary checks succeed after the first quoted string, but this condition skips the flattened parse; tryDeserializeText then accepts ('y',-5) as the whole tuple. The reader consumes the wrong boundary and subsequently fails. Preserve the flattened interpretation for non-temporal tuples as well, and add this variant alongside the existing temporal ambiguity regression.
Related: #34668
Adds
output_format_csv_quote_date_time_types, a backward-compatible CSV output setting for users that need date and time values emitted without surrounding double quotes while keeping existingCSVbehavior by default.The setting applies to
Date,Date32,DateTime,DateTime64,Time, andTime64values inCSVoutput. Strings remain quoted according to the existingCSVserializer and numbers are unchanged. CSV input parsing is unchanged and already accepts both quoted and unquoted date and time values.Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):
Adds the setting
output_format_csv_quote_date_time_types. When disabled,Date,Date32,DateTime,DateTime64,Time, andTime64values are written without surrounding double quotes inCSVoutput, while preserving the existing quoted behavior by default.Documentation entry for user-facing changes
Workflow [PR]
Sync PR [sync-upstream/pr/107292]