Skip to content

Commit

Permalink
allow select operator to receive input from parent (#5422)
Browse files Browse the repository at this point in the history
This commit allows the SQL select operator to receive it's
input from it's parent in a pipeline when no from clause is
present.  This means that bare select queries work on constant
values now since the default parent will be a single null value.

We also brought the column naming semantics into closer alignment
with SQL where selected columns also have a string name and not
a dotted field path.

The SQL semantic logic has been simplified and expand further as
we make progress toward our binder-in-the-data approach to
SQL scoping.
  • Loading branch information
mccanne authored Nov 3, 2024
1 parent 36353b1 commit 7b6b955
Show file tree
Hide file tree
Showing 8 changed files with 1,240 additions and 1,211 deletions.
33 changes: 24 additions & 9 deletions compiler/ast/sql.go
Original file line number Diff line number Diff line change
@@ -1,15 +1,21 @@
package ast

type Select struct {
Kind string `json:"kind" unpack:""`
Distinct bool `json:"distinct"`
Value bool `json:"value"`
Args Assignments `json:"args"`
From *From `json:"from"`
Where Expr `json:"where"`
GroupBy []Expr `json:"group_by"`
Having Expr `json:"having"`
Loc `json:"loc"`
Kind string `json:"kind" unpack:""`
Distinct bool `json:"distinct"`
Value bool `json:"value"`
Selection Selection `json:"selection"`
From *From `json:"from"`
Where Expr `json:"where"`
GroupBy []Expr `json:"group_by"`
Having Expr `json:"having"`
Loc `json:"loc"`
}

type Selection struct {
Kind string `json:"kind" unpack:""`
Args []AsExpr `json:"args"`
Loc `json:"loc"`
}

// SQLPipe turns a Seq into an Op. We need this to put pipes inside
Expand Down Expand Up @@ -108,3 +114,12 @@ func (*Union) OpAST() {}
func (*OrderBy) OpAST() {}
func (*Limit) OpAST() {}
func (*With) OpAST() {}

type AsExpr struct {
Kind string `json:"kind" unpack:""`
ID *ID `json:"id"`
Expr Expr `json:"expr"`
Loc `json:"loc"`
}

func (*AsExpr) ExprAST() {}
Loading

0 comments on commit 7b6b955

Please sign in to comment.