-
Notifications
You must be signed in to change notification settings - Fork 27
parsing intersect and except
#271
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
|
As per our discussion, we need tests to make sure that we're parsing with the correct operator precedence. ( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm, very clever way of implementing precedence, just requesting some docs so we can remember how it works in the future
| $$ = $1 | ||
| } | ||
|
|
||
| set_op: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is clever but might be confusing for someone without context. It might be helpful to give an example like {1,2} ∩ {2,3} U {3,4} has two results depending on whether you execute the intersect or union first (same as addition/multiplication). Here is 3 sentences that make it clear how we enforce INTERSECT being executed before UNION/EXCEPT...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Agreed. It's clever but I'm still not entire sure I understand how it works. Some documentation would be really helpful.
| } | ||
|
|
||
| // Union.Type | ||
| // SetOp.Type |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
would it be dumb to rewrite this into "SetOpType" and distinct as a bool? or does that lose information
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not dumb, and it doesn't lose any information.
I just duplicated the existing logic; I'm pretty sure it was written that way in the first place so the yacc code is simpler.
Could just do
$$ = UnionStr
$$ = UnionAllStr
$$ = UnionDistinctStrand convert it later instead of returning a new struct
|
|
||
| type Statements []Statement | ||
|
|
||
| func (*Union) iStatement() {} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks like the whitespace got messed up in this file.
| $$ = $1 | ||
| } | ||
|
|
||
| set_op: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Agreed. It's clever but I'm still not entire sure I understand how it works. Some documentation would be really helpful.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good now. Thanks!
This PR adds support for parsing the keywords
INTERSECTandEXCEPT.These work similar to
UNIONand work withDISTINCTandALLkeywords.Additionally, there are new precedence tests;
INTERSECThas a higher precedence thanUNIONandEXCEPT.The rest are parsed left to right.
syntax for dolthub/dolt#6643