You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@arrow.apache.org by al...@apache.org on 2023/05/04 18:45:42 UTC
[arrow-datafusion] branch main updated: minor: fix error type for window (#6231)
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/arrow-datafusion.git
The following commit(s) were added to refs/heads/main by this push:
new 6213a92e1a minor: fix error type for window (#6231)
6213a92e1a is described below
commit 6213a92e1a831612336c5890ab86793cfddd784a
Author: comphead <co...@users.noreply.github.com>
AuthorDate: Thu May 4 11:45:36 2023 -0700
minor: fix error type for window (#6231)
---
datafusion/core/src/physical_plan/planner.rs | 2 +-
.../core/tests/sqllogictests/test_files/window.slt | 15 ++++++++++++++-
datafusion/expr/src/window_frame.rs | 16 +++++++++-------
3 files changed, 24 insertions(+), 9 deletions(-)
diff --git a/datafusion/core/src/physical_plan/planner.rs b/datafusion/core/src/physical_plan/planner.rs
index 2d616d5a7d..458b1b2a21 100644
--- a/datafusion/core/src/physical_plan/planner.rs
+++ b/datafusion/core/src/physical_plan/planner.rs
@@ -1592,7 +1592,7 @@ pub fn create_window_expr_with_name(
physical_input_schema,
)
}
- other => Err(DataFusionError::Internal(format!(
+ other => Err(DataFusionError::Plan(format!(
"Invalid window expression '{other:?}'"
))),
}
diff --git a/datafusion/core/tests/sqllogictests/test_files/window.slt b/datafusion/core/tests/sqllogictests/test_files/window.slt
index 66b011eeb9..2027358f7c 100644
--- a/datafusion/core/tests/sqllogictests/test_files/window.slt
+++ b/datafusion/core/tests/sqllogictests/test_files/window.slt
@@ -920,7 +920,7 @@ drop table temp
#fn window_frame_ranges_unbounded_preceding_err
-statement error DataFusion error: Execution error: Invalid window frame: end bound cannot be unbounded preceding
+statement error DataFusion error: Error during planning: Invalid window frame: end bound cannot be unbounded preceding
SELECT
SUM(c2) OVER (ORDER BY c2 RANGE BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED PRECEDING),
COUNT(*) OVER (ORDER BY c2 RANGE BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED PRECEDING)
@@ -2365,3 +2365,16 @@ SELECT c9, rn1 FROM (SELECT c9,
4216440507 3
4144173353 4
4076864659 5
+
+
+# invalid window frame. null as preceding
+statement error DataFusion error: Error during planning: Invalid window frame: frame offsets must be non negative integers
+select row_number() over (rows between null preceding and current row) from (select 1 a) x
+
+# invalid window frame. null as preceding
+statement error DataFusion error: Error during planning: Invalid window frame: frame offsets must be non negative integers
+select row_number() over (rows between null preceding and current row) from (select 1 a) x
+
+# invalid window frame. negative as following
+statement error DataFusion error: Error during planning: Invalid window frame: frame offsets must be non negative integers
+select row_number() over (rows between current row and -1 following) from (select 1 a) x
diff --git a/datafusion/expr/src/window_frame.rs b/datafusion/expr/src/window_frame.rs
index 7794125d0e..97f767bfab 100644
--- a/datafusion/expr/src/window_frame.rs
+++ b/datafusion/expr/src/window_frame.rs
@@ -68,14 +68,14 @@ impl TryFrom<ast::WindowFrame> for WindowFrame {
if let WindowFrameBound::Following(val) = &start_bound {
if val.is_null() {
- return Err(DataFusionError::Execution(
+ return Err(DataFusionError::Plan(
"Invalid window frame: start bound cannot be unbounded following"
.to_owned(),
));
}
} else if let WindowFrameBound::Preceding(val) = &end_bound {
if val.is_null() {
- return Err(DataFusionError::Execution(
+ return Err(DataFusionError::Plan(
"Invalid window frame: end bound cannot be unbounded preceding"
.to_owned(),
));
@@ -256,9 +256,11 @@ pub fn convert_frame_bound_to_scalar_value(v: ast::Expr) -> Result<ScalarValue>
result
}
}
- e => {
- let msg = format!("Window frame bound cannot be {e:?}");
- return Err(DataFusionError::Internal(msg));
+ _ => {
+ return Err(DataFusionError::Plan(
+ "Invalid window frame: frame offsets must be non negative integers"
+ .to_owned(),
+ ));
}
})))
}
@@ -338,7 +340,7 @@ mod tests {
let err = WindowFrame::try_from(window_frame).unwrap_err();
assert_eq!(
err.to_string(),
- "Execution error: Invalid window frame: start bound cannot be unbounded following".to_owned()
+ "Error during planning: Invalid window frame: start bound cannot be unbounded following".to_owned()
);
let window_frame = ast::WindowFrame {
@@ -349,7 +351,7 @@ mod tests {
let err = WindowFrame::try_from(window_frame).unwrap_err();
assert_eq!(
err.to_string(),
- "Execution error: Invalid window frame: end bound cannot be unbounded preceding".to_owned()
+ "Error during planning: Invalid window frame: end bound cannot be unbounded preceding".to_owned()
);
let window_frame = ast::WindowFrame {