Skip to content

Commit 38692a4

Browse files
authored
bring up JOIN USING and make README query work (#5477)
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.
1 parent 0f2ddc4 commit 38692a4

File tree

9 files changed

+3220
-3218
lines changed

9 files changed

+3220
-3218
lines changed

compiler/ast/ast.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -535,8 +535,7 @@ type (
535535
Kind string `json:"kind" unpack:""`
536536
Style string `json:"style"`
537537
RightInput Seq `json:"right_input"`
538-
LeftKey Expr `json:"left_key"`
539-
RightKey Expr `json:"right_key"`
538+
Cond JoinExpr `json:"cond"`
540539
Args Assignments `json:"args"`
541540
Loc `json:"loc"`
542541
}

compiler/ast/sql.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -87,24 +87,24 @@ type (
8787

8888
type JoinExpr interface {
8989
Node
90-
joinOp()
90+
joinExpr()
9191
}
9292

93-
type JoinOn struct {
93+
type JoinOnExpr struct {
9494
Kind string `json:"kind" unpack:""`
9595
Expr Expr `json:"expr"`
9696
Loc `json:"loc"`
9797
}
9898

99-
func (*JoinOn) joinOp() {}
99+
func (*JoinOnExpr) joinExpr() {}
100100

101-
type JoinUsing struct {
101+
type JoinUsingExpr struct {
102102
Kind string `json:"kind" unpack:""`
103103
Fields []Expr `json:"fields"`
104104
Loc `json:"loc"`
105105
}
106106

107-
func (*JoinUsing) joinOp() {}
107+
func (*JoinUsingExpr) joinExpr() {}
108108

109109
func (*SQLPipe) OpAST() {}
110110
func (*Select) OpAST() {}

compiler/ast/unpack.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -109,8 +109,8 @@ var unpacker = unpack.New(
109109
OrderBy{},
110110
Limit{},
111111
With{},
112-
JoinOn{},
113-
JoinUsing{},
112+
JoinOnExpr{},
113+
JoinUsingExpr{},
114114
)
115115

116116
// UnmarshalOp transforms a JSON representation of an operator into an Op.

0 commit comments

Comments
 (0)