Skip to content

Commit 9e5bc8c

Browse files
committed
fix: Function expr names without arguments are plain function names
Signed-off-by: Alex Qyoun-ae <[email protected]>
1 parent dcf3e4a commit 9e5bc8c

File tree

3 files changed

+6
-3
lines changed

3 files changed

+6
-3
lines changed

datafusion/core/src/optimizer/simplify_expressions.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1860,7 +1860,7 @@ mod tests {
18601860
// expect the same timestamp appears in both exprs
18611861
let actual = get_optimized_plan_formatted(&plan, &time);
18621862
let expected = format!(
1863-
"Projection: TimestampNanosecond({}, Some(\"UTC\")) AS now(), TimestampNanosecond({}, Some(\"UTC\")) AS t2\
1863+
"Projection: TimestampNanosecond({}, Some(\"UTC\")) AS now, TimestampNanosecond({}, Some(\"UTC\")) AS t2\
18641864
\n TableScan: test projection=None",
18651865
time.timestamp_nanos(),
18661866
time.timestamp_nanos()
@@ -1910,7 +1910,7 @@ mod tests {
19101910

19111911
// Note that constant folder runs and folds the entire
19121912
// expression down to a single constant (true)
1913-
let expected = "Filter: Boolean(true) AS CAST(now() AS Int64) < CAST(totimestamp(Utf8(\"2020-09-08T12:05:00+00:00\")) AS Int64) + Int32(50000)\
1913+
let expected = "Filter: Boolean(true) AS CAST(now AS Int64) < CAST(totimestamp(Utf8(\"2020-09-08T12:05:00+00:00\")) AS Int64) + Int32(50000)\
19141914
\n TableScan: test projection=None";
19151915
let actual = get_optimized_plan_formatted(&plan, &time);
19161916

datafusion/core/tests/sql/functions.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -602,7 +602,7 @@ async fn pi_function() -> Result<()> {
602602
let actual = execute_to_batches(&ctx, sql).await;
603603
let expected = vec![
604604
"+-------------------+--------------------+--------------------+",
605-
"| pi() | pi() / Int64(2) | pi() / Int64(3) |",
605+
"| pi | pi / Int64(2) | pi / Int64(3) |",
606606
"+-------------------+--------------------+--------------------+",
607607
"| 3.141592653589793 | 1.5707963267948966 | 1.0471975511965976 |",
608608
"+-------------------+--------------------+--------------------+",

datafusion/expr/src/expr.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -772,6 +772,9 @@ fn create_function_name(
772772
args: &[Expr],
773773
input_schema: &DFSchema,
774774
) -> Result<String> {
775+
if !distinct && args.is_empty() {
776+
return Ok(fun.to_ascii_lowercase());
777+
}
775778
let names: Vec<String> = args
776779
.iter()
777780
.map(|e| create_name(e, input_schema))

0 commit comments

Comments
 (0)