Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions datafusion/sql/src/planner.rs
Original file line number Diff line number Diff line change
Expand Up @@ -354,6 +354,12 @@ impl<'a, S: ContextProvider> SqlToRel<'a, S> {
if let Some(with) = query.with {
// Process CTEs from top to bottom
// do not allow self-references
if with.recursive {
return Err(DataFusionError::NotImplemented(
"Recursive CTEs are not supported".to_string(),
));
}

for cte in with.cte_tables {
// A `WITH` block can't use the same name more than once
let cte_name = normalize_ident(&cte.alias.name);
Expand Down Expand Up @@ -3530,6 +3536,22 @@ mod tests {
);
}

#[test]
fn recursive_ctes() {
let sql = "
WITH RECURSIVE numbers AS (
select 1 as n
UNION ALL
select n + 1 FROM numbers WHERE N < 10
)
select * from numbers;";
let err = logical_plan(sql).expect_err("query should have failed");
assert_eq!(
r#"NotImplemented("Recursive CTEs are not supported")"#,
format!("{:?}", err)
);
}

#[test]
fn select_array_non_literal_type() {
let sql = "SELECT [now()]";
Expand Down