@@ -120,6 +120,18 @@ func explainCreateQuery(sb *strings.Builder, n *ast.CreateQuery, indent string,
120120 if len (n .OrderBy ) == 1 {
121121 if ident , ok := n .OrderBy [0 ].(* ast.Identifier ); ok {
122122 fmt .Fprintf (sb , "%s Identifier %s\n " , indent , ident .Name ())
123+ } else if lit , ok := n .OrderBy [0 ].(* ast.Literal ); ok && lit .Type == ast .LiteralTuple {
124+ // Handle tuple literal (including empty tuple from ORDER BY ())
125+ exprs , _ := lit .Value .([]ast.Expression )
126+ fmt .Fprintf (sb , "%s Function tuple (children %d)\n " , indent , 1 )
127+ if len (exprs ) > 0 {
128+ fmt .Fprintf (sb , "%s ExpressionList (children %d)\n " , indent , len (exprs ))
129+ for _ , e := range exprs {
130+ Node (sb , e , depth + 4 )
131+ }
132+ } else {
133+ fmt .Fprintf (sb , "%s ExpressionList\n " , indent )
134+ }
123135 } else {
124136 Node (sb , n .OrderBy [0 ], depth + 2 )
125137 }
@@ -135,6 +147,18 @@ func explainCreateQuery(sb *strings.Builder, n *ast.CreateQuery, indent string,
135147 if len (n .PrimaryKey ) == 1 {
136148 if ident , ok := n .PrimaryKey [0 ].(* ast.Identifier ); ok {
137149 fmt .Fprintf (sb , "%s Identifier %s\n " , indent , ident .Name ())
150+ } else if lit , ok := n .PrimaryKey [0 ].(* ast.Literal ); ok && lit .Type == ast .LiteralTuple {
151+ // Handle tuple literal (including empty tuple from PRIMARY KEY ())
152+ exprs , _ := lit .Value .([]ast.Expression )
153+ fmt .Fprintf (sb , "%s Function tuple (children %d)\n " , indent , 1 )
154+ if len (exprs ) > 0 {
155+ fmt .Fprintf (sb , "%s ExpressionList (children %d)\n " , indent , len (exprs ))
156+ for _ , e := range exprs {
157+ Node (sb , e , depth + 4 )
158+ }
159+ } else {
160+ fmt .Fprintf (sb , "%s ExpressionList\n " , indent )
161+ }
138162 } else {
139163 Node (sb , n .PrimaryKey [0 ], depth + 2 )
140164 }
@@ -156,12 +180,23 @@ func explainCreateQuery(sb *strings.Builder, n *ast.CreateQuery, indent string,
156180 }
157181}
158182
159- func explainDropQuery (sb * strings.Builder , n * ast.DropQuery , indent string ) {
183+ func explainDropQuery (sb * strings.Builder , n * ast.DropQuery , indent string , depth int ) {
160184 // DROP USER has a special output format
161185 if n .User != "" {
162186 fmt .Fprintf (sb , "%sDROP USER query\n " , indent )
163187 return
164188 }
189+
190+ // Handle multiple tables: DROP TABLE t1, t2, t3
191+ if len (n .Tables ) > 1 {
192+ fmt .Fprintf (sb , "%sDropQuery (children %d)\n " , indent , 1 )
193+ fmt .Fprintf (sb , "%s ExpressionList (children %d)\n " , indent , len (n .Tables ))
194+ for _ , t := range n .Tables {
195+ Node (sb , t , depth + 2 )
196+ }
197+ return
198+ }
199+
165200 name := n .Table
166201 if n .View != "" {
167202 name = n .View
0 commit comments