(
&self,
sql_table_name: ObjectName,
)
| 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 { |
no test coverage detected