@@ -2436,22 +2436,24 @@ pub enum Statement {
24362436 id : u64 ,
24372437 } ,
24382438 /// ```sql
2439- /// EXPLAIN TABLE
2439+ /// [ EXPLAIN | DESC | DESCRIBE] TABLE
24402440 /// ```
24412441 /// Note: this is a MySQL-specific statement. See <https://dev.mysql.com/doc/refman/8.0/en/explain.html>
24422442 ExplainTable {
2443- /// If true, query used the MySQL `DESCRIBE` alias for explain
2444- describe_alias : bool ,
2443+ /// `EXPLAIN | DESC | DESCRIBE`
2444+ describe_alias : DescribeAlias ,
2445+ /// Hive style `FORMATTED | EXTENDED`
2446+ hive_format : Option < HiveDescribeFormat > ,
24452447 /// Table name
24462448 #[ cfg_attr( feature = "visitor" , visit( with = "visit_relation" ) ) ]
24472449 table_name : ObjectName ,
24482450 } ,
24492451 /// ```sql
2450- /// [EXPLAIN | DESCRIBE <select statement>
2452+ /// [EXPLAIN | DESC | DESCRIBE] < statement>
24512453 /// ```
24522454 Explain {
2453- // If true, query used the MySQL ` DESCRIBE` alias for explain
2454- describe_alias : bool ,
2455+ /// `EXPLAIN | DESC | DESCRIBE`
2456+ describe_alias : DescribeAlias ,
24552457 /// Carry out the command and show actual run times and other statistics.
24562458 analyze : bool ,
24572459 // Display additional information regarding the plan.
@@ -2611,12 +2613,13 @@ impl fmt::Display for Statement {
26112613 }
26122614 Statement :: ExplainTable {
26132615 describe_alias,
2616+ hive_format,
26142617 table_name,
26152618 } => {
2616- if * describe_alias {
2617- write ! ( f , "DESCRIBE " ) ? ;
2618- } else {
2619- write ! ( f, "EXPLAIN " ) ?;
2619+ write ! ( f , "{ describe_alias} " ) ? ;
2620+
2621+ if let Some ( format ) = hive_format {
2622+ write ! ( f, "{} " , format ) ?;
26202623 }
26212624
26222625 write ! ( f, "{table_name}" )
@@ -2628,11 +2631,7 @@ impl fmt::Display for Statement {
26282631 statement,
26292632 format,
26302633 } => {
2631- if * describe_alias {
2632- write ! ( f, "DESCRIBE " ) ?;
2633- } else {
2634- write ! ( f, "EXPLAIN " ) ?;
2635- }
2634+ write ! ( f, "{describe_alias} " ) ?;
26362635
26372636 if * analyze {
26382637 write ! ( f, "ANALYZE " ) ?;
@@ -4925,6 +4924,44 @@ impl fmt::Display for HiveDelimiter {
49254924 }
49264925}
49274926
4927+ #[ derive( Debug , Copy , Clone , PartialEq , PartialOrd , Eq , Ord , Hash ) ]
4928+ #[ cfg_attr( feature = "serde" , derive( Serialize , Deserialize ) ) ]
4929+ #[ cfg_attr( feature = "visitor" , derive( Visit , VisitMut ) ) ]
4930+ pub enum HiveDescribeFormat {
4931+ Extended ,
4932+ Formatted ,
4933+ }
4934+
4935+ impl fmt:: Display for HiveDescribeFormat {
4936+ fn fmt ( & self , f : & mut fmt:: Formatter < ' _ > ) -> fmt:: Result {
4937+ use HiveDescribeFormat :: * ;
4938+ f. write_str ( match self {
4939+ Extended => "EXTENDED" ,
4940+ Formatted => "FORMATTED" ,
4941+ } )
4942+ }
4943+ }
4944+
4945+ #[ derive( Debug , Copy , Clone , PartialEq , PartialOrd , Eq , Ord , Hash ) ]
4946+ #[ cfg_attr( feature = "serde" , derive( Serialize , Deserialize ) ) ]
4947+ #[ cfg_attr( feature = "visitor" , derive( Visit , VisitMut ) ) ]
4948+ pub enum DescribeAlias {
4949+ Describe ,
4950+ Explain ,
4951+ Desc ,
4952+ }
4953+
4954+ impl fmt:: Display for DescribeAlias {
4955+ fn fmt ( & self , f : & mut fmt:: Formatter < ' _ > ) -> fmt:: Result {
4956+ use DescribeAlias :: * ;
4957+ f. write_str ( match self {
4958+ Describe => "DESCRIBE" ,
4959+ Explain => "EXPLAIN" ,
4960+ Desc => "DESC" ,
4961+ } )
4962+ }
4963+ }
4964+
49284965#[ derive( Debug , Clone , PartialEq , PartialOrd , Eq , Ord , Hash ) ]
49294966#[ cfg_attr( feature = "serde" , derive( Serialize , Deserialize ) ) ]
49304967#[ cfg_attr( feature = "visitor" , derive( Visit , VisitMut ) ) ]
0 commit comments