Repository navigation
Keep row policy input columns in the header of file-like reads - #122714
Conversation
…WHERE Without PREWHERE, `StorageFile::read` does not apply the row-level filter to the format header, so the input columns of the row policy stay in the output header of `ReadFromFile`. When `optimizePrewhere` added PREWHERE, `ReadFromFile::updatePrewhereInfo` also applied the row-level filter, and the header lost these columns. There were two effects: - `optimizePrewhere` built the step above the read from a DAG that was made for the old header, so the DAG had an input that the new header did not have. `optimizeLazyMaterialization` failed on it with a `LOGICAL_ERROR` exception, which 908a3e3 made tolerated. - A `DEFAULT` column computed from a row policy input failed with `UNKNOWN_IDENTIFIER`, because `StorageFileSource` computes defaults after the format applied the filter. Now the row-level filter is never propagated into `ReadFromFormatInfo` of `ReadFromFile`. The source still applies it through `FormatFilterInfo`. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
…on optimizer" This reverts commit 908a3e3. The dangling input came from the `ReadFromFile` header change on PREWHERE, which is fixed now. A DAG input without a header column is a bug again. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
…torage reads `IStorageURLBase::read`, `StorageURLWithFailover::read` and `StorageObjectStorage::read` applied the row-level filter to the format header, also without PREWHERE, so the input columns of the row policy were removed. A `DEFAULT` column computed from such a column failed with `UNKNOWN_IDENTIFIER`, because the source computes defaults after the format applied the filter. Now the row-level filter is never part of `ReadFromFormatInfo`: the `row_level_filter` field and the parameter of `updateFormatPrewhereInfo` are removed. The sources still apply the filter via `FormatFilterInfo`. The fallback `FilterTransform` in `StorageObjectStorageSource` (for data files whose format does not support PREWHERE) keeps the input columns of the row-level filter as well. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
|
Workflow [PR], commit [c732c77] Summary: ✅
AI ReviewSummaryThis PR removes row policies from Findings❌ Blockers
Final VerdictStatus: ❌ Block Minimum required actions:
LLVM Coverage ReportMeasured on commit c732c77.
Changed lines: Changed C/C++ lines covered: 101/111 (90.99%) · Uncovered code |
Build profile diff (arm_release)Comparing ✅ No significant changes. Binary sizes
The official master build is compiled with Compile time of recompiled translation units127 translation units recompiled, 1176 s compile time in total, 127 of them have a recent master baseline. |
…ilter For data files whose format does not support PREWHERE (ORC files in an Iceberg table with format `Parquet`), `StorageObjectStorageSource` applies the row policy with a `FilterTransform`. Adding the inputs to the outputs of the DAG did not prevent `FilterTransform` from removing the filter column. For `USING a`, the filter column is the input `a`, so `a` was removed and the query failed with `NOT_FOUND_COLUMN_IN_BLOCK`. Now the DAG is built again with `cloneSubDAG` from the filter node, with aliases removed. If the filter node is an input, the filter column is not removed. Otherwise it is an output. All inputs are outputs as well. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
| else | ||
| row_level_outputs.push_back(row_level_filter_node); | ||
|
|
||
| row_level_outputs.insert(row_level_outputs.end(), row_level_dag.getInputs().begin(), row_level_dag.getInputs().end()); |
There was a problem hiding this comment.
Rebuilding the fallback row-policy actions from cloneSubDAG({&filter_node}) drops the original DAG's pass-through outputs. cloneSubDAG only keeps the policy's dependencies, and then this code re-exports only those inputs, so any selected column that the policy does not reference disappears from the declared header. In the mixed-format fallback path that breaks queries like SELECT k FROM t with USING a: the original FilterDAGInfo preserved k for pipeline compatibility, but this rebuilt DAG does not, so ExtractColumnsTransform / later stages no longer see k.
There was a problem hiding this comment.
This is not true. Columns that are not inputs are pass-through by default.
A test was added to verify this case works.
For files that do not support `PREWHERE` (ORC files of an Iceberg table with format `Parquet`), the source applies the row policy after the reader. The columns that the policy does not use must stay in the block, in any order of the selected columns, for a policy that is an input (`USING a`) and for a function (`USING a > 0`). Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
…column
When the filter column of a split filter has the same name as an input,
`ActionsDAG::split` renames it in the first half, and the second half
reads it through an input under the new name, with an alias back to the
old one. `trySplitFilter` then called `removeUnusedResult` with the old
name, which removed only the alias. The filter step stopped outputting the
column, and the second half kept an input with no column in the header.
Removing unused columns rejects such an input with a logical error:
The header [_CAST(NULL_Nullable(Nothing), 'Nullable(Nothing)'_String)]
has a column for only 1 of the DAG's 2 inputs
Now the renamed input is removed as well, and should the second half still
read it, the filter step keeps the column.
Found by the AST fuzzer in the stress test:
SELECT x FROM (SELECT arrayJoin([1]) AS x GROUP BY NULL WITH TOTALS) WHERE NULL
INTERSECT DISTINCT SELECT DISTINCT 1
CI: https://s3.amazonaws.com/clickhouse-test-reports/praktika.html?PR=122952&sha=79586cd61a93fb2471e94dd87e8a93349f0e7172&name_0=PR
PR: #122952
Related: #122714
Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Claude
A row policy on
File,URLand object storage tables (S3, data lakes) removed its input columns from the header of the reading step. There were two effects:ReadFromFileapplied the row policy to its header only when PREWHERE was set. WhenoptimizePrewheremoved aWHEREto PREWHERE, the header lost the policy inputs, but the step above the read kept a DAG input for them. The lazymaterialization optimizer failed on this input with a
LOGICAL_ERRORexception. Lazy materialization for reading local Parquet files (file/File) #114262 made it tolerate such inputs (908a3e3). This PR reverts that change, because the input no longeroccurs.
DEFAULTcolumn computed from a policy input failed withUNKNOWN_IDENTIFIER, because the source computes defaults after the format applied the row policy. ForFile, this happened with PREWHERE. ForURLandS3, it happenedalways.
Now a row policy is never part of
ReadFromFormatInfoand never changes its headers. The sources still apply it viaFormatFilterInfo.Related: #114262
Related: #122682
Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):
Fix
UNKNOWN_IDENTIFIERfor aDEFAULTcolumn that depends on a column used by a row policy, in tables with theFile,URL,S3and other object storage engines.Workflow [PR]
Sync PR [sync-upstream/pr/122714]
Version info
26.10.1.1085-master(included in26.10and later)