Gabriel39 commented on code in PR #71397:
URL: https://github.com/apache/doris/pull/71397#discussion_r4793562218
##########
be/src/format_v2/orc/orc_reader.cpp:
##########
@@ -2205,7 +2292,9 @@ Status OrcReader::_select_stripe_ranges_by_statistics() {
int64_t filtered_bytes = 0;
for (const auto stripe_index : split_stripes) {
bool drop = false;
- if (sarg_needed_stripes[stripe_index - split_stripes.front()] == 0) {
+ // An unsafe DATE must reach decoding, preserving strict errors or
conversion-generated NULLs.
+ if (!unsafe_date_stripes.contains(stripe_index) &&
Review Comment:
Fixed in 0b1a2ea661. Projected DATE eligibility is collected even with SARG
pruning disabled. Cached false granules cannot skip unsafe or unproven DATE
ranges; explicit safe file bounds retain normal cache use. Cold/warm
lazy-to-eager tests pass with pruning enabled and disabled. The parallel
permissive-to-strict Parquet cache bypass is fixed too, and a targeted revert
makes its new test fail with both plain and dictionary encoding.
I also checked the exact pinned ORC SDK
d88650dcd09bf51907a68c0172052869b268002a locally: it caches a borrowed SARG
applier and consumes it when constructing a RowReader. Cleanup readers remain
necessary to discard that cache while its options live; they now contribute to
OrcRowReadersCreated.
##########
be/src/format_v2/parquet/parquet_reader.cpp:
##########
@@ -1216,6 +1216,56 @@ Status ParquetReader::get_aggregate_result(const
format::FileAggregateRequest& r
}
const auto& count_projection = request.columns[0].projection;
const auto& root_schema = projected_root_schema(_state->file_schema,
count_projection);
+ std::vector<const ParquetColumnSchema*> date_leaves;
+ if (_state->enable_strict_mode ||
+ remove_nullable(root_schema.type)->get_primitive_type() ==
TYPE_DATEV2) {
+ const auto collect_dates = [&](auto&& self, const
ParquetColumnSchema& schema,
+ const format::LocalColumnIndex*
projection) -> void {
+ if (schema.kind == ParquetColumnSchemaKind::PRIMITIVE) {
+ if (remove_nullable(schema.type)->get_primitive_type() ==
TYPE_DATEV2) {
+ date_leaves.push_back(&schema);
+ }
+ return;
+ }
+ for (const auto& child : schema.children) {
+ if (format::is_child_projected(projection,
child->local_id)) {
+ self(self, *child,
+ format::find_child_projection(projection,
child->local_id));
+ }
+ }
+ };
+ collect_dates(collect_dates, root_schema, &count_projection);
+ }
+ const auto& footer = _state->file_context.native_metadata->to_thrift();
+ // Older writers can publish incorrect all-NULL counts. They must not
let COUNT
+ // bypass DATE conversion when the same statistics are distrusted by
normal reads.
+ const bool null_count_trusted =
+ native::parquet_reader_compat(footer.__isset.created_by ?
footer.created_by : "")
+ .null_count_trusted;
+ for (const auto* date_leaf : date_leaves) {
+ // Definition levels count physical NULLs only. DATE conversion
can add logical NULLs
+ // or raise an error, including for nested children in strict
mode. Validate every
+ // projected DATE leaf before allowing a levels-only count to
bypass conversion.
+ for (const auto& row_group_plan : _state->scan_plan->row_groups) {
+ const auto& group =
_state->file_context.native_metadata->to_thrift()
+
.row_groups[row_group_plan.row_group_id];
+ const auto& chunk = group.columns[date_leaf->leaf_column_id];
+ if (!chunk.__isset.meta_data ||
!chunk.meta_data.__isset.statistics) {
+ return Status::NotSupported("Parquet DATE COUNT requires
value validation");
+ }
+ const auto stats = detail::sanitize_native_footer_statistics(
+ date_leaf->type_descriptor, chunk.meta_data.statistics,
+ detail::has_supported_type_defined_order(
+
_state->file_context.native_metadata->to_thrift(),
+ date_leaf->leaf_column_id));
+ const auto decoded =
ParquetStatisticsUtils::TransformColumnStatistics(
+ *date_leaf, &stats, chunk.meta_data.num_values,
_state->timezone,
+ null_count_trusted);
+ if (!decoded.has_min_max && !(decoded.has_null_count &&
!decoded.has_not_null)) {
Review Comment:
Fixed in 0b1a2ea661 in the shared DATE footer/page statistics proof,
covering ordinary pruning as well as COUNT. An all-NULL proof is rejected when
bounds are present or physical nullability contradicts it; even
partial/deprecated bounds are checked before normalization can erase the
evidence. Required/nullable COUNT regressions and the statistics matrix pass,
while legitimate all-NULL shortcuts remain covered. COUNT and strict cache hits
now reuse the same writer-aware conversion-safety proof.
--
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]