@@ -54,7 +54,7 @@ use datafusion_expr::{
5454 TransactionConclusion , TransactionEnd , TransactionIsolationLevel , TransactionStart ,
5555 Volatility , WriteOp ,
5656} ;
57- use sqlparser:: ast:: { self , SqliteOnConflict } ;
57+ use sqlparser:: ast:: { self , ShowStatementOptions , SqliteOnConflict } ;
5858use sqlparser:: ast:: {
5959 Assignment , AssignmentTarget , ColumnDef , CreateIndex , CreateTable ,
6060 CreateTableOptions , Delete , DescribeAlias , Expr as SQLExpr , FromTable , Ident , Insert ,
@@ -685,18 +685,51 @@ impl<'a, S: ContextProvider> SqlToRel<'a, S> {
685685 Statement :: ShowTables {
686686 extended,
687687 full,
688- terse : _, // TODO throw errors for unsupported options
689- history : _,
690- external : _,
691- show_options : _,
692- //db_name,
693- //filter,
694- // SHOW TABLES IN/FROM are equivalent, this field specifies which the user
695- // specified, but it doesn't affect the plan so ignore the field
696- //clause: _,
688+ terse,
689+ history,
690+ external,
691+ show_options,
697692 } => {
698- todo ! ( "Update show tables/ fix for new syntax" ) ;
699- // self.show_tables_to_plan(extended, full, db_name, filter)
693+ // We only support the basic "SHOW TABLES"
694+ // https://github.com/apache/datafusion/issues/3188
695+ if extended {
696+ return not_impl_err ! ( "SHOW TABLES EXTENDED not supported" ) ?;
697+ }
698+ if full {
699+ return not_impl_err ! ( "SHOW FULL TABLES not supported" ) ?;
700+ }
701+ if terse {
702+ return not_impl_err ! ( "SHOW TERSE TABLES not supported" ) ?;
703+ }
704+ if history {
705+ return not_impl_err ! ( "SHOW TABLES HISTORY not supported" ) ?;
706+ }
707+ if external {
708+ return not_impl_err ! ( "SHOW EXTERNAL TABLES not supported" ) ?;
709+ }
710+ let ShowStatementOptions {
711+ show_in,
712+ starts_with,
713+ limit,
714+ limit_from,
715+ filter_position,
716+ } = show_options;
717+ if show_in. is_some ( ) {
718+ return not_impl_err ! ( "SHOW TABLES IN not supported" ) ?;
719+ }
720+ if starts_with. is_some ( ) {
721+ return not_impl_err ! ( "SHOW TABLES LIKE not supported" ) ?;
722+ }
723+ if limit. is_some ( ) {
724+ return not_impl_err ! ( "SHOW TABLES LIMIT not supported" ) ?;
725+ }
726+ if limit_from. is_some ( ) {
727+ return not_impl_err ! ( "SHOW TABLES LIMIT FROM not supported" ) ?;
728+ }
729+ if filter_position. is_some ( ) {
730+ return not_impl_err ! ( "SHOW TABLES FILTER not supported" ) ?;
731+ }
732+ self . show_tables_to_plan ( )
700733 }
701734
702735 Statement :: ShowColumns {
@@ -1080,24 +1113,12 @@ impl<'a, S: ContextProvider> SqlToRel<'a, S> {
10801113 }
10811114
10821115 /// Generate a logical plan from a "SHOW TABLES" query
1083- fn show_tables_to_plan (
1084- & self ,
1085- extended : bool ,
1086- full : bool ,
1087- db_name : Option < Ident > ,
1088- filter : Option < ShowStatementFilter > ,
1089- ) -> Result < LogicalPlan > {
1116+ fn show_tables_to_plan ( & self ) -> Result < LogicalPlan > {
10901117 if self . has_table ( "information_schema" , "tables" ) {
1091- // We only support the basic "SHOW TABLES"
1092- // https://github.com/apache/datafusion/issues/3188
1093- if db_name. is_some ( ) || filter. is_some ( ) || full || extended {
1094- plan_err ! ( "Unsupported parameters to SHOW TABLES" )
1095- } else {
1096- let query = "SELECT * FROM information_schema.tables;" ;
1097- let mut rewrite = DFParser :: parse_sql ( query) ?;
1098- assert_eq ! ( rewrite. len( ) , 1 ) ;
1099- self . statement_to_plan ( rewrite. pop_front ( ) . unwrap ( ) ) // length of rewrite is 1
1100- }
1118+ let query = "SELECT * FROM information_schema.tables;" ;
1119+ let mut rewrite = DFParser :: parse_sql ( query) ?;
1120+ assert_eq ! ( rewrite. len( ) , 1 ) ;
1121+ self . statement_to_plan ( rewrite. pop_front ( ) . unwrap ( ) ) // length of rewrite is 1
11011122 } else {
11021123 plan_err ! ( "SHOW TABLES is not supported unless information_schema is enabled" )
11031124 }
0 commit comments