hello-stephen commented on code in PR #71337:
URL: https://github.com/apache/doris/pull/71337#discussion_r4794501795
##########
be/test/format_v2/parquet/parquet_reader_test.cpp:
##########
@@ -3545,6 +3601,123 @@ TEST_F(NewParquetReaderTest,
ShreddedVariantPredicateUsesTypedLeafPageIndexWithR
EXPECT_GT(profile.get_counter("VariantReconstructionTime")->value(), 0);
}
+TEST_F(NewParquetReaderTest, PrunesNestedVariantWithNonEmptyAncestorResidual) {
+ _file_path = (_test_dir / "nested_variant_pruning.parquet").string();
+ ASSERT_NO_FATAL_FAILURE(write_nested_variant_pruning_file(_file_path));
+
+ using Row = std::pair<int32_t, std::string>;
+ auto scan = [&](bool narrow, bool pruning, std::vector<Row>* result) {
+ SCOPED_TRACE(pruning);
+ RuntimeProfile profile("nested_variant_pruning");
+ RuntimeState state {TQueryOptions(), TQueryGlobals()};
+ auto reader = create_reader(0, -1, &profile);
+ ASSERT_TRUE(reader->init(&state).ok());
+ std::vector<format::ColumnDefinition> schema;
+ ASSERT_TRUE(reader->get_schema(&schema).ok());
+ ASSERT_EQ(schema.size(), 2);
+
+ auto request = std::make_shared<format::FileScanRequest>();
+ request->non_predicate_columns.push_back(
+
format::LocalColumnIndex::top_level(format::LocalColumnId(schema[0].local_id)));
+ auto projection =
+
format::LocalColumnIndex::top_level(format::LocalColumnId(schema[1].local_id));
+ if (narrow) {
+ projection =
format::LocalColumnIndex::partial_local(schema[1].local_id);
+ const format::ColumnDefinition* field = &schema[1];
+ auto* projected = &projection;
+ for (std::string_view name : {"typed_value", "a", "typed_value",
"b"}) {
+ const auto child =
+ std::ranges::find(field->children, name,
&format::ColumnDefinition::name);
+ ASSERT_NE(child, field->children.end());
+ field = &*child;
+ projected->children.push_back(
+
format::LocalColumnIndex::partial_local(field->local_id));
+ projected = &projected->children.back();
+ }
+ const auto typed = std::ranges::find(field->children,
"typed_value",
+
&format::ColumnDefinition::name);
+ ASSERT_NE(typed, field->children.end());
+
projected->children.push_back(format::LocalColumnIndex::local(typed->local_id));
+ }
+ request->predicate_columns.push_back(std::move(projection));
+
request->local_positions.emplace(format::LocalColumnId(schema[0].local_id),
+ format::LocalIndex(0));
+
request->local_positions.emplace(format::LocalColumnId(schema[1].local_id),
+ format::LocalIndex(1));
+ request->conjuncts.push_back(
+ create_variant_int32_path_greater_than_conjunct(1, {"a", "b"},
95));
+ request->metadata_pruning_safe_conjunct_count = pruning ? 1 : 0;
Review Comment:
[P2] Exercise a nested Variant predicate that SQL can pass to pruning
This test sets `metadata_pruning_safe_conjunct_count` by hand. In a normal
scan, `TableReader` excludes `CAST(v['a']['b'] AS INT) > 95` from that prefix
because `VCastExpr` is unsafe for selected-row evaluation. An implicit scalar
comparison inserts the same `CAST`, and `extract_variant_shredded_predicate`
only unwraps `CAST_EXPR`, so `TRY_CAST` cannot use this path either. Both
metadata passes therefore retain the groups and pages that this test shows as
pruned. Please route a proven-safe SQL predicate through `TableReader` and
assert footer and page pruning without overriding the prefix. Preserve the
existing error-order guard for ordinary casts.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]