Skip to content

Commit

Permalink
add integration-test
Browse files Browse the repository at this point in the history
  • Loading branch information
jackwener committed Feb 21, 2023
1 parent 43bbeb3 commit 945a96e
Showing 1 changed file with 17 additions and 4 deletions.
21 changes: 17 additions & 4 deletions datafusion/optimizer/tests/integration-test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -320,6 +320,22 @@ fn push_down_filter_groupby_expr_contains_alias() {
assert_eq!(expected, format!("{plan:?}"));
}

#[test]
// issue: https://github.com/apache/arrow-datafusion/issues/5334
fn test_same_name_but_not_ambiguous() {
let sql = "SELECT t1.col_int32 AS col_int32 FROM test t1 intersect SELECT col_int32 FROM test t2";
let plan = test_sql(sql).unwrap();
let expected = "LeftSemi Join: col_int32 = t2.col_int32\
\n Distinct:\
\n Projection: t1.col_int32 AS col_int32\
\n SubqueryAlias: t1\
\n TableScan: test projection=[col_int32]\
\n Projection: t2.col_int32\
\n SubqueryAlias: t2\
\n TableScan: test projection=[col_int32]";
assert_eq!(expected, format!("{plan:?}"));
}

fn test_sql(sql: &str) -> Result<LogicalPlan> {
// parse the SQL
let dialect = GenericDialect {}; // or AnsiDialect, or your own dialect ...
Expand Down Expand Up @@ -348,10 +364,7 @@ struct MySchemaProvider {
}

impl ContextProvider for MySchemaProvider {
fn get_table_provider(
&self,
name: TableReference,
) -> datafusion_common::Result<Arc<dyn TableSource>> {
fn get_table_provider(&self, name: TableReference) -> Result<Arc<dyn TableSource>> {
let table_name = name.table();
if table_name.starts_with("test") {
let schema = Schema::new_with_metadata(
Expand Down

0 comments on commit 945a96e

Please sign in to comment.