Skip to content

Commit

Permalink
fix: return NotImplemented when execute SELECT INTO syntax (apach…
Browse files Browse the repository at this point in the history
…e#5945)

* fix: return `NotImplemented` when execute `SELECT INTO` syntax

* chore: add tests for select unsupported syntax
  • Loading branch information
r4ntix authored and korowa committed Apr 13, 2023
1 parent 3a762a4 commit a75dd0f
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 0 deletions.
3 changes: 3 additions & 0 deletions datafusion/sql/src/select.rs
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,9 @@ impl<'a, S: ContextProvider> SqlToRel<'a, S> {
if !select.sort_by.is_empty() {
return Err(DataFusionError::NotImplemented("SORT BY".to_string()));
}
if select.into.is_some() {
return Err(DataFusionError::NotImplemented("INTO".to_string()));
}

// process `from` clause
let plan = self.plan_from_tables(select.from, planner_context)?;
Expand Down
31 changes: 31 additions & 0 deletions datafusion/sql/tests/integration_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3366,6 +3366,37 @@ fn test_select_distinct_order_by() {
assert_eq!(err.to_string(), expected);
}

#[rstest]
#[case::select_cluster_by_unsupported(
"SELECT customer_name, SUM(order_total) as total_order_amount FROM orders CLUSTER BY customer_name",
"This feature is not implemented: CLUSTER BY"
)]
#[case::select_lateral_view_unsupported(
"SELECT id, number FROM person LATERAL VIEW explode(numbers) exploded_table AS number",
"This feature is not implemented: LATERAL VIEWS"
)]
#[case::select_qualify_unsupported(
"SELECT i, p, o FROM person QUALIFY ROW_NUMBER() OVER (PARTITION BY p ORDER BY o) = 1",
"This feature is not implemented: QUALIFY"
)]
#[case::select_top_unsupported(
"SELECT TOP (5) * FROM person",
"This feature is not implemented: TOP"
)]
#[case::select_sort_by_unsupported(
"SELECT * FROM person SORT BY id",
"This feature is not implemented: SORT BY"
)]
#[case::select_into_unsupported(
"SELECT * INTO test FROM person",
"This feature is not implemented: INTO"
)]
#[test]
fn test_select_unsupported_syntax_errors(#[case] sql: &str, #[case] error: &str) {
let err = logical_plan(sql).unwrap_err();
assert_eq!(err.to_string(), error)
}

#[test]
fn select_order_by_with_cast() {
let sql =
Expand Down

0 comments on commit a75dd0f

Please sign in to comment.