MCPcopy Create free account
hub / github.com/apache/datafusion / show_create_table_to_plan

Method show_create_table_to_plan

datafusion/sql/src/statement.rs:2636–2662  ·  view source on GitHub ↗
(
        &self,
        sql_table_name: ObjectName,
    )

Source from the content-addressed store, hash-verified

2634 }
2635
2636 fn show_create_table_to_plan(
2637 &self,
2638 sql_table_name: ObjectName,
2639 ) -> Result<LogicalPlan> {
2640 if !self.has_table("information_schema", "tables") {
2641 return plan_err!(
2642 "SHOW CREATE TABLE is not supported unless information_schema is enabled"
2643 );
2644 }
2645 // Figure out the where clause
2646 let where_clause = object_name_to_qualifier(
2647 &sql_table_name,
2648 self.options.enable_ident_normalization,
2649 )?;
2650
2651 // Do a table lookup to verify the table exists
2652 let table_ref = self.object_name_to_table_reference(sql_table_name)?;
2653 let _ = self.context_provider.get_table_source(table_ref)?;
2654
2655 let query = format!(
2656 "SELECT table_catalog, table_schema, table_name, definition FROM information_schema.views WHERE {where_clause}"
2657 );
2658
2659 let mut rewrite = DFParser::parse_sql(&query)?;
2660 assert_eq!(rewrite.len(), 1);
2661 self.statement_to_plan(rewrite.pop_front().unwrap()) // length of rewrite is 1
2662 }
2663
2664 /// Return true if there is a table provider available for "schema.table"
2665 fn has_table(&self, schema: &str, table: &str) -> bool {

Calls 6

object_name_to_qualifierFunction · 0.85
has_tableMethod · 0.80
pop_frontMethod · 0.80
get_table_sourceMethod · 0.45
statement_to_planMethod · 0.45

Tested by

no test coverage detected