Skip to content

Commit e62fd78

Browse files
committed
Add PARTITION BY support and fix tuple expansion
- Add PARTITION BY output to CREATE TABLE Storage definition - Treat nested tuple/array literals as complex expressions for expansion This fixes 20 more tests (5849 -> 5869 passing).
1 parent fc06a9b commit e62fd78

File tree

2 files changed

+15
-3
lines changed

2 files changed

+15
-3
lines changed

internal/explain/expressions.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,9 @@ func explainLiteral(sb *strings.Builder, n *ast.Literal, indent string, depth in
2929
}
3030
hasComplexExpr := false
3131
for _, e := range exprs {
32-
if _, isLit := e.(*ast.Literal); !isLit {
32+
lit, isLit := e.(*ast.Literal)
33+
// Non-literals or tuple/array literals count as complex
34+
if !isLit || (isLit && (lit.Type == ast.LiteralTuple || lit.Type == ast.LiteralArray)) {
3335
hasComplexExpr = true
3436
break
3537
}

internal/explain/statements.go

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ func explainCreateQuery(sb *strings.Builder, n *ast.CreateQuery, indent string,
5656
if len(n.Columns) > 0 {
5757
children++
5858
}
59-
if n.Engine != nil || len(n.OrderBy) > 0 || len(n.PrimaryKey) > 0 {
59+
if n.Engine != nil || len(n.OrderBy) > 0 || len(n.PrimaryKey) > 0 || n.PartitionBy != nil {
6060
children++
6161
}
6262
if n.AsSelect != nil {
@@ -76,11 +76,14 @@ func explainCreateQuery(sb *strings.Builder, n *ast.CreateQuery, indent string,
7676
Column(sb, col, depth+3)
7777
}
7878
}
79-
if n.Engine != nil || len(n.OrderBy) > 0 || len(n.PrimaryKey) > 0 || len(n.Settings) > 0 {
79+
if n.Engine != nil || len(n.OrderBy) > 0 || len(n.PrimaryKey) > 0 || n.PartitionBy != nil || len(n.Settings) > 0 {
8080
storageChildren := 0
8181
if n.Engine != nil {
8282
storageChildren++
8383
}
84+
if n.PartitionBy != nil {
85+
storageChildren++
86+
}
8487
if len(n.OrderBy) > 0 {
8588
storageChildren++
8689
}
@@ -106,6 +109,13 @@ func explainCreateQuery(sb *strings.Builder, n *ast.CreateQuery, indent string,
106109
fmt.Fprintf(sb, "%s Function %s\n", indent, n.Engine.Name)
107110
}
108111
}
112+
if n.PartitionBy != nil {
113+
if ident, ok := n.PartitionBy.(*ast.Identifier); ok {
114+
fmt.Fprintf(sb, "%s Identifier %s\n", indent, ident.Name())
115+
} else {
116+
Node(sb, n.PartitionBy, depth+2)
117+
}
118+
}
109119
if len(n.OrderBy) > 0 {
110120
if len(n.OrderBy) == 1 {
111121
if ident, ok := n.OrderBy[0].(*ast.Identifier); ok {

0 commit comments

Comments
 (0)