Gabriel39 commented on code in PR #71397:
URL: https://github.com/apache/doris/pull/71397#discussion_r4795875320
##########
be/src/format_v2/parquet/reader/variant_column_reader.cpp:
##########
@@ -695,6 +701,10 @@ bool supports_direct_typed_variant_state(const
ParquetColumnSchema& schema) {
if (schema.type == nullptr || schema.kind !=
ParquetColumnSchemaKind::PRIMITIVE) {
return false;
}
+ // Raw INT32 is only physical storage here; an integer typed state would
lose DATE identity.
+ if (schema.type_descriptor.is_variant_date) {
Review Comment:
Fixed in d76640f505. Encoded Variant DATE-to-scalar conversion now uses the
shared checked Gregorian inverse, accepting representable year-zero dates while
rejecting the actual missing leap day and out-of-range ordinals. A nested
object-path regression compares fully shredded raw DATE leaves with unshredded
DATEs through extraction and CAST to DATE; it covers January 1, February 28,
March 1, the leap-day exclusion, both range limits and ordinary dates. It
reproduced NULL results before the fix and now passes.
##########
be/src/core/column/variant_v2/column_variant_v2_typed_column.h:
##########
@@ -106,12 +106,15 @@ void with_variant_typed_scalar(const Column& column,
size_t row, uint8_t scale,
} else if constexpr (Type == TYPE_DECIMAL128I) {
const __int128 value = column.get_data()[row].value;
callback(VariantScalarRef::decimal(value, scale, 16));
- } else if constexpr (Type == TYPE_DATE) {
- const int32_t value = variant_days_since_epoch(column.get_data()[row],
row, "DATE");
- callback(VariantScalarRef::date(value));
- } else if constexpr (Type == TYPE_DATEV2) {
- const int32_t value = variant_days_since_epoch(column.get_data()[row],
row, "DATEV2");
- callback(VariantScalarRef::date(value));
+ } else if constexpr (Type == TYPE_DATE || Type == TYPE_DATEV2) {
+ const auto& value = column.get_data()[row];
+ if (!value.is_valid_date()) {
+ throw Exception(ErrorCode::INVALID_ARGUMENT,
+ "Cannot encode invalid DATE value at row {} as
Variant", row);
+ }
+ // Variant DATE uses Gregorian days; the MySQL offset shifts Jan/Feb
of year zero.
+ // Keep DATETIME's separate timestamp mapping unchanged.
+ callback(VariantScalarRef::date(daynr_to_epoch_days(value.daynr())));
Review Comment:
Fixed in d76640f505. Typed DATE emission and legacy storage-cell fallback
share a DATE-only Gregorian helper; the separate DATETIME timestamp mapping is
unchanged. A regression compares both DATEV2 and legacy DATE cells through
homogeneous typed batches, heterogeneous generic batches and full sparse-object
reconstruction, checking JSON and raw DATE ordinals. January/February year-zero
values reproduced the one-day discrepancy before the fix; all paths now agree.
--
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]