Skip to content
Merged
Show file tree
Hide file tree
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
1 change: 1 addition & 0 deletions datafusion/core/src/sql/planner.rs
Original file line number Diff line number Diff line change
Expand Up @@ -324,6 +324,7 @@ impl<'a, S: ContextProvider> SqlToRel<'a, S> {
}
}
}
SetExpr::Query(q) => self.query_to_plan(*q, ctes),
_ => Err(DataFusionError::NotImplemented(format!(
"Query {} not implemented yet",
set_expr
Expand Down
24 changes: 24 additions & 0 deletions datafusion/core/tests/sql/expr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
// specific language governing permissions and limitations
// under the License.

use datafusion::datasource::empty::EmptyTable;

use super::*;

#[tokio::test]
Expand Down Expand Up @@ -1127,3 +1129,25 @@ async fn csv_query_sqrt_sqrt() -> Result<()> {
assert_float_eq(&expected, &actual);
Ok(())
}

#[tokio::test]
async fn nested_subquery() -> Result<()> {
let ctx = SessionContext::new();
let schema = Schema::new(vec![
Field::new("id", DataType::Int16, false),
Field::new("a", DataType::Int16, false),
]);
let empty_table = Arc::new(EmptyTable::new(Arc::new(schema)));
ctx.register_table("t1", empty_table.clone())?;
ctx.register_table("t2", empty_table)?;
let sql = "SELECT COUNT(*) as cnt \
FROM (\
(SELECT id FROM t1) EXCEPT \
(SELECT id FROM t2)\
) foo";
let actual = execute_to_batches(&ctx, sql).await;
// the purpose of this test is just to make sure the query produces a valid plan
let expected = vec!["+-----+", "| cnt |", "+-----+", "| 0 |", "+-----+"];
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you disable rustfmt for this line and format it so that it is easier to read, as shown in #2413

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm going to go ahead and merge this. Perhaps we can improve the test formatting as a separate PR.

assert_batches_eq!(expected, &actual);
Ok(())
}