Skip to content

Commit

Permalink
bring up JOIN USING and make README query work (#5477)
Browse files Browse the repository at this point in the history
This commit gets the using condition for joins working and now allows
the query that is now in the top-level README to work.  We unified
some of the join logic between SQL and SPQ and relaxed some of the
checking of group-by keys with selection, which had been too aggressive.
We also added a test that emulates the README query with smaller data
in local files rather than APIs and we fixed up the README query to add 
the repos field from the RHS of the join  to make it more interesting.
  • Loading branch information
mccanne authored Nov 13, 2024
1 parent 0f2ddc4 commit 38692a4
Show file tree
Hide file tree
Showing 9 changed files with 3,220 additions and 3,218 deletions.
3 changes: 1 addition & 2 deletions compiler/ast/ast.go
Original file line number Diff line number Diff line change
Expand Up @@ -535,8 +535,7 @@ type (
Kind string `json:"kind" unpack:""`
Style string `json:"style"`
RightInput Seq `json:"right_input"`
LeftKey Expr `json:"left_key"`
RightKey Expr `json:"right_key"`
Cond JoinExpr `json:"cond"`
Args Assignments `json:"args"`
Loc `json:"loc"`
}
Expand Down
10 changes: 5 additions & 5 deletions compiler/ast/sql.go
Original file line number Diff line number Diff line change
Expand Up @@ -87,24 +87,24 @@ type (

type JoinExpr interface {
Node
joinOp()
joinExpr()
}

type JoinOn struct {
type JoinOnExpr struct {
Kind string `json:"kind" unpack:""`
Expr Expr `json:"expr"`
Loc `json:"loc"`
}

func (*JoinOn) joinOp() {}
func (*JoinOnExpr) joinExpr() {}

type JoinUsing struct {
type JoinUsingExpr struct {
Kind string `json:"kind" unpack:""`
Fields []Expr `json:"fields"`
Loc `json:"loc"`
}

func (*JoinUsing) joinOp() {}
func (*JoinUsingExpr) joinExpr() {}

func (*SQLPipe) OpAST() {}
func (*Select) OpAST() {}
Expand Down
4 changes: 2 additions & 2 deletions compiler/ast/unpack.go
Original file line number Diff line number Diff line change
Expand Up @@ -109,8 +109,8 @@ var unpacker = unpack.New(
OrderBy{},
Limit{},
With{},
JoinOn{},
JoinUsing{},
JoinOnExpr{},
JoinUsingExpr{},
)

// UnmarshalOp transforms a JSON representation of an operator into an Op.
Expand Down
Loading

0 comments on commit 38692a4

Please sign in to comment.