Skip to content

Commit 1747605

Browse files
committed
Update datafusion-proto
1 parent b4ea7b9 commit 1747605

6 files changed

Lines changed: 722 additions & 163 deletions

File tree

datafusion/expr/src/utils.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -814,6 +814,8 @@ pub fn can_hash(data_type: &DataType) -> bool {
814814
DataType::Float16 => true,
815815
DataType::Float32 => true,
816816
DataType::Float64 => true,
817+
DataType::Decimal32(_, _) => true,
818+
DataType::Decimal64(_, _) => true,
817819
DataType::Decimal128(_, _) => true,
818820
DataType::Decimal256(_, _) => true,
819821
DataType::Timestamp(_, _) => true,

datafusion/proto-common/proto/datafusion_common.proto

Lines changed: 32 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,19 @@ enum IntervalUnit{
134134
MonthDayNano = 2;
135135
}
136136

137-
message Decimal{
137+
message Decimal32Type {
138+
reserved 1, 2;
139+
uint32 precision = 3;
140+
int32 scale = 4;
141+
}
142+
143+
message Decimal64Type {
144+
reserved 1, 2;
145+
uint32 precision = 3;
146+
int32 scale = 4;
147+
}
148+
149+
message Decimal128Type {
138150
reserved 1, 2;
139151
uint32 precision = 3;
140152
int32 scale = 4;
@@ -284,6 +296,8 @@ message ScalarValue{
284296
ScalarNestedValue struct_value = 32;
285297
ScalarNestedValue map_value = 41;
286298

299+
Decimal32 decimal32_value = 43;
300+
Decimal64 decimal64_value = 44;
287301
Decimal128 decimal128_value = 20;
288302
Decimal256 decimal256_value = 39;
289303

@@ -308,6 +322,18 @@ message ScalarValue{
308322
}
309323
}
310324

325+
message Decimal32{
326+
bytes value = 1;
327+
int64 p = 2;
328+
int64 s = 3;
329+
}
330+
331+
message Decimal64{
332+
bytes value = 1;
333+
int64 p = 2;
334+
int64 s = 3;
335+
}
336+
311337
message Decimal128{
312338
bytes value = 1;
313339
int64 p = 2;
@@ -350,7 +376,9 @@ message ArrowType{
350376
TimeUnit TIME32 = 21 ;
351377
TimeUnit TIME64 = 22 ;
352378
IntervalUnit INTERVAL = 23 ;
353-
Decimal DECIMAL = 24 ;
379+
Decimal32Type DECIMAL32 = 40;
380+
Decimal64Type DECIMAL64 = 41;
381+
Decimal128Type DECIMAL128 = 24;
354382
Decimal256Type DECIMAL256 = 36;
355383
List LIST = 25;
356384
List LARGE_LIST = 26;
@@ -478,9 +506,7 @@ message ParquetColumnOptions {
478506
uint64 bloom_filter_ndv = 7;
479507
}
480508

481-
oneof max_statistics_size_opt {
482-
uint32 max_statistics_size = 8;
483-
}
509+
reserved 8; // used to be uint32 max_statistics_size = 8;
484510
}
485511

486512
message ParquetOptions {
@@ -519,9 +545,7 @@ message ParquetOptions {
519545
string statistics_enabled = 13;
520546
}
521547

522-
oneof max_statistics_size_opt {
523-
uint64 max_statistics_size = 14;
524-
}
548+
reserved 14; // used to be uint32 max_statistics_size = 20;
525549

526550
oneof column_index_truncate_length_opt {
527551
uint64 column_index_truncate_length = 17;

datafusion/proto-common/src/from_proto/mod.rs

Lines changed: 18 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ use datafusion_common::{
3737
TableParquetOptions,
3838
},
3939
file_options::{csv_writer::CsvWriterOptions, json_writer::JsonWriterOptions},
40+
not_impl_err,
4041
parsers::CompressionTypeVariant,
4142
plan_datafusion_err,
4243
stats::Precision,
@@ -257,7 +258,15 @@ impl TryFrom<&protobuf::arrow_type::ArrowTypeEnum> for DataType {
257258
arrow_type::ArrowTypeEnum::Interval(interval_unit) => {
258259
DataType::Interval(parse_i32_to_interval_unit(interval_unit)?)
259260
}
260-
arrow_type::ArrowTypeEnum::Decimal(protobuf::Decimal {
261+
arrow_type::ArrowTypeEnum::Decimal32(protobuf::Decimal32Type {
262+
precision,
263+
scale,
264+
}) => DataType::Decimal32(*precision as u8, *scale as i8),
265+
arrow_type::ArrowTypeEnum::Decimal64(protobuf::Decimal64Type {
266+
precision,
267+
scale,
268+
}) => DataType::Decimal64(*precision as u8, *scale as i8),
269+
arrow_type::ArrowTypeEnum::Decimal128(protobuf::Decimal128Type {
261270
precision,
262271
scale,
263272
}) => DataType::Decimal128(*precision as u8, *scale as i8),
@@ -469,6 +478,14 @@ impl TryFrom<&protobuf::ScalarValue> for ScalarValue {
469478
let null_type: DataType = v.try_into()?;
470479
null_type.try_into().map_err(Error::DataFusionError)?
471480
}
481+
Value::Decimal32Value(_val) => {
482+
return not_impl_err!("Decimal32 protobuf deserialization")
483+
.map_err(Error::DataFusionError)
484+
}
485+
Value::Decimal64Value(_val) => {
486+
return not_impl_err!("Decimal64 protobuf deserialization")
487+
.map_err(Error::DataFusionError)
488+
}
472489
Value::Decimal128Value(val) => {
473490
let array = vec_to_array(val.value.clone());
474491
Self::Decimal128(
@@ -938,12 +955,6 @@ impl TryFrom<&protobuf::ParquetOptions> for ParquetOptions {
938955
protobuf::parquet_options::StatisticsEnabledOpt::StatisticsEnabled(v) => Some(v),
939956
})
940957
.unwrap_or(None),
941-
max_statistics_size: value
942-
.max_statistics_size_opt.as_ref()
943-
.map(|opt| match opt {
944-
protobuf::parquet_options::MaxStatisticsSizeOpt::MaxStatisticsSize(v) => Some(*v as usize),
945-
})
946-
.unwrap_or(None),
947958
max_row_group_size: value.max_row_group_size as usize,
948959
created_by: value.created_by.clone(),
949960
column_index_truncate_length: value
@@ -1009,12 +1020,6 @@ impl TryFrom<&protobuf::ParquetColumnOptions> for ParquetColumnOptions {
10091020
protobuf::parquet_column_options::StatisticsEnabledOpt::StatisticsEnabled(v) => Some(v),
10101021
})
10111022
.unwrap_or(None),
1012-
max_statistics_size: value
1013-
.max_statistics_size_opt
1014-
.map(|opt| match opt {
1015-
protobuf::parquet_column_options::MaxStatisticsSizeOpt::MaxStatisticsSize(v) => Some(v as usize),
1016-
})
1017-
.unwrap_or(None),
10181023
encoding: value
10191024
.encoding_opt.clone()
10201025
.map(|opt| match opt {

0 commit comments

Comments
 (0)