Skip to content

Commit 61adc69

Browse files
author
B Vadlamani
committed
deprecate_paste_crate
1 parent 422b545 commit 61adc69

17 files changed

Lines changed: 811 additions & 685 deletions

File tree

datafusion/core/tests/parquet/page_pruning.rs

Lines changed: 353 additions & 267 deletions
Large diffs are not rendered by default.

datafusion/core/tests/parquet/row_group_pruning.rs

Lines changed: 343 additions & 299 deletions
Large diffs are not rendered by default.

datafusion/expr-common/src/interval_arithmetic.rs

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ use datafusion_common::{
3737
};
3838

3939
macro_rules! get_extreme_value {
40-
($extreme:ident, $value:expr) => {
40+
($extreme:ident, $DECIMAL128_ARRAY:ident, $DECIMAL256_ARRAY:ident, $value:expr) => {
4141
match $value {
4242
DataType::UInt8 => ScalarValue::UInt8(Some(u8::$extreme)),
4343
DataType::UInt16 => ScalarValue::UInt16(Some(u16::$extreme)),
@@ -83,18 +83,12 @@ macro_rules! get_extreme_value {
8383
ScalarValue::IntervalMonthDayNano(Some(IntervalMonthDayNano::$extreme))
8484
}
8585
DataType::Decimal128(precision, scale) => ScalarValue::Decimal128(
86-
Some(
87-
paste::paste! {[<$extreme _DECIMAL128_FOR_EACH_PRECISION>]}
88-
[*precision as usize],
89-
),
86+
Some($DECIMAL128_ARRAY[*precision as usize]),
9087
*precision,
9188
*scale,
9289
),
9390
DataType::Decimal256(precision, scale) => ScalarValue::Decimal256(
94-
Some(
95-
paste::paste! {[<$extreme _DECIMAL256_FOR_EACH_PRECISION>]}
96-
[*precision as usize],
97-
),
91+
Some($DECIMAL256_ARRAY[*precision as usize]),
9892
*precision,
9993
*scale,
10094
),
@@ -1162,10 +1156,20 @@ fn handle_overflow<const UPPER: bool>(
11621156
match (UPPER, positive_sign) {
11631157
(true, true) | (false, false) => ScalarValue::try_from(dt).unwrap(),
11641158
(true, false) => {
1165-
get_extreme_value!(MIN, dt)
1159+
get_extreme_value!(
1160+
MIN,
1161+
MIN_DECIMAL128_FOR_EACH_PRECISION,
1162+
MIN_DECIMAL256_FOR_EACH_PRECISION,
1163+
dt
1164+
)
11661165
}
11671166
(false, true) => {
1168-
get_extreme_value!(MAX, dt)
1167+
get_extreme_value!(
1168+
MAX,
1169+
MAX_DECIMAL128_FOR_EACH_PRECISION,
1170+
MAX_DECIMAL256_FOR_EACH_PRECISION,
1171+
dt
1172+
)
11691173
}
11701174
}
11711175
}
@@ -4218,12 +4222,8 @@ mod tests {
42184222
}
42194223

42204224
macro_rules! capture_mode_change {
4221-
($TYPE:ty) => {
4222-
paste::item! {
4223-
capture_mode_change_helper!([<capture_mode_change_ $TYPE>],
4224-
[<create_interval_ $TYPE>],
4225-
$TYPE);
4226-
}
4225+
($TYPE:ty, $TEST_FN_NAME:ident, $CREATE_FN_NAME:ident) => {
4226+
capture_mode_change_helper!($TEST_FN_NAME, $CREATE_FN_NAME, $TYPE);
42274227
};
42284228
}
42294229

@@ -4251,8 +4251,8 @@ mod tests {
42514251
};
42524252
}
42534253

4254-
capture_mode_change!(f32);
4255-
capture_mode_change!(f64);
4254+
capture_mode_change!(f32, capture_mode_change_f32, create_interval_f32);
4255+
capture_mode_change!(f64, capture_mode_change_f64, create_interval_f64);
42564256

42574257
#[cfg(all(
42584258
any(target_arch = "x86_64", target_arch = "aarch64"),

datafusion/expr/src/test/function_stub.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,6 @@ use crate::{
4141

4242
macro_rules! create_func {
4343
($UDAF:ty, $AGGREGATE_UDF_FN:ident) => {
44-
paste::paste! {
4544
#[doc = concat!("AggregateFunction that returns a [AggregateUDF](crate::AggregateUDF) for [`", stringify!($UDAF), "`]")]
4645
pub fn $AGGREGATE_UDF_FN() -> std::sync::Arc<crate::AggregateUDF> {
4746
// Singleton instance of [$UDAF], ensures the UDAF is only created once
@@ -51,7 +50,6 @@ macro_rules! create_func {
5150
});
5251
std::sync::Arc::clone(&INSTANCE)
5352
}
54-
}
5553
}
5654
}
5755

datafusion/functions-aggregate/src/macros.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,6 @@ macro_rules! create_func {
6767
create_func!($UDAF, $AGGREGATE_UDF_FN, <$UDAF>::default());
6868
};
6969
($UDAF:ty, $AGGREGATE_UDF_FN:ident, $CREATE:expr) => {
70-
paste::paste! {
7170
#[doc = concat!("AggregateFunction that returns a [`AggregateUDF`](datafusion_expr::AggregateUDF) for [`", stringify!($UDAF), "`]")]
7271
pub fn $AGGREGATE_UDF_FN() -> std::sync::Arc<datafusion_expr::AggregateUDF> {
7372
// Singleton instance of [$UDAF], ensures the UDAF is only created once
@@ -76,7 +75,6 @@ macro_rules! create_func {
7675
std::sync::Arc::new(datafusion_expr::AggregateUDF::from($CREATE))
7776
});
7877
std::sync::Arc::clone(&INSTANCE)
79-
}
8078
}
8179
}
8280
}

datafusion/functions-nested/src/macros.rs

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,6 @@ macro_rules! make_udf_expr_and_func {
5050
make_udf_expr_and_func!($UDF, $EXPR_FN, $($arg)*, $DOC, $SCALAR_UDF_FN, $UDF::new);
5151
};
5252
($UDF:ident, $EXPR_FN:ident, $($arg:ident)*, $DOC:expr, $SCALAR_UDF_FN:ident, $CTOR:path) => {
53-
paste::paste! {
5453
// "fluent expr_fn" style function
5554
#[doc = $DOC]
5655
pub fn $EXPR_FN($($arg: datafusion_expr::Expr),*) -> datafusion_expr::Expr {
@@ -60,13 +59,11 @@ macro_rules! make_udf_expr_and_func {
6059
))
6160
}
6261
create_func!($UDF, $SCALAR_UDF_FN, $CTOR);
63-
}
6462
};
6563
($UDF:ident, $EXPR_FN:ident, $DOC:expr, $SCALAR_UDF_FN:ident) => {
6664
make_udf_expr_and_func!($UDF, $EXPR_FN, $DOC, $SCALAR_UDF_FN, $UDF::new);
6765
};
6866
($UDF:ident, $EXPR_FN:ident, $DOC:expr, $SCALAR_UDF_FN:ident, $CTOR:path) => {
69-
paste::paste! {
7067
// "fluent expr_fn" style function
7168
#[doc = $DOC]
7269
pub fn $EXPR_FN(arg: Vec<datafusion_expr::Expr>) -> datafusion_expr::Expr {
@@ -76,7 +73,6 @@ macro_rules! make_udf_expr_and_func {
7673
))
7774
}
7875
create_func!($UDF, $SCALAR_UDF_FN, $CTOR);
79-
}
8076
};
8177
}
8278

@@ -97,7 +93,6 @@ macro_rules! create_func {
9793
create_func!($UDF, $SCALAR_UDF_FN, $UDF::new);
9894
};
9995
($UDF:ident, $SCALAR_UDF_FN:ident, $CTOR:path) => {
100-
paste::paste! {
10196
#[doc = concat!("ScalarFunction that returns a [`ScalarUDF`](datafusion_expr::ScalarUDF) for ")]
10297
#[doc = stringify!($UDF)]
10398
pub fn $SCALAR_UDF_FN() -> std::sync::Arc<datafusion_expr::ScalarUDF> {
@@ -110,6 +105,5 @@ macro_rules! create_func {
110105
});
111106
std::sync::Arc::clone(&INSTANCE)
112107
}
113-
}
114108
};
115109
}

datafusion/functions-table/src/lib.rs

Lines changed: 16 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -42,21 +42,23 @@ pub fn all_default_table_functions() -> Vec<Arc<TableFunction>> {
4242
/// This is used to ensure creating the list of `TableFunction` only happens once.
4343
#[macro_export]
4444
macro_rules! create_udtf_function {
45-
($module:path, $name:expr) => {
46-
paste::paste! {
47-
pub fn [<$name:lower>]() -> Arc<TableFunction> {
48-
static INSTANCE: std::sync::LazyLock<Arc<TableFunction>> =
49-
std::sync::LazyLock::new(|| {
50-
std::sync::Arc::new(TableFunction::new(
51-
$name.to_string(),
52-
Arc::new($module {}),
53-
))
54-
});
55-
std::sync::Arc::clone(&INSTANCE)
56-
}
45+
($module:expr, $func_name:ident, $name:expr) => {
46+
pub fn $func_name() -> Arc<TableFunction> {
47+
static INSTANCE: std::sync::LazyLock<Arc<TableFunction>> =
48+
std::sync::LazyLock::new(|| {
49+
std::sync::Arc::new(TableFunction::new(
50+
$name.to_string(),
51+
Arc::new($module),
52+
))
53+
});
54+
std::sync::Arc::clone(&INSTANCE)
5755
}
5856
};
5957
}
6058

61-
create_udtf_function!(generate_series::GenerateSeriesFunc, "generate_series");
62-
create_udtf_function!(generate_series::RangeFunc, "range");
59+
create_udtf_function!(
60+
generate_series::GenerateSeriesFunc {},
61+
generate_series,
62+
"generate_series"
63+
);
64+
create_udtf_function!(generate_series::RangeFunc {}, range, "range");

datafusion/functions-window/src/cume_dist.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ use std::sync::Arc;
3939
define_udwf_and_expr!(
4040
CumeDist,
4141
cume_dist,
42+
cume_dist_udfw,
4243
"Calculates the cumulative distribution of a value in a group of values."
4344
);
4445

datafusion/functions-window/src/lead_lag.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ use std::sync::{Arc, LazyLock};
4343
get_or_init_udwf!(
4444
Lag,
4545
lag,
46+
lag_udwf,
4647
"Returns the row value that precedes the current row by a specified \
4748
offset within partition. If no such row exists, then returns the \
4849
default value.",
@@ -51,6 +52,7 @@ get_or_init_udwf!(
5152
get_or_init_udwf!(
5253
Lead,
5354
lead,
55+
lead_udwf,
5456
"Returns the value from a row that follows the current row by a \
5557
specified offset within the partition. If no such row exists, then \
5658
returns the default value.",

datafusion/functions-window/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ pub mod expr_fn {
6868
/// Returns all default window functions
6969
pub fn all_default_window_functions() -> Vec<Arc<WindowUDF>> {
7070
vec![
71-
cume_dist::cume_dist_udwf(),
71+
cume_dist::cume_dist_udfw(),
7272
row_number::row_number_udwf(),
7373
lead_lag::lead_udwf(),
7474
lead_lag::lag_udwf(),

0 commit comments

Comments
 (0)