Skip to content

Commit 34e1684

Browse files
committed
refer to apache#8781, convert the internal_err! in datetime_expression.rs to exec_err!
Signed-off-by: tangruilin <[email protected]>
1 parent 15f59d9 commit 34e1684

File tree

1 file changed

+20
-21
lines changed

1 file changed

+20
-21
lines changed

datafusion/physical-expr/src/datetime_expressions.rs

Lines changed: 20 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -53,8 +53,7 @@ use datafusion_common::cast::{
5353
as_timestamp_nanosecond_array, as_timestamp_second_array,
5454
};
5555
use datafusion_common::{
56-
exec_err, internal_err, not_impl_err, DataFusionError, Result, ScalarType,
57-
ScalarValue,
56+
exec_err, not_impl_err, DataFusionError, Result, ScalarType, ScalarValue,
5857
};
5958
use datafusion_expr::ColumnarValue;
6059

@@ -165,7 +164,7 @@ where
165164
F: Fn(&'a str) -> Result<O::Native>,
166165
{
167166
if args.len() != 1 {
168-
return internal_err!(
167+
return exec_err!(
169168
"{:?} args were supplied but {} takes exactly one argument",
170169
args.len(),
171170
name
@@ -202,7 +201,7 @@ where
202201
F2: Fn(O::Native) -> O::Native,
203202
{
204203
if args.len() < 2 {
205-
return internal_err!(
204+
return exec_err!(
206205
"{:?} args were supplied but {} takes 2 or more arguments",
207206
args.len(),
208207
name
@@ -218,7 +217,7 @@ where
218217
}
219218
ColumnarValue::Scalar(s) => match s {
220219
ScalarValue::Utf8(a) | ScalarValue::LargeUtf8(a) => Ok(Either::Right(a)),
221-
other => internal_err!(
220+
other => exec_err!(
222221
"Unexpected scalar type encountered '{other}' for function '{name}'"
223222
),
224223
},
@@ -420,7 +419,7 @@ fn to_timestamp_impl<T: ArrowTimestampType + ScalarType<i64>>(
420419
|n| n / factor,
421420
name,
422421
),
423-
_ => internal_err!("Unsupported 0 argument count for function {name}"),
422+
_ => exec_err!("Unsupported 0 argument count for function {name}"),
424423
}
425424
}
426425

@@ -1190,7 +1189,7 @@ macro_rules! extract_date_part {
11901189
.map(|v| cast(&(Arc::new(v) as ArrayRef), &DataType::Float64))?)
11911190
}
11921191
},
1193-
datatype => internal_err!("Extract does not support datatype {:?}", datatype),
1192+
datatype => exec_err!("Extract does not support datatype {:?}", datatype),
11941193
}
11951194
};
11961195
}
@@ -1316,7 +1315,7 @@ where
13161315
let n: i64 = n.into();
13171316
n as f64 / 1_000_f64
13181317
}),
1319-
_ => return internal_err!("Can not convert {:?} to epoch", array.data_type()),
1318+
_ => return exec_err!("Can not convert {:?} to epoch", array.data_type()),
13201319
};
13211320
Ok(b)
13221321
}
@@ -1331,7 +1330,7 @@ fn validate_to_timestamp_data_types(
13311330
// all good
13321331
}
13331332
_ => {
1334-
return Some(internal_err!(
1333+
return Some(exec_err!(
13351334
"{name} function unsupported data type at index {}: {}",
13361335
idx + 1,
13371336
a.data_type()
@@ -1346,7 +1345,7 @@ fn validate_to_timestamp_data_types(
13461345
/// to_timestamp() SQL function implementation
13471346
pub fn to_timestamp_invoke(args: &[ColumnarValue]) -> Result<ColumnarValue> {
13481347
if args.is_empty() {
1349-
return internal_err!(
1348+
return exec_err!(
13501349
"to_timestamp function requires 1 or more arguments, got {}",
13511350
args.len()
13521351
);
@@ -1377,7 +1376,7 @@ pub fn to_timestamp_invoke(args: &[ColumnarValue]) -> Result<ColumnarValue> {
13771376
),
13781377
DataType::Utf8 => to_timestamp(args),
13791378
other => {
1380-
internal_err!(
1379+
exec_err!(
13811380
"Unsupported data type {:?} for function to_timestamp",
13821381
other
13831382
)
@@ -1388,7 +1387,7 @@ pub fn to_timestamp_invoke(args: &[ColumnarValue]) -> Result<ColumnarValue> {
13881387
/// to_timestamp_millis() SQL function implementation
13891388
pub fn to_timestamp_millis_invoke(args: &[ColumnarValue]) -> Result<ColumnarValue> {
13901389
if args.is_empty() {
1391-
return internal_err!(
1390+
return exec_err!(
13921391
"to_timestamp_millis function requires 1 or more arguments, got {}",
13931392
args.len()
13941393
);
@@ -1413,7 +1412,7 @@ pub fn to_timestamp_millis_invoke(args: &[ColumnarValue]) -> Result<ColumnarValu
14131412
),
14141413
DataType::Utf8 => to_timestamp_millis(args),
14151414
other => {
1416-
internal_err!(
1415+
exec_err!(
14171416
"Unsupported data type {:?} for function to_timestamp_millis",
14181417
other
14191418
)
@@ -1424,7 +1423,7 @@ pub fn to_timestamp_millis_invoke(args: &[ColumnarValue]) -> Result<ColumnarValu
14241423
/// to_timestamp_micros() SQL function implementation
14251424
pub fn to_timestamp_micros_invoke(args: &[ColumnarValue]) -> Result<ColumnarValue> {
14261425
if args.is_empty() {
1427-
return internal_err!(
1426+
return exec_err!(
14281427
"to_timestamp_micros function requires 1 or more arguments, got {}",
14291428
args.len()
14301429
);
@@ -1449,7 +1448,7 @@ pub fn to_timestamp_micros_invoke(args: &[ColumnarValue]) -> Result<ColumnarValu
14491448
),
14501449
DataType::Utf8 => to_timestamp_micros(args),
14511450
other => {
1452-
internal_err!(
1451+
exec_err!(
14531452
"Unsupported data type {:?} for function to_timestamp_micros",
14541453
other
14551454
)
@@ -1460,7 +1459,7 @@ pub fn to_timestamp_micros_invoke(args: &[ColumnarValue]) -> Result<ColumnarValu
14601459
/// to_timestamp_nanos() SQL function implementation
14611460
pub fn to_timestamp_nanos_invoke(args: &[ColumnarValue]) -> Result<ColumnarValue> {
14621461
if args.is_empty() {
1463-
return internal_err!(
1462+
return exec_err!(
14641463
"to_timestamp_nanos function requires 1 or more arguments, got {}",
14651464
args.len()
14661465
);
@@ -1485,7 +1484,7 @@ pub fn to_timestamp_nanos_invoke(args: &[ColumnarValue]) -> Result<ColumnarValue
14851484
),
14861485
DataType::Utf8 => to_timestamp_nanos(args),
14871486
other => {
1488-
internal_err!(
1487+
exec_err!(
14891488
"Unsupported data type {:?} for function to_timestamp_nanos",
14901489
other
14911490
)
@@ -1496,7 +1495,7 @@ pub fn to_timestamp_nanos_invoke(args: &[ColumnarValue]) -> Result<ColumnarValue
14961495
/// to_timestamp_seconds() SQL function implementation
14971496
pub fn to_timestamp_seconds_invoke(args: &[ColumnarValue]) -> Result<ColumnarValue> {
14981497
if args.is_empty() {
1499-
return internal_err!(
1498+
return exec_err!(
15001499
"to_timestamp_seconds function requires 1 or more arguments, got {}",
15011500
args.len()
15021501
);
@@ -1520,7 +1519,7 @@ pub fn to_timestamp_seconds_invoke(args: &[ColumnarValue]) -> Result<ColumnarVal
15201519
}
15211520
DataType::Utf8 => to_timestamp_seconds(args),
15221521
other => {
1523-
internal_err!(
1522+
exec_err!(
15241523
"Unsupported data type {:?} for function to_timestamp_seconds",
15251524
other
15261525
)
@@ -1531,7 +1530,7 @@ pub fn to_timestamp_seconds_invoke(args: &[ColumnarValue]) -> Result<ColumnarVal
15311530
/// from_unixtime() SQL function implementation
15321531
pub fn from_unixtime_invoke(args: &[ColumnarValue]) -> Result<ColumnarValue> {
15331532
if args.len() != 1 {
1534-
return internal_err!(
1533+
return exec_err!(
15351534
"from_unixtime function requires 1 argument, got {}",
15361535
args.len()
15371536
);
@@ -1542,7 +1541,7 @@ pub fn from_unixtime_invoke(args: &[ColumnarValue]) -> Result<ColumnarValue> {
15421541
cast_column(&args[0], &DataType::Timestamp(TimeUnit::Second, None), None)
15431542
}
15441543
other => {
1545-
internal_err!(
1544+
exec_err!(
15461545
"Unsupported data type {:?} for function from_unixtime",
15471546
other
15481547
)

0 commit comments

Comments
 (0)