|
3 | 3 | #include "duckdb.hpp" |
4 | 4 | #include "mbedtls_wrapper.hpp" |
5 | 5 | #include "parquet_crypto.hpp" |
| 6 | +#include "parquet_decimal_utils.hpp" |
6 | 7 | #include "parquet_shredding.hpp" |
7 | 8 | #include "parquet_timestamp.hpp" |
8 | 9 | #include "resizable_buffer.hpp" |
@@ -751,8 +752,17 @@ struct DecimalStatsUnifier : public NumericStatsUnifier<T> { |
751 | 752 | if (stats.empty()) { |
752 | 753 | return string(); |
753 | 754 | } |
754 | | - auto numeric_val = Load<T>(const_data_ptr_cast(stats.data())); |
755 | | - return Value::DECIMAL(numeric_val, width, scale).ToString(); |
| 755 | + |
| 756 | + auto stats_data = const_data_ptr_cast(stats.data()); |
| 757 | + |
| 758 | + if (sizeof(T) == sizeof(hugeint_t)) { |
| 759 | + auto _schema = ParquetColumnSchema(); |
| 760 | + auto numeric_val = ParquetDecimalUtils::ReadDecimalValue<hugeint_t>(stats_data, stats.size(), _schema); |
| 761 | + return Value::DECIMAL(numeric_val, width, scale).ToString(); |
| 762 | + } else { |
| 763 | + auto numeric_val = Load<T>(stats_data); |
| 764 | + return Value::DECIMAL(numeric_val, width, scale).ToString(); |
| 765 | + } |
756 | 766 | } |
757 | 767 | }; |
758 | 768 |
|
@@ -874,7 +884,7 @@ struct NullStatsUnifier : public ColumnStatsUnifier { |
874 | 884 | static unique_ptr<ColumnStatsUnifier> GetBaseStatsUnifier(const LogicalType &type) { |
875 | 885 | switch (type.id()) { |
876 | 886 | case LogicalTypeId::BOOLEAN: |
877 | | - return make_uniq<NullStatsUnifier>(); |
| 887 | + return make_uniq<NumericStatsUnifier<int8_t>>(); |
878 | 888 | case LogicalTypeId::TINYINT: |
879 | 889 | case LogicalTypeId::SMALLINT: |
880 | 890 | case LogicalTypeId::INTEGER: |
@@ -919,6 +929,8 @@ static unique_ptr<ColumnStatsUnifier> GetBaseStatsUnifier(const LogicalType &typ |
919 | 929 | return make_uniq<DecimalStatsUnifier<int32_t>>(width, scale); |
920 | 930 | case PhysicalType::INT64: |
921 | 931 | return make_uniq<DecimalStatsUnifier<int64_t>>(width, scale); |
| 932 | + case PhysicalType::INT128: |
| 933 | + return make_uniq<DecimalStatsUnifier<hugeint_t>>(width, scale); |
922 | 934 | default: |
923 | 935 | return make_uniq<NullStatsUnifier>(); |
924 | 936 | } |
|
0 commit comments