Skip to content

Support output Hive text format - #107582

Merged
alexey-milovidov merged 53 commits into
masterfrom
support-output-hive-text-format
Aug 7, 2026
Merged

alexey-milovidov merged 53 commits into
masterfrom
support-output-hive-text-format

Conversation

@alexey-milovidov

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

Copy link
Copy Markdown
Member

Reimplements #60737.

Adds the HiveText output format, so SELECT ... FORMAT HiveText and inserts into file-backed tables can produce the text serialization used by Apache Hive tables (Hive's LazySimpleSerDe). HiveText already existed as an input format; this adds the output side. It targets Hive's default LazySimpleSerDe — see Compatibility for what this does and does not guarantee.

Format

Each row is written without any quoting:

  • top-level fields are separated by the fields delimiter — \x01 (Ctrl-A) by default, controlled by the existing input_format_hive_text_fields_delimiter setting;
  • rows are separated by the rows delimiter — \n by default, controlled by the new format_hive_text_rows_delimiter setting;
  • values of nested types (Array, Map, Tuple) are written without brackets and are separated by Hive's separator list indexed by nesting level: \x02 for collection items (controlled by input_format_hive_text_collection_items_delimiter), \x03 for map key/value pairs (controlled by input_format_hive_text_map_keys_delimiter), and Hive's default deeper control characters (\x04, \x05, and so on), the same way Hive does it;
  • non-finite Float32/Float64 values are written using Hive's Java spellings — NaN, Infinity, and -Infinity — so they round-trip through Hive's FLOAT/DOUBLE parser.

Types that have no natural Hive text representation (for example AggregateFunction, Dynamic, Variant, LowCardinality, Object) are not supported for output and throw NOT_IMPLEMENTED.

Compatibility

The output targets Hive's default LazySimpleSerDe and is not symmetric with ClickHouse's own HiveText input:

  • Nested Array/Map/Tuple values are written with Hive's nested separators (no brackets), but the input format parses each field with CSV/bracketed rules and ignores input_format_hive_text_collection_items_delimiter / input_format_hive_text_map_keys_delimiter. So nested output such as SELECT [1, 2] FORMAT HiveText is not read back by INSERT ... FORMAT HiveText — only top-level scalar fields round-trip, and only with the default \n row delimiter.
  • Round-tripping also requires the default \n row delimiter. When format_hive_text_rows_delimiter is changed, the output separates rows with the configured byte, but the input side is still the newline-based CSVRowInputFormat and there is no matching input_format_hive_text_rows_delimiter. So multi-row scalar output such as SELECT number FROM numbers(3) FORMAT HiveText SETTINGS format_hive_text_rows_delimiter=';' (which produces 0;1;2;) is not read back by INSERT ... FORMAT HiveText as three rows.
  • Only the default, unescaped LazySimpleSerDe subset is implemented: fields are written without escaping (no equivalent of Hive's optional ROW FORMAT DELIMITED ... ESCAPED BY), and NULL is always \N (no equivalent of NULL DEFINED AS). A String that itself contains an active separator is written literally and will be misread when parsed back — this matches how Hive behaves with a non-escaping serde.

Implementation

  • a new ISerialization::serializeTextHive() virtual method whose default implementation throws, overridden only by the data types Hive supports (numbers up to 64-bit — the 128/256-bit integer domains fit no Hive type and throw, string, decimal up to Hive DECIMAL's maximum precision of 38, date/datetime, bool, and the nested Array/Map/Tuple/Nullable containers);
  • a new HiveTextRowOutputFormat, registered unconditionally (it does not depend on USE_HIVE, since output needs no Hive metastore).

Changelog category (leave one):

  • New Feature

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

Added the HiveText output format that writes data in Apache Hive LazySimpleSerDe text form. Fields are separated by \x01, rows by the new format_hive_text_rows_delimiter setting (default \n), and nested Array, Map, and Tuple values use Hive's separator list. The output targets Hive's default LazySimpleSerDe and is not symmetric with ClickHouse's HiveText input for nested values or custom row delimiters.

Add the HiveText output format, mirroring Apache Hive's LazySimpleSerDe text
serialization. Each row is written without quoting; top-level fields are
separated by the fields delimiter ('\001' by default) and rows by the rows
delimiter ('\n', configurable via the new format_hive_text_rows_delimiter
setting). Values of nested types (Array, Map, Tuple) are written without
brackets, separated by a delimiter derived from the fields delimiter by their
nesting level, the same way Hive does it.

Implemented via a new ISerialization::serializeTextHive() method (whose default
throws for types that Hive does not support) and a new HiveTextRowOutputFormat.

Reimplements #60737.

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

clickhouse-gh Bot commented Jun 16, 2026 •

Copy link
Copy Markdown
Contributor

Workflow [PR], commit [1ed2085]

Summary: ✅


AI Review

Summary

This PR adds HiveText output support and, after the earlier follow-up commits, the serializer matrix and upfront type validation are mostly in good shape. One contract gap still remains: the newly documented top-level-scalar self-round-trip still loses Nullable(String) values whose literal contents are \N, because the input side now unconditionally treats \N as null.

Findings

⚠️ Majors

  • [src/Processors/Formats/Impl/HiveTextRowInputFormat.cpp:26] Pinning csv.null_representation to \N makes SELECT CAST('\\N', 'Nullable(String)') FORMAT HiveText | INSERT ... FORMAT HiveText insert NULL, because SerializationNullable::deserializeTextCSVImpl checks the null token before delegating to the nested String parser. The current docs in docs/reference/formats/HiveText.mdx and the focused regression 04693_hive_text_output_round_trip still describe a blanket top-level-scalar round-trip, so the advertised contract is too broad. Narrow the contract and add a focused regression for this value, or reject it on output for Nullable(String) if the strict round-trip guarantee is meant to hold.
Final Verdict

⚠️ Needs follow-up before merge: the new self-round-trip contract is still overstated for Nullable(String) values equal to \N.

LLVM Coverage Report

Metric Baseline Current Δ
Lines 86.50% 86.50% +0.00%
Functions 91.90% 91.80% -0.10%
Branches 78.80% 78.80% +0.00%

Changed lines: Changed C/C++ lines covered: 399/422 (94.55%) · Uncovered code

Full report · Diff report

@clickhouse-gh clickhouse-gh Bot added the pr-feature Pull request with new product feature label Jun 16, 2026
Comment thread src/Core/FormatFactorySettings.h Resolved
alexey-milovidov and others added 4 commits June 19, 2026 05:24
`SerializationDate` and `SerializationDateTime` derive from `SerializationNumber`
and so inherited its numeric `serializeTextHive`, which writes the raw underlying
integer. As a result `SELECT toDate('2024-04-09') FORMAT HiveText` emitted `19822`
and `DateTime` emitted epoch seconds, while Hive text output expects date and
timestamp strings.

Override `serializeTextHive` for `SerializationDate` and `SerializationDateTime`
to delegate to `serializeText`, matching what `SerializationDate32` and
`SerializationDateTime64` already do, and fix the `03093` reference that recorded
the buggy `Date` output.

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
The new `format_hive_text_rows_delimiter` setting was declared as `UInt64` and
then truncated with `static_cast<char>` before use, unlike the existing Hive
delimiter settings (`input_format_hive_text_fields_delimiter` and friends) which
are `Char`. That made it inconsistent to configure and silently accepted invalid
values such as `256`.

Declare it as `Char` and assign it directly into `FormatSettings::hive_text.rows_delimiter`.

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
Covers `Date`, `Date32`, `DateTime` and `DateTime64` (which must be written as
Hive date/timestamp strings rather than the underlying numeric values) and the
`format_hive_text_rows_delimiter` setting with a non-default value, complementing
the existing `03093` test.

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

Copy link
Copy Markdown
Member Author

Addressed the AI Review ❌ Block verdict (both inline threads resolved):

  1. Date/DateTime Hive output (ec4db03d81f) — SerializationDate and SerializationDateTime derive from SerializationNumber and so inherited its numeric serializeTextHive, emitting the raw underlying integer (19822, epoch seconds). Added overrides delegating to serializeText, matching SerializationDate32/SerializationDateTime64. Fixed the 03093 reference accordingly.
  2. format_hive_text_rows_delimiter typing (fca2d8595d7) — changed from UInt64+static_cast<char> to a Char setting assigned directly, consistent with the existing Hive delimiter settings. Multi-character values (e.g. 256) are now rejected with SIZE_OF_FIXED_STRING_DOESNT_MATCH instead of being silently truncated.
  3. Tests (a2a49f6e4e7) — new 05018_hive_text_output_dates_and_row_delimiter covering Date, Date32, DateTime, DateTime64 and a non-default row delimiter; both it and 03093 pass against a locally built server.

Also merged master (clean) so CI runs on a fresh base.

One design item left for your call (not changed): Time, Time64, Enum and Interval also inherit the numeric/decimal serializeTextHive and emit raw values (e.g. Enum emits its numeric value rather than the name, Time emits raw seconds). Hive has no TIME/INTERVAL/ENUM type, so per the format's stated philosophy these arguably should either delegate to serializeText or throw NOT_IMPLEMENTED rather than silently emit raw numbers.

alexey-milovidov and others added 3 commits June 21, 2026 10:34
The new stateless test was numbered 05018, leaving a gap from the previous
highest number (4356) larger than 100, which the `test_numbers_check` style
check rejects (`Gap (4356, 5018) > 100`). Renumber it to 04402.

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
`HiveText` output promises that only Hive-supported scalar types are serialized
and that types with no natural Hive text representation throw `NOT_IMPLEMENTED`.
But `SerializationEnum`, `SerializationTime` and `SerializationInterval` derive
from `SerializationNumber` and so inherited its generic numeric `serializeTextHive`,
silently emitting the raw underlying integer (the enum's number instead of its
name, the time as raw seconds, the interval as a raw count). `SerializationTime64`
already threw via the base default, but with a generic message.

Hive has no `ENUM`, `TIME` or `INTERVAL` type, so these are not in the documented
supported set. Add `serializeTextHive` overrides that throw `NOT_IMPLEMENTED` with
a clear per-type message, making the contract hold instead of producing a lossy
file. This is the conservative, non-additive direction: declining support rather
than presuming a representation; supporting any of these (e.g. emitting the enum
name) remains a follow-up decision.

Adds `04403_hive_text_output_unsupported_types` covering all four types and
documents the rejected types in the `HiveText` format reference.

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

Copy link
Copy Markdown
Member Author

Addressed the remaining AI Review ❌ Block finding and the red Style check.

  1. Numeric-backed special types (36a7fd39fd5) — Enum, Time and Interval derived from SerializationNumber and inherited its generic numeric serializeTextHive, silently emitting the raw underlying integer (the enum's number instead of its name, the time as raw seconds, and so on). Added serializeTextHive overrides that throw NOT_IMPLEMENTED with a clear per-type message (e.g. Type Enum is not supported by the HiveText output format); SerializationTime64 already threw via the base default and now does so with a matching message. Hive has no ENUM/TIME/INTERVAL type, so these are kept out of the documented supported set rather than producing a lossy file — the conservative, non-additive direction (declining support rather than presuming a representation such as the enum name; that can be a follow-up).

  2. test_numbers_check (cf132c31b35) — renumbered the new stateless test 05018 → 04402 to close Gap (4356, 5018) > 100.

  3. Tests / docs — added 04403_hive_text_output_unsupported_types (asserts all four types throw NOT_IMPLEMENTED) and documented the rejected types in the HiveText format reference.

Merged master (clean) for a fresh build base. Built locally (no errors, no warnings in the changed files) and verified against the freshly built 26.6 server: 04402 and 03093 produce the expected output, and Enum/Time/Time64/Interval each throw Type X is not supported by the HiveText output format (code 48, NOT_IMPLEMENTED).

…-text-format

# Conflicts:
#	tests/queries/0_stateless/02187_async_inserts_all_formats.python
#	tests/queries/0_stateless/03251_insert_sparse_all_formats.sh
@alexey-milovidov

alexey-milovidov commented Jun 29, 2026 •

Copy link
Copy Markdown
Member Author

Merged the latest master (the branch was ~575 commits behind and red). Build-verified the 22 changed translation units (including the new HiveTextRowOutputFormat.cpp) against the merged master — they compile cleanly.

CI failure analysis

Docs check / Build docusaurus — this one is caused by this PR, but the bug is in the docs generation tooling, not in this PR's code. The new setting format_hive_text_rows_delimiter has default \n, and its SettingsChangesHistory.cpp entry is the first one in the whole file with a control character in a default value. The clickhouse-docs settings generator (scripts/settings/format-settings.sql) builds the <VersionHistory rows={...}/> JSX expression by concatenating the version, default value and comment into a JSON array, but it only escapes the comment (and only "/\). The raw \n therefore lands inside a JS string literal, which MDX/acorn rejects with Could not parse expression with acorn.

Fix submitted to clickhouse-docs: ClickHouse/clickhouse-docs#6461 (escape all three labels with toJSONString). The Docs check clones clickhouse-docs main fresh at run time, so this PR's Docs check will go green on the next run once that is merged. The fix is also required to avoid breaking the live docs build once this PR merges.

AST fuzzer (amd_debug, targeted) / Logical error: Inconsistent KeyCondition behavior (STID: 5182-684a) — unrelated, known flaky fuzzer issue tracked in #98075 (exact same STID). It is in MergeTreeDataSelectExecutor::markRangesFromPKRange query planning and recurs across many unrelated PRs; nothing to do with an output format.

Stress test (arm_asan_ubsan, s3) / UndefinedBehaviorSanitizer in ConcurrentBoundedQueue<Chunk>::popImpl (chrono duration_cast) — unrelated, pre-existing UBSan that also fires on master (PR=0 in CIDB on the same day). Not related to this PR.

alexey-milovidov and others added 2 commits June 30, 2026 00:35
…or nested types

The nested `HiveText` output derived every separator from the fields delimiter by
character arithmetic (`fields_delimiter + 1`, `fields_delimiter + 2`), which ignored
the existing `input_format_hive_text_collection_items_delimiter` and
`input_format_hive_text_map_keys_delimiter` settings and corrupted the output for any
non-default fields delimiter (for example, fields `,` emitted array elements separated
by `-` and map key/values by `.`).

Thread an explicit nesting level (`FormatSettings::HiveText::nesting_level`) through the
`Array`/`Map`/`Tuple` serializations and resolve each separator from Apache Hive's
`LazySimpleSerDe` separator list via the new `getHiveTextDelimiter`: index 0 is the
fields delimiter, 1 the collection-items delimiter, 2 the map-keys delimiter, and deeper
levels default to consecutive control characters (`\x04`, `\x05`, ...). Data nested
deeper than Hive's eight separators now throws `NOT_IMPLEMENTED` instead of emitting an
out-of-range byte.

Output for the default delimiters is byte-for-byte unchanged. Added
`04489_hive_text_output_nondefault_delimiters` covering `Array`, `Map` and `Tuple` with
non-default delimiters, and updated the `HiveText` format docs.

Addresses the AI Review block on #107582

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

Copy link
Copy Markdown
Member Author

Triaged this PR (continue-pr): no code change needed — it is effectively ready.

  • Review state: AI Review verdict is ✅ Approve (the earlier ❌ Block findings on Date/DateTime numeric output, the format_hive_text_rows_delimiter Char typing, the Enum/Time/Interval → NOT_IMPLEMENTED handling, and the test renumbering are all addressed in the existing commits). There are 0 unresolved review threads.
  • Mergeability: MERGEABLE, no conflicts. The branch is ~96 commits behind master, but the merge-base is from 2026-06-29 23:39Z (< 1 day old), so I did not re-merge — re-merging would not clear the sole red (see below).
  • Sole CI red: AST fuzzer (amd_debug, targeted, old_compatibility) → Logical error: Block structure mismatch in A stream: different columns: (STID: 0993-27f0). This is unrelated to the HiveText output format. The actual failing query in this run is a fuzzed
    SELECT makeDate32(day, year) FROM (
      SELECT DISTINCT 0 AS year, 1048575 AS day, 65535 AS month GROUP BY 2 WITH TOTALS LIMIT 251
      UNION ALL
      SELECT DISTINCT materialize(257 AS year), 65537, toLowCardinality(toNullable(2 AS day))
      WHERE isNullable(day) GROUP BY GROUPING SETS ((makeDate32(NULL, NULL, isNull(NULL), -2147483649)))
      QUALIFY equals(-1, day)
    ) QUALIFY isNull(day) ORDER BY month ASC NULLS FIRST WITH FILL, day ASC NULLS LAST, year DESC
    with no FORMAT HiveText at all — it aborts in UnionStep::updateOutputHeader on a UNION ALL branch whose header constant-folds to Const(Nullable(Nothing)) while the other branch is a non-const Nullable(Nothing). This is the known, still-open Logical error: Block structure mismatch in A stream: different columns: (STID: 0993-27f0) #108142, and a general fix for this class is already in flight in Fix Block structure mismatch in UnionStep/IntersectOrExceptStep when a branch constant-folds #107719 (Fix Block structure mismatch in UnionStep/IntersectOrExceptStep when a branch constant-folds).

This PR only adds an output serialization path and does not touch query planning, so the fuzzer failure cannot be caused by it. Blocked solely on a fuzzer re-run (or #107719 landing) and a maintainer merge.

alexey-milovidov and others added 2 commits June 30, 2026 18:57
The most recent merge of `master` brought in
`04489_max_threads_auto_parsing_compat`, which collides on the `04489`
numeric prefix with this PR's new
`04489_hive_text_output_nondefault_delimiters`. Renumber the latter to
`04490` (the next free number) so the two tests do not share a prefix.

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

Copy link
Copy Markdown
Member Author

Continued this PR (continue-pr): merged latest master and renumbered a colliding test; build- and smoke-verified locally; pushed.

What changed since the last triage

GitHub flipped the PR to CONFLICTING/DIRTY (it was MERGEABLE at the previous pass). So this time I merged master:

  1. Merged master (28ee3f03ea5) — the git merge was actually clean (no conflict markers; the settings files FormatFactorySettings.h, SettingsChangesHistory.cpp, FormatSettings.h, FormatFactory.cpp auto-merged), so GitHub's CONFLICTING flag was stale against an older base. After the push the PR is MERGEABLE again. The format_hive_text_rows_delimiter change-history entry moved cleanly to the top of the bumped 26.7 version block.
  2. Renumbered the nondefault-delimiters test (50d72267c77) — the merge brought in 04489_max_threads_auto_parsing_compat, which collided on the 04489 numeric prefix with this PR's new 04489_hive_text_output_nondefault_delimiters. Renamed the latter to 04490_hive_text_output_nondefault_delimiters (next free number; the test has no internal references to its own number).

Verification

  • Built the clickhouse target against the merged base — completed with 0 errors (the merge recompiled ~3.6k TUs from master header churn; the PR's serialization TUs and the new HiveTextRowOutputFormat.cpp compile cleanly).
  • Smoke-tested the freshly built binary: nested types honor the configured collection/map-key delimiters (1;2;3,k1:10;k2:20,1;a;7:8), Date/Date32/DateTime delegate to serializeText, a non-default format_hive_text_rows_delimiter is honored, and Enum/Time/Interval still throw NOT_IMPLEMENTED (... is not supported by the HiveText output format).

Review / CI

Blocked solely on the fresh CI (and the unrelated fuzzer flake) plus a maintainer merge.

…put_format

`SerializationDateTime::serializeTextHive` and `SerializationDateTime64::serializeTextHive`
delegated to `serializeText`, which honors `date_time_output_format`. With
`date_time_output_format = 'unix_timestamp'` a `DateTime`/`DateTime64` value was emitted
as epoch seconds again, and with `iso` it was emitted as `2024-04-09T12:34:56Z` — both
forms that Hive cannot parse as a `TIMESTAMP`. So a deployment with a non-default
session/server setting could produce `HiveText` files unreadable by Hive.

Make the Hive serializers always write the simple Hive timestamp text
(`yyyy-MM-dd HH:mm:ss[.fffffffff]`), bypassing `date_time_output_format`.
`SerializationDateTime64::serializeTextHive` still honors
`date_time_64_output_format_cut_trailing_zeros_align_to_groups_of_thousands`,
which only affects the fractional part and stays Hive-parseable.

`Date`/`Date32` were already insulated (their `serializeText` writes
`writeDateText` unconditionally), so they are unchanged.

Add `04491_hive_text_output_datetime_format_setting`, which asserts the output is the
simple Hive timestamp text under `date_time_output_format` = `simple`, `unix_timestamp`
and `iso`; the existing `04402` test only pinned `simple`, so it could not catch this.
Document the behavior in the `HiveText` format reference.

Addresses the AI Review "Request changes" verdict on PR #107582.

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
Comment thread docs/en/interfaces/formats.md Resolved
@alexey-milovidov alexey-milovidov added the pr-autogenerated-docs PR that regenerates docs artifacts from source; exempt from the autogenerated-region edit guard label Jul 31, 2026
The change updated the legacy `docs/en/interfaces` pages and the embedded
`setDocumentation` block, but the Mintlify tree that actually backs the public
format reference was still input-only:

- `docs/reference/formats/index.mdx` marked `HiveText` output as `✗`.
- `docs/reference/formats/HiveText.mdx` declared `output_format: false` in its
  frontmatter, and its generated body still described the format as input-only
  with no mention of `format_hive_text_rows_delimiter`.

The overview-table row and the frontmatter flag are hand-maintained, so they are
edited directly. The page body lives inside an `AUTOGENERATED` region fed by
`system.formats`, so it is regenerated with the in-tree generator rather than
hand-written:

    python3 ci/jobs/scripts/docs/autogenerate/autogenerate_docs.py \
        --write --binary build/programs/clickhouse --docs-dir docs \
        --only format:HiveText

`--check` for the same page now reports it as in sync. Because the diff touches
a generated region, the pull request carries the `pr-autogenerated-docs` label
that `ci/jobs/docs_job_mintlify.py` uses to skip the generated-region guard.

The settings reference under `docs/reference/settings/formats` is left to the
nightly generator: `format_hive_text_rows_delimiter` already carries its
docstring in `src/Core/FormatFactorySettings.h`, which is the only supported
source for those pages.
@clickhouse-gh

clickhouse-gh Bot commented Aug 1, 2026

Copy link
Copy Markdown
Contributor

LLVM Coverage Report

Metric Baseline Current Δ
Lines 86.50% 86.50% +0.00%
Functions 91.90% 91.90% +0.00%
Branches 78.70% 78.70% +0.00%

Changed lines: Changed C/C++ lines covered: 389/412 (94.42%) · Uncovered code

Full report · Diff report

The initial commit excluded `HiveText` from `03251_insert_sparse_all_formats`,
which is the end-to-end regression for the one self-compatibility guarantee the
documentation and the PR body still make: top-level scalar fields written with
the default fields delimiter and the default rows delimiter round-trip through
`SELECT ... FORMAT HiveText | INSERT ... FORMAT HiveText`.

The exclusion is not needed. `system.formats` is already filtered on
`is_input AND is_output`, so builds without `USE_HIVE` (where only the output
side is registered) drop `HiveText` from the list on their own. Verified
against a local server that the `HiveText` iteration of `03251` produces the
same `sum(sipHash64(*))` as every other format, including on the
`enable_parsing_to_custom_serialization` path with sparse columns.

Also add a focused `04693_hive_text_output_round_trip` regression that pipes a
table of top-level scalars (including `Nullable` and `Bool`) through
`FORMAT HiveText` and back, since `03251` is tagged `long` and is skipped in
several build configurations.

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

clickhouse-gh Bot commented Aug 3, 2026 •

Copy link
Copy Markdown
Contributor

Build profile diff (arm_release)

No arm_release build profile data for commit 1ed2085 - the build was skipped, reused from cache, or predates profile upload.

…-text-format

# Conflicts:
#	docs/en/interfaces/formats.md
#	docs/en/interfaces/formats/HiveText.md
The `HiveText` output format always writes `NULL` as Hive's default null
sequence `\N`, but the CSV-based input side still read the null token from
`format_csv_null_representation`, so with a non-default value of that setting
the documented top-level scalar round-trip inserted the literal string `\N`
instead of `NULL` (and `Nullable` numerics failed to parse). Pin
`csv.null_representation` to `\N` in `updateFormatSettings`, next to the other
CSV knobs the format already overrides, so both sides are independent of that
setting, matching Hive's `LazySimpleSerDe`. Document it and add a focused
regression test.

Co-Authored-By: Claude Fable 5 <[email protected]>
updated.csv.allow_variable_number_of_columns = settings.hive_text.allow_variable_number_of_columns;
/// Hive's `LazySimpleSerDe` always writes `NULL` as `\N` (and the `HiveText` output format
/// always emits `\N`), so accept it independent of `format_csv_null_representation`.
updated.csv.null_representation = "\\N";

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.

Pinning the input null token to \N still leaves one hole in the new top-level-scalar round-trip contract: SerializationNullable::deserializeTextCSVImpl checks settings.csv.null_representation before it delegates to the nested String serializer, so SELECT CAST('\\N', 'Nullable(String)') FORMAT HiveText | INSERT ... FORMAT HiveText comes back as NULL, not the original string. That is distinct from the already-documented Hive-side ambiguity for plain String: here the same-table ClickHouse self-round-trip loses data for a supported scalar type.

Please either narrow the contract/docs/tests to exclude Nullable(String) values equal to \N, or reject that value on output if the strict round-trip guarantee is supposed to hold.

@alexey-milovidov
alexey-milovidov added this pull request to the merge queue Aug 7, 2026
Merged via the queue into master with commit b23db30 Aug 7, 2026
181 checks passed
@alexey-milovidov
alexey-milovidov deleted the support-output-hive-text-format branch August 7, 2026 19:59
@robot-ch-test-poll4 robot-ch-test-poll4 added the pr-synced-to-cloud The PR is synced to the cloud repo label Aug 7, 2026

This branch was successfully deployed

1 active deployment
staging - docs — 1ed20856 Deployed Aug 7, 2026 by mintlify[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

pr-autogenerated-docs PR that regenerates docs artifacts from source; exempt from the autogenerated-region edit guard pr-feature Pull request with new product feature 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