Repository navigation
Conversation
76b3e98 to
dfec54b
Compare
This setting helps prevent silent data loss during named tuple conversions. When enabled, it throws an exception if any fields would be dropped during the conversion process. This makes it easier to catch potential data loss issues, especially in INSERT-SELECT operations. Example: ```sql (1 as a2, 2 as b2)::Tuple(a int, b int) -- Would fail with setting enabled ```
This reverts commit 1d9a957.
|
I haven't forgotten about this issue, no need to rebase or anything, but I need to think about different approaches to solve the problem. |
|
Dear @Algunenano, this PR hasn't been updated for a while. You will be unassigned. Will you continue working on it? If so, please feel free to reassign yourself. |
|
Dear @Algunenano, this PR hasn't been updated for a while. You will be unassigned. Will you continue working on it? If so, please feel free to reassign yourself. |
|
🕵 Merged
@groeneai, thanks for #123699 (the DNS cache race in The three open review threads are unchanged. Each needs a maintainer decision on compatibility: the insert guard for named tuples nested in containers in |
…che update `DNSResolver::dropCache` cleared `cache_host` and `cache_address` before taking `update_mutex`. The periodic `updateCache` holds `update_mutex` while it refreshes every known host and address, and `updateHost`/`updateAddress` end with an unconditional `CacheBase::set`, so a drop that landed during an update had its cleared entries put back; it then waited for the update, cleared only `known_*`/`new_*`, and returned with a non-empty cache. This made `test_host_regexp_multiple_ptr_records::test_reverse_dns_profile_events` flaky (`assert 7 > 7` on `DNSReverseRequests`): `SYSTEM CLEAR DNS CACHE` ran inside an update cycle, the PTR answer for the client was re-inserted before the statement returned, and the following access check was a cache hit. Clear both caches inside the existing `scoped_lock(update_mutex, drop_mutex)`. The drop already waited on `update_mutex`, so its latency is unchanged. The new gtest runs `updateCache` in a single updater thread (the server has exactly one, `DNSCacheUpdater`; two concurrent `updateCache` callers would race on `known_hosts`), waits until the updater has refreshed the entry, then drops the cache and checks it is empty. Without the fix it fails in every repetition. Requested in ClickHouse#71030 (comment) Co-Authored-By: Claude Opus 5.5 <[email protected]>
Conflicts: - `resolveFunction.cpp`: keep master's `ARRAY[x]` rewrite before the PR's named `tuple` rewrite. - `tuple.h`: keep master's documentation-only `getSignatureString` and route both `getReturnTypeImpl` overloads to the PR's parameter-aware implementation. - `InterpreterInsertQuery.cpp`: keep the PR's insert guard and master's `getEffectiveMaxThreads`. - `KeyCondition.cpp`: apply the PR's `recursiveRemoveTupleElementNames` to master's `mapping.key_expr_type`.
…fields` in `FunctionConvertSettings::updateHash` A strict and a permissive cast of the same types must not share a hash, as it feeds `ActionsDAG` and other cache keys. Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
🕵 Merged The only red on the previous head was The three other open threads (strict insert semantics for nested containers in |
The `settings_changes_history` style check requires changes made now to be recorded under the current version `26.11`. https://s3.amazonaws.com/clickhouse-test-reports/praktika.html?PR=71030&sha=016cfbb1c145ed4d52cff842ebc309c4a5ce49cf&name_0=PR&name_1=Style%20check ClickHouse#71030 Co-Authored-By: Claude Opus 5.5 <[email protected]>
…m master The branch rewrote the queries of this test to request the full tuple structure. For `array_tuple_column` and `map_tuple_column`, the element `c` is stored in the file as `Nullable(Int64)`, but the queries asked for `c Tuple(i UInt32, j UInt32)`, so both the reference and the patched server failed with `CAST AS Tuple can only be performed between tuple types or from String`. The original queries that read only the `a` subfield work with this branch, so there is no reason to diverge from master. https://s3.amazonaws.com/clickhouse-test-reports/praktika.html?PR=71030&sha=70428270d2033297b1fd7dad08e2c6426b3a5a0e&name_0=PR&name_1=Performance%20Comparison%20%28arm_release%2C%20master_head%2C%204%2F6%29 ClickHouse#71030 Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
🕵 Fixed the red
The three open review threads and the change request from 2024 still need a maintainer's decision on strict insert semantics:
I made no code change for those. |
# Conflicts: # tests/queries/0_stateless/00309_formats.sql # tests/queries/0_stateless/04338_tuple_inside_nullable_null_carrying_elements.sql
Master removed `enable_analyzer` from tests in 71b0310 because the old query analysis is gone and the setting is frozen at `1`. Drop it from the tests touched by this PR as well. Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
🕵 Merged The three open review threads still need a maintainer decision, as explained in the earlier replies: strict insert semantics for named tuples nested in containers, enforcing the insert guard in null-context schema casts ( |
|
🕵 Merged The only red on the previous head is The three open review threads still need a maintainer decision, as explained in the replies there: strict insert semantics for named tuples nested in containers, enforcing the insert guard in null-context schema casts ( |
|
🕵 Merged The three open review threads still need a maintainer decision, as explained in the replies there:
|
…ansforms `convertColumnForDeterministicDag` cast set elements and constants to the still-named `dag.input_type`, so a `Tuple(b, a)` element was reordered by name before `sipHash64(v)` was applied, while `IN` and `equals` compare tuple elements positionally. The index then pruned rows that satisfy the predicate, for `PARTITION BY sipHash64(v)` and `ORDER BY sipHash64(v)` alike. Cast to the name-less input type and relabel the result with the type the DAG was built against (the column layout is identical). Co-Authored-By: Claude Opus 5.5 <[email protected]>
The style check now rejects plain `std::unordered_map` and `std::vector` in `src/Processors`. Replace them with `UnorderedMapWithMemoryTracking` and `VectorWithMemoryTracking` in the named tuple reordering helpers. https://s3.amazonaws.com/clickhouse-test-reports/praktika.html?PR=71030&sha=34b6ca75fd7f7cb31c83db630822d4b8b7e5deab&name_0=PR&name_1=Style%20check ClickHouse#71030 Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
🕵 Fixed the red The
|
# Conflicts: # src/Interpreters/InterpreterInsertQuery.cpp
|
🕵 Merged The only red check on the previous head was the gate for unresolved review threads in
|
Conflicts resolved: - `src/Analyzer/Resolve/resolveFunction.cpp`: keep the rewrite of `tuple(x AS a, ...)` into the parametric form before the new `__compose` and `groupConcat` handling from master. - `src/Functions/FunctionsConversion.cpp`: master moved the tuple element mapping into `getTupleCastElementPositions`; the `allow_named_tuple_conversion_with_extra_source_fields` guard is re-applied on top of that mapping. - `src/Functions/tuple.h`: keep the parametric `FunctionTuple`, with the `[[nodiscard]]` attributes from master. - `src/Interpreters/InterpreterInsertQuery.cpp`: keep the two named-tuple settings, drop the settings master no longer uses there. - `src/Interpreters/Set.cpp`: master moved the key cast into `Set::castToKeyType`; the positional (name-agnostic) tuple cast is re-applied there. Co-Authored-By: Claude Fable 5.2 <[email protected]>
The `26.11` release branch has been created, so the settings history entries of `enable_named_columns_in_function_tuple`, `allow_named_tuple_conversion_with_extra_source_fields` and `allow_named_tuple_conversion_with_extra_source_fields_on_insert` must refer to `26.12`, the version where they will appear. Co-Authored-By: Claude Fable 5.2 <[email protected]>
…eted `VALUES` path
The interpreted `VALUES` path (`input_format_values_deduce_templates_of_expressions = 0`, or an expression the template cannot handle) reordered a named tuple only when the source and the destination had exactly the same set of names. With partially overlapping names it fell back to the positional `convertFieldToType`, so with `allow_named_tuple_conversion_with_extra_source_fields_on_insert = 1` the value `tuple('b2', 'a')(1, 2)` inserted into `Tuple(a Int32, b Int32)` was stored as `(1, 2)`, while the expression template path and `INSERT ... SELECT` store `(2, 0)`. A non-lossy schema expansion (`Tuple(b, a)` into `Tuple(a, b, c)`) was rejected, and named tuples inside `Array`, `Map` and `Nullable` were converted positionally and bypassed the insert guard.
Now the value is brought to the destination layout with the same mapping as `CAST` (`tryGetTupleCastElementPositions`): matched by name when both sides are named and have a name in common, dropping unmatched source elements and filling unmatched destination elements with defaults, and by position otherwise. The conversion and the guard descend into tuples, `Array`, `Map` and `Nullable`.
Co-Authored-By: Claude Fable 5.2 <[email protected]>
Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes to CHANGELOG.md):
INSERTinto namedTuplecolumns now rejects by-name tuple conversions that would drop source fields by default. Setallow_named_tuple_conversion_with_extra_source_fields_on_insert = 1to keep the previous permissiveINSERTbehavior, orallow_named_tuple_conversion_with_extra_source_fields = 0to reject such conversions for every query, not only forINSERT. Named tuples whose element names are fully disjoint from the destination are converted positionally and are unaffected. This helps #70830 and implements #70853 (comment).Example:
This PR also introduces explicit named-tuple syntax in the
tuplefunction:It works regardless of the analyzer, and it fixes incorrect reuse of named tuple metadata in distributed queries: when the same tuple expression is used with different logical names, AST-level reuse must be prevented, otherwise element names can be mixed up. In non-initial (distributed) queries aliases are not preserved, so names cannot be reliably reconstructed later.
Documentation entry for user-facing changes
CI Settings (Only check the boxes if you know what you are doing):
Workflow [PR]
Sync PR [sync-upstream/pr/71030]