Skip to content

Commit a923ad8

Browse files
committed
simple
1 parent 76f6b2f commit a923ad8

File tree

4 files changed

+32
-58
lines changed

4 files changed

+32
-58
lines changed

Cargo.lock

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/query/storages/fuse/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@ match-template = { workspace = true }
6262
opendal = { workspace = true }
6363
parking_lot = { workspace = true }
6464
parquet = { workspace = true }
65+
paste = { workspace = true }
6566
rand = { workspace = true }
6667
serde = { workspace = true }
6768
serde_json = { workspace = true }

src/query/storages/fuse/src/io/write/stream/column_ndv_estimator.rs

Lines changed: 15 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ use databend_common_expression::types::UInt32Type;
3535
use databend_common_expression::types::UInt64Type;
3636
use databend_common_expression::types::UInt8Type;
3737
use databend_common_expression::types::ValueType;
38+
use databend_common_expression::with_number_type;
3839
use databend_common_expression::Column;
3940
use databend_common_expression::ScalarRef;
4041
use databend_common_expression::SELECTIVITY_THRESHOLD;
@@ -69,37 +70,22 @@ pub enum ColumnNDVEstimator {
6970
}
7071

7172
pub fn create_column_ndv_estimator(data_type: &DataType) -> ColumnNDVEstimator {
73+
macro_rules! match_number_type_create {
74+
($inner_type:expr) => {{
75+
with_number_type!(|NUM_TYPE| match $inner_type {
76+
NumberDataType::NUM_TYPE => {
77+
paste::paste! {
78+
ColumnNDVEstimator::NUM_TYPE(ColumnNDVEstimatorImpl::<[<NUM_TYPE Type>]>::new())
79+
}
80+
}
81+
})
82+
}};
83+
}
84+
7285
let inner_type = data_type.remove_nullable();
7386
match inner_type {
74-
DataType::Number(NumberDataType::Int8) => {
75-
ColumnNDVEstimator::Int8(ColumnNDVEstimatorImpl::<Int8Type>::new())
76-
}
77-
DataType::Number(NumberDataType::Int16) => {
78-
ColumnNDVEstimator::Int16(ColumnNDVEstimatorImpl::<Int16Type>::new())
79-
}
80-
DataType::Number(NumberDataType::Int32) => {
81-
ColumnNDVEstimator::Int32(ColumnNDVEstimatorImpl::<Int32Type>::new())
82-
}
83-
DataType::Number(NumberDataType::Int64) => {
84-
ColumnNDVEstimator::Int64(ColumnNDVEstimatorImpl::<Int64Type>::new())
85-
}
86-
DataType::Number(NumberDataType::UInt8) => {
87-
ColumnNDVEstimator::UInt8(ColumnNDVEstimatorImpl::<UInt8Type>::new())
88-
}
89-
DataType::Number(NumberDataType::UInt16) => {
90-
ColumnNDVEstimator::UInt16(ColumnNDVEstimatorImpl::<UInt16Type>::new())
91-
}
92-
DataType::Number(NumberDataType::UInt32) => {
93-
ColumnNDVEstimator::UInt32(ColumnNDVEstimatorImpl::<UInt32Type>::new())
94-
}
95-
DataType::Number(NumberDataType::UInt64) => {
96-
ColumnNDVEstimator::UInt64(ColumnNDVEstimatorImpl::<UInt64Type>::new())
97-
}
98-
DataType::Number(NumberDataType::Float32) => {
99-
ColumnNDVEstimator::Float32(ColumnNDVEstimatorImpl::<Float32Type>::new())
100-
}
101-
DataType::Number(NumberDataType::Float64) => {
102-
ColumnNDVEstimator::Float64(ColumnNDVEstimatorImpl::<Float64Type>::new())
87+
DataType::Number(num_type) => {
88+
match_number_type_create!(num_type)
10389
}
10490
DataType::String => ColumnNDVEstimator::String(ColumnNDVEstimatorImpl::<StringType>::new()),
10591
DataType::Date => ColumnNDVEstimator::Date(ColumnNDVEstimatorImpl::<DateType>::new()),

src/query/storages/fuse/src/io/write/stream/column_statistics_builder.rs

Lines changed: 15 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ use databend_common_expression::types::UInt32Type;
3838
use databend_common_expression::types::UInt64Type;
3939
use databend_common_expression::types::UInt8Type;
4040
use databend_common_expression::types::ValueType;
41+
use databend_common_expression::with_number_type;
4142
use databend_common_expression::Column;
4243
use databend_common_expression::Scalar;
4344
use databend_common_expression::ScalarRef;
@@ -108,36 +109,21 @@ macro_rules! create_builder_for_type {
108109

109110
pub fn create_column_stats_builder(data_type: &DataType) -> ColumnStatisticsBuilder {
110111
let inner_type = data_type.remove_nullable();
112+
macro_rules! match_number_type_create {
113+
($inner_type:expr) => {{
114+
with_number_type!(|NUM_TYPE| match $inner_type {
115+
NumberDataType::NUM_TYPE => {
116+
paste::paste! {
117+
ColumnStatisticsBuilder::NUM_TYPE(CommonBuilder::<[<NUM_TYPE Type>]>::create(inner_type))
118+
}
119+
}
120+
})
121+
}};
122+
}
123+
111124
match inner_type {
112-
DataType::Number(NumberDataType::Int8) => {
113-
create_builder_for_type!(inner_type, Int8, Int8Type)
114-
}
115-
DataType::Number(NumberDataType::Int16) => {
116-
create_builder_for_type!(inner_type, Int16, Int16Type)
117-
}
118-
DataType::Number(NumberDataType::Int32) => {
119-
create_builder_for_type!(inner_type, Int32, Int32Type)
120-
}
121-
DataType::Number(NumberDataType::Int64) => {
122-
create_builder_for_type!(inner_type, Int64, Int64Type)
123-
}
124-
DataType::Number(NumberDataType::UInt8) => {
125-
create_builder_for_type!(inner_type, UInt8, UInt8Type)
126-
}
127-
DataType::Number(NumberDataType::UInt16) => {
128-
create_builder_for_type!(inner_type, UInt16, UInt16Type)
129-
}
130-
DataType::Number(NumberDataType::UInt32) => {
131-
create_builder_for_type!(inner_type, UInt32, UInt32Type)
132-
}
133-
DataType::Number(NumberDataType::UInt64) => {
134-
create_builder_for_type!(inner_type, UInt64, UInt64Type)
135-
}
136-
DataType::Number(NumberDataType::Float32) => {
137-
create_builder_for_type!(inner_type, Float32, Float32Type)
138-
}
139-
DataType::Number(NumberDataType::Float64) => {
140-
create_builder_for_type!(inner_type, Float64, Float64Type)
125+
DataType::Number(num_type) => {
126+
match_number_type_create!(num_type)
141127
}
142128
DataType::String => create_builder_for_type!(inner_type, String, StringType),
143129
DataType::Date => create_builder_for_type!(inner_type, Date, DateType),

0 commit comments

Comments
 (0)