You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@datafusion.apache.org by al...@apache.org on 2024/08/21 15:23:54 UTC
(datafusion) branch main updated: fix: Panic non-integer for the second argument of `nth_value` function (#12076)
This is an automated email from the ASF dual-hosted git repository.
alamb pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/datafusion.git
The following commit(s) were added to refs/heads/main by this push:
new 9d076bde4f fix: Panic non-integer for the second argument of `nth_value` function (#12076)
9d076bde4f is described below
commit 9d076bde4fb099329abf33f57e319fd47c523561
Author: Alex Huang <hu...@gmail.com>
AuthorDate: Wed Aug 21 23:23:49 2024 +0800
fix: Panic non-integer for the second argument of `nth_value` function (#12076)
* fix: Panic non-integer for nth_value function
* chore: Display actual value
* Update datafusion/physical-plan/src/windows/mod.rs
Co-authored-by: Marco Neumann <ma...@crepererum.net>
* chore
---------
Co-authored-by: Marco Neumann <ma...@crepererum.net>
---
datafusion/physical-plan/src/windows/mod.rs | 8 ++++++--
datafusion/sqllogictest/test_files/window.slt | 13 +++++++++++++
2 files changed, 19 insertions(+), 2 deletions(-)
diff --git a/datafusion/physical-plan/src/windows/mod.rs b/datafusion/physical-plan/src/windows/mod.rs
index f938f4410a..63f4ffcfaa 100644
--- a/datafusion/physical-plan/src/windows/mod.rs
+++ b/datafusion/physical-plan/src/windows/mod.rs
@@ -30,7 +30,9 @@ use crate::{
use arrow::datatypes::Schema;
use arrow_schema::{DataType, Field, SchemaRef};
-use datafusion_common::{exec_err, DataFusionError, Result, ScalarValue};
+use datafusion_common::{
+ exec_datafusion_err, exec_err, DataFusionError, Result, ScalarValue,
+};
use datafusion_expr::{
BuiltInWindowFunction, PartitionEvaluator, WindowFrame, WindowFunctionDefinition,
WindowUDF,
@@ -284,7 +286,9 @@ fn create_built_in_window_expr(
args[1]
.as_any()
.downcast_ref::<Literal>()
- .unwrap()
+ .ok_or_else(|| {
+ exec_datafusion_err!("Expected a signed integer literal for the second argument of nth_value, got {}", args[1])
+ })?
.value()
.clone(),
)?;
diff --git a/datafusion/sqllogictest/test_files/window.slt b/datafusion/sqllogictest/test_files/window.slt
index 78055f8c1c..5bf5cf8328 100644
--- a/datafusion/sqllogictest/test_files/window.slt
+++ b/datafusion/sqllogictest/test_files/window.slt
@@ -4861,3 +4861,16 @@ select a, row_number(a) over (order by b) as rn from t;
statement ok
drop table t;
+
+statement ok
+DROP TABLE t1;
+
+# https://github.com/apache/datafusion/issues/12073
+statement ok
+CREATE TABLE t1(v1 BIGINT);
+
+query error DataFusion error: Execution error: Expected a signed integer literal for the second argument of nth_value, got v1@0
+SELECT NTH_VALUE('+Inf'::Double, v1) OVER (PARTITION BY v1) FROM t1;
+
+statement ok
+DROP TABLE t1;
\ No newline at end of file
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@datafusion.apache.org
For additional commands, e-mail: commits-help@datafusion.apache.org