Repository navigation
Fix Arrow export of JSON, Dynamic, QBit and AggregateFunction - #115250
Conversation
The `output_format_arrow_unsupported_types_as_binary` fallback wrote a column with no first-class Arrow mapping by calling `IColumn::getDataAt` per row. That method exposes a column's contiguous in-memory bytes, which most of the types reaching the fallback do not have: - `ColumnObject` (`JSON`), `ColumnVariant` (hence `ColumnDynamic`) and `ColumnQBit` throw `Method getDataAt is not supported`, so `SELECT ... FORMAT Arrow` failed on them - after the schema message had already been written, leaving the client with a truncated stream; - `ColumnAggregateFunction::getDataAt` returns the `AggregateDataPtr` itself, so exporting an aggregate state silently wrote raw heap addresses instead of the state, both corrupting the data and disclosing server addresses. Before the fallback existed these types were rejected with a clear `UNKNOWN_TYPE`, so both are regressions introduced together with the setting. The fallback now serializes each value through `ISerialization`, whose `serializeText`/`serializeBinary` are pure virtual and therefore defined for every type, so the "do not fail a `SELECT *`" property holds by construction instead of depending on an unrelated method's implementation status. The aggregate state written in binary mode is the `RowBinary` encoding and deserializes back into the original `AggregateFunction` type. `output_format_arrow_unsupported_types` (`throw`/`text`/`binary`) replaces the boolean, adding a `text` mode that writes what `CAST(col AS String)` would produce - useful for the BI clients that drive `SELECT *` over Arrow Flight SQL, and the workaround users had to apply by hand for `JSON`. The default, `binary`, is the previous behavior, so `compatibility` must not change it. The boolean keeps working with full effect (`0` means `throw`, `1` means `binary`) and is only consulted while the new setting is left at its default, so an explicit mode wins whichever order the two are set in. Both writers now decide in the schema converter, before the schema message is written, so a rejected type can no longer abort a stream whose schema the reader has already accepted. An opaque column is tagged with the `clickhouse.opaque` Arrow extension name and the original ClickHouse type name, so a consumer can tell it apart from a genuine string or binary column; a reader that does not know the extension name sees the plain storage type. Closes: #115023 Caused by: #91170 Co-authored-by: Yakov Olkhovskiy <[email protected]>
|
|
|
Workflow [PR], commit [93eb366] Summary: ✅
AI ReviewSummaryThis PR correctly replaces the old Findings❌ Blockers
Tests
Final VerdictChanges requested. LLVM Coverage ReportMeasured on commit 93eb366.
Changed lines: Changed C/C++ lines covered: 511/587 (87.05%) · Uncovered code |
A new setting field type has to be listed in every `*_SUPPORTED_TYPES` macro that carries format settings, otherwise `Settings::operator[]` has no overload for it. Follows `ArrowCompression` everywhere it appears. Co-authored-by: Yakov Olkhovskiy <[email protected]>
Build profile diff (arm_release)Comparing ✅ No significant changes. Binary sizes
The official master build is compiled with Object file sizes464 object files changed (+378.97 KiB total), 1 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 units3194 translation units recompiled, 16711 s compile time in total, 3193 of them have a recent master baseline. |
Covers all three values of `output_format_arrow_unsupported_types` for `JSON`, `Dynamic`, `Array(Dynamic)` and `AggregateFunction`, the precedence between the new setting and `output_format_arrow_unsupported_types_as_binary` in both orders, the `AggregateFunction` binary round-trip through `finalizeAggregation`, and the `clickhouse.opaque` extension tag as seen by `pyarrow`. Co-authored-by: Yakov Olkhovskiy <[email protected]>
…ting in the Flight sink `CHColumnToArrowColumn`, which serves Arrow Flight, only switched the storage type to `utf8`/`binary` for a column with no Arrow mapping, so a Flight client could not tell such a column from a genuine `String`/`Binary` one - the `clickhouse.opaque` extension tag existed only in the native IPC writer. `getArrowType` now reports the ClickHouse type name of an opaque column through an out parameter and `calculateArrowSchema` attaches the same extension metadata. Only the pass-through wrappers (`Nullable`, `LowCardinality`) forward it, so it describes the field itself, matching how this writer already tags `UUID` at the root. The extension name moves to `FormatSettings` next to the enum, so both writers share one definition (`SchemaConverter.h` is `USE_ARROW`-only, while `CHColumnToArrowColumn` also builds for `USE_PARQUET`). `StorageArrowFlight::ArrowFlightSink::consume` built its converter settings from scratch and so never consulted the setting at all, leaving it on the struct default. It now resolves the mode from the query context like the other Arrow Flight call sites, which makes `INSERT INTO ... ENGINE = ArrowFlight` of an `AggregateFunction` column follow `output_format_arrow_unsupported_types` (`throw` reproduces the struct default). `JSON` and `Dynamic` cannot reach this sink: the storage rejects a dynamic-structure column when the table is created, and through the table function the header comes from the remote schema. Verified against a local ClickHouse Arrow Flight server: `SELECT *` over a table with `JSON` and `AggregateFunction` columns returns them as `clickhouse.opaque`-tagged `binary` fields carrying the ClickHouse type name, with a neighbouring `String` column left untagged, and `output_format_arrow_unsupported_types = 'text'` in the command switches them to tagged `string` fields holding the text. Co-authored-by: Yakov Olkhovskiy <[email protected]>
…k-5dc0 Co-authored-by: Yakov Olkhovskiy <[email protected]>
`CHColumnToArrowColumn` materialized a default `FormatSettings` to serialize a
column with no Arrow mapping, so the payload ignored every setting the value's
serialization depends on. The native Arrow IPC writer passes the query's own
settings, so the two writers could encode the same value differently:
`output_format_binary_write_json_as_string = 1` produced the length-prefixed
`RowBinary` string in `FORMAT Arrow` and the plain binary `JSON` encoding over
Arrow Flight. `text` mode diverged the same way, for instance on
`output_format_json_quote_64bit_integers`.
The settings now travel with the conversion settings, and the Arrow Flight call
sites build both through one `arrowConversionSettings` helper instead of
repeating the initializer. `getFormatSettings` reads the whole profile, so the
per-block loop in `DoGet` resolves it once rather than once per block.
Verified against a local ClickHouse Arrow Flight server that both writers now
emit identical bytes:
output_format_binary_write_json_as_string = 0 -> 0101610A0100000000000000
output_format_binary_write_json_as_string = 1 -> 077B2261223A317D
output_format_json_quote_64bit_integers = 1 -> {"n":"12345678901234567890"}
Co-authored-by: Yakov Olkhovskiy <[email protected]>
`calculateArrowSchema` attached the `clickhouse.opaque` extension type only to the top-level field, while the container branches of `getArrowType` built their children with no metadata. `Array(JSON)`, `Tuple(j JSON)`, `Map(String, JSON)` and `Variant(..., JSON)` therefore reached an Arrow Flight client as plain `list<item: binary>` / `struct<j: binary>` / ... , where the native Arrow IPC writer tags those children, so a nested opaque value was indistinguishable from a genuine string or binary child on this path only. The container branches now build their children through `getArrowChildField`, which carries the tag when the child's ClickHouse type has no Arrow mapping. Arrow type equality ignores child field metadata, so the builder path that shares `getArrowType` is unaffected. Verified against a local ClickHouse Arrow Flight server that the two writers now produce the same schema for `Array(JSON)`, `Tuple(JSON)`, `Map(String, JSON)` and `Variant(String, JSON)`, down to the tag on `item`, `j`, `value` and the variant's `Object` alternative. Co-authored-by: Yakov Olkhovskiy <[email protected]>
The interface page still described the superseded boolean. It now covers the three values of `output_format_arrow_unsupported_types`, the `clickhouse.opaque` extension tag that lets a client tell such a column from a genuine `Utf8`/`Binary` one, and how the boolean maps onto the new setting. The rest of the user-facing documentation is generated: the per-setting page under `docs/reference/settings/formats/` comes from the `DECLARE` doc strings in `FormatFactorySettings.h`, and the settings tables on the `Arrow` and `ArrowStream` pages come from `setDocumentation` in `ArrowIPCBlockInputFormat.cpp`, both of which this branch already updates. Regenerating the docs tree against this build confirms those sources produce the intended pages, so the generated regions are left to the docs autogeneration workflow. Co-authored-by: Yakov Olkhovskiy <[email protected]>
|
Preview deployment for your docs. Learn more about Mintlify Previews.
|
|
@yakov-olkhovskiy I'm running into this now - I'm using |
…k-5dc0 Master opened a 26.9 settings-changes block while this branch was open, so the `output_format_arrow_unsupported_types` entry moves there - that is the release it now ships in. Co-authored-by: Yakov Olkhovskiy <[email protected]>
`format_settings` was the only member of `CHColumnToArrowColumn::Settings`
without one, so `-Wmissing-field-initializers` fired on the positional
aggregate initialization in `DeltaLake/WriteTransaction.cpp`, which lists only
the leading fields and relies on the rest defaulting. That is an error under
`-Werror` in the `arm_tidy` build:
WriteTransaction.cpp:121:9: error: missing field 'format_settings' initializer
[clang-diagnostic-missing-field-initializers,-warnings-as-errors]
Clang skips the diagnostic for a field that has an initializer, so spelling one
here also keeps any future field addition from breaking that caller.
Co-authored-by: Yakov Olkhovskiy <[email protected]>
…ed anchor
The `output_format_arrow_unsupported_types` heading is emitted into the
autogenerated region of `reference/settings/formats/output-format`, which this
branch deliberately leaves to the docs autogeneration workflow. Until that runs
the anchor does not exist in the committed tree, so `lychee --include-fragments`
rejected the link:
[ERROR] reference/settings/formats/output-format#output_format_arrow_unsupported_types
(at 399:198) | Cannot find fragment
Linking the page instead is stable regardless of when the reference pages are
regenerated, and the setting is already named in the sentence.
Co-authored-by: Yakov Olkhovskiy <[email protected]>
|
@dgieselaar not a workaround you missed, and not that nobody uses ArrowStream - it's a genuine gap - JSON has never been exportable over Arrow/ArrowStream. Before 26.5 you'd get a clean UNKNOWN_TYPE - 'JSON' is not supported for conversion into Arrow data format, and from 26.5 you get the much less obvious Method getDataAt is not supported for Object(...). Same outcome either way, so downgrading won't help you. output_format_arrow_unsupported_types_as_binary = 0 isn't a workaround either - it only replaces one exception with a clearer one. What does work today is casting the column in the query, since String maps to Arrow fine: If you're doing SELECT * and don't want to enumerate columns, REPLACE keeps the shape: On this PR: once it lands, a JSON column goes out without any query changes. The default (output_format_arrow_unsupported_types = 'binary') writes the RowBinary encoding, but for a product consuming ArrowStream you probably want: which gives you the JSON text in an Arrow Utf8 column - the same thing toJSONString produces, without the cast. Either way the field is tagged with the |
Two problems with how an opaque column is declared. `text` mode advertised every opaque column as Arrow `Utf8`, but `SerializationAggregateFunction::serializeText` writes the raw state bytes rather than text, so `sumState(toUInt64(128))` produced a `Utf8` column whose payload starts with `0x80` and is not valid UTF-8. The schema is written before any data, so this cannot be decided per value: an aggregate state now goes into a `Binary` column in either mode, in both writers. Every other type reaching this path (`JSON`, `Dynamic`, `QBit`, `BFloat16`) has a genuine text form and still gets `Utf8` in `text` mode. `DataTypeMap::isValidKeyType` rejects only nullable keys, so `Map(JSON, UInt8)` is a legal type, but the Arrow-library writer passed the key to `arrow::map` as a bare type and only the value went through `getArrowChildField`. The key field therefore carried no `clickhouse.opaque` tag, while the native IPC writer tags both children. The key is now built as a field too, via the `MapType` overload that takes both, which reproduces the previous layout - an `entries` struct of a non-nullable `key` and a `value` - with the tag added. The new coverage is a high-bit aggregate state and a `Map(JSON, UInt8)` in the stateless test for the native writer, and the same two over Arrow Flight in the integration test for the library-backed one. Co-authored-by: Yakov Olkhovskiy <[email protected]>
A column whose type has no Arrow mapping is written as an opaque column tagged `clickhouse.opaque`, and reading it back into that type has to undo the encoding the Arrow type names. That undo reached only a non-nullable column sitting at the top level of the batch. On the native reader it moves out of `decodeBatchColumn` into `reinterpretRawBytes`, the post-decode rewrite that already walks `Nullable`, `Array`, `Tuple` and `Map` alongside the requested type. `DecodedColumn` carries the schema field it was decoded from and the recursion threads each child's own field down, so a leaf reads the tag that belongs to it. A `Nullable` root and a constant column, both excluded before, are covered by the same move. On the Apache-Arrow-library reader the `LIST`, `MAP` and `STRUCT` branches passed the parent `arrow::Field` into the child read, where the child's metadata never is. They now pass the child's own field. Parquet and ORC are unaffected: `output_unsupported_types` defaults to `THROW` and only Arrow Flight sets it, so neither writes an opaque column in the first place. Co-authored-by: Yakov Olkhovskiy <[email protected]>
…o cursor/fix-arrow-unsupported-types-fallback-5dc0 # Conflicts: # src/Core/SettingsChangesHistory.cpp Co-authored-by: Yakov Olkhovskiy <[email protected]>
| std::string field_name = column_variant_type.getVariant(i)->getFamilyName(); | ||
| fields.push_back(std::make_shared<arrow::Field>(field_name, arrow_type, is_column_nullable)); | ||
| fields.push_back(getArrowChildField( | ||
| field_name, column_name, column_variant_type.getVariant(i), variant, format_name, settings, for_builder)); |
There was a problem hiding this comment.
The write side now tags opaque Variant alternatives distinctly, but the native IPC reader still never consumes that information inside unions. RecordBatchDecoder::decodeUnion decodes every child with target_hint = nullptr and fieldToCHType(child, ...) (src/Processors/Formats/Impl/ArrowIPC/RecordBatchDecoder.cpp:1479-1509), so an alternative tagged clickhouse.opaque = JSON is still treated as plain String.
That makes valid round-trips fail today. The simplest repro is Variant(JSON, String): in either mode, both union children map to String, DataTypeVariant deduplicates them, and read-back fails with Arrow IPC union has multiple children mapping to the same ClickHouse type. Even when the other alternatives are distinct, binary mode still falls back to the old String -> CAST route because the post-pass never descends through ColumnVariant.
Could we thread the requested Variant alternatives through decodeUnion (or add an equivalent post-pass for ColumnVariant) before treating Variant as covered by the new opaque round-trip support?
There was a problem hiding this comment.
Both repros are real — I reproduced them exactly, including the Variant(JSON, String) deduplication error. The last sentence is the right ask, and I have taken it as written down rather than papered over: d949874 states the limitation in the setting description, so Variant is no longer implied to be covered.
What the measurements say about where the gap is. It is not specific to binary, and not specific to this PR's reader work — text fails identically:
| type | binary |
text |
|---|---|---|
Variant(JSON, String) |
INCORRECT_DATA, union deduplication |
same |
Variant(JSON, UInt64) |
CANNOT_CONVERT_TYPE, Variant(String, UInt64) -> Variant(JSON, UInt64) |
same |
Variant(QBit(BFloat16, 3), UInt64) |
CANNOT_CONVERT_TYPE |
same |
Variant(String, UInt64) |
round-trips | round-trips |
So a Variant with an alternative that has no Arrow mapping does not round-trip in any mode, and it fails loudly in every case — there is no silent corruption of the kind this PR fixes for inline columns, where a Dynamic absorbed the encoding's tag and length bytes into its value. It is also not a regression: before this PR the write side could not produce such a file at all, because the getDataAt fallback threw on the union's JSON child.
On fixing it here rather than following up. decodeUnion derives each child's type from fieldToCHType with no hint, so a tagged child would need the requested Variant's alternatives threaded in, and the type has to be settled inside decodeUnion — the deduplication check runs there, before any post-pass could descend through ColumnVariant. That part is tractable. The problem is symmetry: ArrowColumnToCHColumn has no union handling at all, so an Arrow union never becomes a Variant over Arrow Flight in the first place. Making Variant round-trip properly therefore means implementing union decoding in the library reader too, which is a feature in its own right and unrelated to what this PR is fixing. Doing it only in the native reader would leave the two readers disagreeing about Variant, which seems worse than a documented gap.
Happy to open a follow-up issue for union decoding across both readers if you would like it tracked.
There was a problem hiding this comment.
Yes, please track this separately. The docs now narrow the promise enough that I would not block this PR on Variant, but Variant(..., JSON/QBit/...) is still a user-visible gap that will be easy to rediscover without a follow-up issue.
An Arrow union is decoded without consulting the `clickhouse.opaque` tags its children carry, so a `Variant` with an alternative that has no Arrow mapping writes fine but does not read back into the same `Variant`. It fails the same way in `text` and in `binary`, so this is a property of union decoding rather than of either encoding, and the data written stays well formed for other Arrow readers. Say so in the setting description instead of leaving it to be discovered. Also record why the dictionary rewrite passes no field: a dictionary is how a `LowCardinality` is written, and that wraps only numbers, strings, `Date` and `DateTime`, each of which has an Arrow type of its own, so a dictionary's values are never an opaque column. Co-authored-by: Yakov Olkhovskiy <[email protected]>
`StorageArrowFlight.cpp` already included it, so the one added for `getArrowUnsupportedTypesMode` was a second copy and `readability-duplicate-include` failed the tidy build. https://s3.amazonaws.com/clickhouse-test-reports/praktika.html?PR=115250&sha=d9498748a0eb5a6e47c32e03e2b222dcc8a7ee59&name_0=PR&name_1=Build%20%28arm_tidy%29 #115250 Co-authored-by: Yakov Olkhovskiy <[email protected]>
The previous wording read as though the tag alone were enough. It is not: neither schema-inference path consults it, so a column read without a type named for it arrives as `String` holding the raw payload, unchanged from before. Only a read that already knows the type - from a table's declaration or from a structure argument - recovers it. Co-authored-by: Yakov Olkhovskiy <[email protected]>
Resolve the conflicts in ArrowFlightServer.cpp: 26.9 does not have #115250, #125534 and #125553, which changed the same lines (conversion settings, the `block.empty()` check in `DoGet`, `removeSpecialColumnRepresentations`), so their changes are left out and only #129193's lines are kept. Leave out 05497_arrowflight_exception_on_query_finish: 26.9 has no Arrow Flight port in the stateless test config (#125517 is master-only), so the test cannot connect there. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Resolve the conflicts in ArrowFlightServer.cpp: 26.8 does not have #115250, #125534 and #125553, which changed the same lines (conversion settings, the `block.empty()` check in `DoGet`, `removeSpecialColumnRepresentations`), so their changes are left out and only #129193's lines are kept. Leave out 05497_arrowflight_exception_on_query_finish: 26.8 has no Arrow Flight port in the stateless test config (#125517 is master-only), so the test cannot connect there. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Closes: #115023
Caused by: #91170
The
output_format_arrow_unsupported_types_as_binaryfallback wrote a column with no first-class Arrow mapping by callingIColumn::getDataAtper row. That method exposes a column's contiguous in-memory bytes, which most of the types reaching the fallback do not have:ColumnObject(JSON),ColumnVariant(henceColumnDynamic) andColumnQBitthrowMethod getDataAt is not supported, soSELECT ... FORMAT Arrowfailed on them — after the schema message had already been written, leaving the client with a truncated stream;ColumnAggregateFunction::getDataAtreturns theAggregateDataPtritself, so exporting an aggregate state silently wrote raw heap addresses instead of the state, both corrupting the data and disclosing server addresses.Before the fallback existed these types were rejected with a clear
UNKNOWN_TYPE, so both are regressions introduced together with the setting:The fallback now serializes each value through
ISerialization, whoseserializeText/serializeBinaryare pure virtual and therefore defined for every type, so the "do not fail aSELECT *" property that motivated the setting holds by construction instead of depending on an unrelated method's implementation status.output_format_arrow_unsupported_types(throw/text/binary) replaces the boolean, adding atextmode that writes whatCAST(col AS String)would produce — useful for the BI clients that driveSELECT *over Arrow Flight SQL, and the workaround users had to apply by hand forJSON. Its default,binary, is the previous behavior, and itsSettingsChangesHistoryentry has identical previous and new values socompatibilitynever marks it changed. The boolean keeps working with full effect (0meansthrow,1meansbinary) and is only consulted while the new setting is left at its default, so an explicit mode wins whichever order the two are set in.The Arrow type states the encoding
An opaque column is tagged with the
clickhouse.opaqueArrow extension name and the original ClickHouse type name inARROW:extension:metadata, so a consumer can tell it apart from a genuine string or binary column. Per the Arrow extension-type convention a reader that does not know the extension name ignores the metadata and sees the plain storage type, so no existing consumer changes behavior. Nested children are tagged on their own field, including anArray(JSON)element, aTuplemember, aVariantalternative, and both the key and the value of aMap(JSON, ...).Alongside the name, the Arrow type says which of the two encodings the payload is:
Utf8is the text form andBinaryisserializeBinary.output_format_arrow_string_as_stringdeliberately does not apply to these columns — it governs only realStringandFixedStringones, as its description says — because letting it move an opaque column would park a text payload in aBinarycolumn and leave a reader unable to tell the two apart.That is what lets both readers recover the original type. They used to turn such a column into a
Stringand leave the caller toCASTit, which is the text parser, so only the text form ever survived: withbinary— the default —JSONandQBitfailed to parse, and aDynamiccame back silently wrong, holding the encoding's own type tag and length prefix inside its value (42::Dynamicwrote3432and read back as15023432, still reportingStringand still printing42, because the two extra bytes are not printable). Each reader now checks for aBinarycolumn tagged with the type being asked for, and deserializes it withdeserializeBinary. Everything else takes the route it took before — an untagged column, a tag naming a different type, or a read that asks forStringand gets the raw bytes.Both readers walk the schema fields alongside the requested type, so a leaf reads the tag on the field that owns it rather than one belonging to an enclosing container: a
Nullableroot, anArrayelement, aTuplemember and aMapvalue all recover their type. In the native reader this is the post-decode rewrite that already descends through those shapes, and in the Apache-Arrow-library one the container branches pass each child's ownarrow::Fielddown. A row whose bytes Arrow leaves undefined, because it is null at the leaf or at any enclosing level, decodes as the type's default instead of being fed todeserializeBinary.An alternative of a
Variantis the one shape that does not read back, and the setting description says so. The Arrow union its alternatives form is decoded without consulting the tags, so such aVariantfails on read — identically intextand inbinary, and loudly rather than silently. It is not a regression, since before this change the write side could not produce such a file at all: thegetDataAtfallback threw on the union's child. Closing it means threading the requested alternatives through the native decoder'sdecodeUnionand implementing union decoding in the Apache-Arrow-library reader, which has none today, so it belongs in its own change rather than here.Text and UTF-8
An
AggregateFunctioncolumn stays an ArrowBinarycolumn even intextmode: itsserializeTextwrites the raw aggregate state, which is not valid UTF-8, and an ArrowUtf8column must hold valid UTF-8. The schema is written before any data, so this cannot be decided per value.For the same reason, a value written into a
Utf8column has each invalid UTF-8 sequence replaced by U+FFFD. Only a payload that is already not valid text changes — aDynamicholding aStringof arbitrary bytes, for example. AJSONcolumn cannot reach this at all: its parser rejects invalid UTF-8 on every input path, soCAST(map('k', unhex('FF')), 'JSON')and the equivalentJSONEachRowinsert both fail withINCORRECT_DATA. RealStringandFixedStringcolumns are untouched and keep writing raw bytes intoUtf8exactly as before — this affects only the types whose representation the setting invents, which today either throw or emit heap addresses.The substitution goes through
writeValidUTF8, which is whysrc/Functions/toValidUTF8.cppappears in the diff.WriteBufferValidUTF8is a streaming filter and stages into 4 KiB of its own memory so that a multi-byte sequence split across two writes can be carried to the next one; a caller holding the whole value has no such sequence, so that allocation was pure overhead — one per value, to replace a byte or two.toValidUTF8already contained a one-shot form of the same algorithm that allocates nothing, so it moved tosrc/IO/writeValidUTF8.{h,cpp}and both use it. Writing 5M invalid one-byte values throughFORMAT ArrowStream, against a 0.250 s baseline where every value is valid: 0.770 s with the 4 KiB buffer, 0.701 s sized to the value, 0.343 s with no buffer at all.One consequence is worth stating explicitly: an aggregate state held in a
Dynamicis lossy intextmode. The carve-out above reads the column's declared type, andDynamicsays nothing about what its rows hold, so the state cannot be given aBinarycolumn of its own.binarymode keeps it whole, and aVariantis unaffected because it lists its alternatives, so anAggregateFunctionamong them gets its ownBinarychild.Both writers
The native Arrow IPC writer behind
FORMAT Arrow/ArrowStreamand the Apache-Arrow-library one behind Arrow Flight SQL both make the accept/reject decision in the schema converter, before the schema message is written, so a rejected type can no longer abort a stream whose schema the reader has already accepted. Both serialize the values with the query's ownFormatSettings, so a setting the serialization depends on (output_format_binary_write_json_as_string,output_format_json_quote_64bit_integers, …) produces the same payload whichever writer serves the query. When a type is rejected, the exception names the column the query used rather than the Arrow field name a container gives its child (item,key,value), and says which setting accepts it.Parquet and ORC are unaffected.
CHColumnToArrowColumn::Settings::output_unsupported_typesdefaults toTHROWand Arrow Flight is its only caller, so neither format writes an opaque column and Parquet still rejectsQBitwithUNKNOWN_TYPEexactly as before.Arrow Flight otherwise pins the canonical Arrow mapping and deliberately does not follow the remaining
output_format_arrow_*settings, because the same conversion builds the Flight SQL metadata responses whose schemas the specification fixes, and because a Flight client fetches the schema and the data in separate calls. That is now stated onarrowConversionSettingsand documented on the Arrow Flight interface page, along with the fact thatCreatePreparedStatement'sdataset_schemais a best guess — the specification says clients must not assume it is accurate, and in ClickHouse it can differ both because inference substitutesNULLfor each?and because the Arrow mode is resolved per call.StorageArrowFlight::ArrowFlightSinkbuilt its converter settings from scratch and never consulted the setting, so it always used the rejecting struct default. It now resolves the mode from the query context like the other Arrow Flight call sites.Verified against a local ClickHouse Arrow Flight server as well as
FORMAT Arrow. AQBitcolumn in anENGINE = ArrowFlighttable now round-trips in the defaultbinarymode, where the insert previously failed;JSON,Dynamic,QBitandAggregateFunctionall read back byte-identical to the originals through anArrowStreamfile in both modes; aDynamicholdingok\xc3(tailarrives asok\ufffd(tailin astringcolumn whilebinarykeeps the original bytes; and reading an opaque column without a requested type still yields the raw bytes asString. Nested and nullable shapes round-trip as their exact types:Nullable(JSON),Nullable(QBit),Array(JSON),Tuple(x JSON)andMap(String, JSON)through anArrowStreamfile, with JSON subcolumn access working on the result, andQBitinsideArray,TupleandNullableover Arrow Flight.The reader change was diffed against the pre-change binary over the arrow, parquet, orc and utf8 suites: the same 48 of 456 fail either way, none of them Arrow. Because the library reader also serves Parquet, where the field metadata it now threads through containers is what
JSONandUUIDdetection reads, that part was diffed separately against a baseline binary over nestedJSONandUUIDParquet round trips, with schema inference and with explicit types — byte-identical.Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):
Fixed
SELECT ... FORMAT Arrowfailing withMethod getDataAt is not supportedforJSON,DynamicandQBitcolumns, and silently exporting heap addresses instead of the aggregate state forAggregateFunctioncolumns. Added theoutput_format_arrow_unsupported_typessetting (throw/text/binary, defaultbinary) which supersedesoutput_format_arrow_unsupported_types_as_binary. Such columns can now also be read back into their original type, which previously failed or silently corrupted the value.INSERT INTO ... ENGINE = ArrowFlightnow follows this setting too; it previously rejected such columns unconditionally, so an insert that used to fail may now write an opaque column — setoutput_format_arrow_unsupported_types = 'throw'to keep rejecting it.Workflow [PR]
Sync PR [sync-upstream/pr/115250]
Version info
26.10.1.54(included in26.10and later)