Skip to content

Commit 6b68a7f

Browse files
committed
duckdb: reject unsupported modified star projections during analysis
1 parent 3ad8b20 commit 6b68a7f

7 files changed

Lines changed: 18 additions & 2 deletions

File tree

‎internal/core/analyzer/expr.go‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,9 @@ func (a *analyzer) typeExpr(n ast.Node) (exprType, error) {
3232
return exprType{}, nil
3333

3434
case *ast.TODO:
35+
if e.UnsupportedFeature != "" {
36+
return exprType{}, fmt.Errorf("%s is not supported", e.UnsupportedFeature)
37+
}
3538
return exprType{}, nil
3639

3740
case *ast.A_Const:
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"command": "analyze",
3+
"args": ["--dialect", "duckdb", "--schema", "schema.sql", "query.sql"],
4+
"contexts": ["base"]
5+
}
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
-- name: PublicPeople :many
2+
SELECT * EXCLUDE (secret) FROM people;
3+
4+
-- name: RenumberedPeople :many
5+
SELECT * REPLACE (id + 1 AS id) FROM people;
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
CREATE TABLE people (id INTEGER, name VARCHAR, secret VARCHAR);
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Error: error parsing queries: query.sql:1:1: DuckDB star expression with modifiers or COLUMNS is not supported; query.sql:5:1: DuckDB star expression with modifiers or COLUMNS is not supported

‎internal/engine/duckdb/convert.go‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -770,7 +770,7 @@ func (c *cc) convertStar(e *dw.StarExpression) ast.Node {
770770
// COLUMNS(...) and EXCLUDE/REPLACE/RENAME modifiers have no equivalent.
771771
if e.Columns || e.Expr != nil || len(e.ExcludeList) > 0 ||
772772
len(e.QualifiedExcludeList) > 0 || len(e.ReplaceList) > 0 || len(e.RenameList) > 0 {
773-
return todo(e)
773+
return &ast.TODO{UnsupportedFeature: "DuckDB star expression with modifiers or COLUMNS"}
774774
}
775775
fields := &ast.List{}
776776
if e.RelationName != "" {

‎internal/sql/ast/todo.go‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
package ast
22

33
type TODO struct {
4-
Tag NodeTag[TODO] `json:"tag"`
4+
Tag NodeTag[TODO] `json:"tag"`
5+
UnsupportedFeature string `json:"unsupportedFeature,omitempty"`
56
}
67

78
func (n *TODO) Pos() int {

0 commit comments

Comments
 (0)