You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
add catalog as part of the table path in plan_to_sql (#10612)
* add catalog as part of the table path in plan_to_sql
* Update datafusion/sql/src/unparser/plan.rs
Co-authored-by: Phillip LeBlanc <[email protected]>
---------
Co-authored-by: Phillip LeBlanc <[email protected]>
@@ -505,3 +508,35 @@ impl From<BuilderError> for DataFusionError {
505
508
DataFusionError::External(Box::new(e))
506
509
}
507
510
}
511
+
512
+
#[cfg(test)]
513
+
mod test {
514
+
usecrate::unparser::plan_to_sql;
515
+
use arrow::datatypes::{DataType,Field,Schema};
516
+
use datafusion_expr::{col, logical_plan::table_scan};
517
+
#[test]
518
+
fntest_table_references_in_plan_to_sql(){
519
+
fntest(table_name:&str,expected_sql:&str){
520
+
let schema = Schema::new(vec![
521
+
Field::new("id",DataType::Utf8,false),
522
+
Field::new("value",DataType::Utf8,false),
523
+
]);
524
+
let plan = table_scan(Some(table_name),&schema,None)
525
+
.unwrap()
526
+
.project(vec![col("id"), col("value")])
527
+
.unwrap()
528
+
.build()
529
+
.unwrap();
530
+
let sql = plan_to_sql(&plan).unwrap();
531
+
532
+
assert_eq!(format!("{}", sql), expected_sql)
533
+
}
534
+
535
+
test("catalog.schema.table","SELECT \"catalog\".\"schema\".\"table\".\"id\", \"catalog\".\"schema\".\"table\".\"value\" FROM \"catalog\".\"schema\".\"table\"");
536
+
test("schema.table","SELECT \"schema\".\"table\".\"id\", \"schema\".\"table\".\"value\" FROM \"schema\".\"table\"");
537
+
test(
538
+
"table",
539
+
"SELECT \"table\".\"id\", \"table\".\"value\" FROM \"table\"",
0 commit comments