-
Notifications
You must be signed in to change notification settings - Fork 62
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
Support parsing for attribute and tuple level constraint #1442
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -75,9 +75,8 @@ execCommand | |
qualifiedName : (qualifier+=symbolPrimitive PERIOD)* name=symbolPrimitive; | ||
|
||
tableName : symbolPrimitive; | ||
tableConstraintName : symbolPrimitive; | ||
columnName : symbolPrimitive; | ||
columnConstraintName : symbolPrimitive; | ||
constraintName : symbolPrimitive; | ||
|
||
ddl | ||
: createCommand | ||
|
@@ -100,17 +99,43 @@ tableDef | |
|
||
tableDefPart | ||
: columnName type columnConstraint* # ColumnDeclaration | ||
| ( CONSTRAINT constraintName )? tableConstraintDef # TableConstrDeclaration | ||
; | ||
|
||
tableConstraintDef | ||
: checkConstraintDef # TableConstrCheck | ||
| uniqueConstraintDef # TableConstrUnique | ||
; | ||
|
||
columnConstraint | ||
: ( CONSTRAINT columnConstraintName )? columnConstraintDef | ||
: ( CONSTRAINT constraintName )? columnConstraintDef | ||
; | ||
|
||
columnConstraintDef | ||
: NOT NULL # ColConstrNotNull | ||
| NULL # ColConstrNull | ||
: NOT NULL # ColConstrNotNull | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Since the partiql-ast now uses "attribute" in the table definition, should the ANTLR definitions also use "attribute" rather than "column"? I think we should keep the parser and ast terminology consistent. Related -- would the PIG parser also need to be updated to use "attribute"? Perhaps it does't matter since the PIG parser is getting deprecated. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think this is a valid call out. But given the fact that Antlr grammar is an internal concern, perhaps we can treat this as a backlog item? I don't think we want to introduce changes to the PIG parser. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. At some point we would want to update the ANTLR grammar on our website. Perhaps then would be a good time to do those changes in batch? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Ah, I hadn't realized the current ANTLR-generated parse code was meant to be "internal" despite the visibility modifiers indicating it was "public". Created an issue to track the internalization of the ANTLR-generated sources -- #1446.
Since we'll likely have other changes to the ANTLR grammar before the DDL syntax is finalized, I'm fine w/ punting on the changes. Could you create an issue to track updating the website grammar and grammar within |
||
| NULL # ColConstrNull | ||
| uniqueSpec # ColConstrUnique | ||
| checkConstraintDef # ColConstrCheck | ||
; | ||
|
||
checkConstraintDef | ||
: CHECK PAREN_LEFT searchCondition PAREN_RIGHT | ||
; | ||
|
||
uniqueSpec | ||
: PRIMARY KEY # PrimaryKey | ||
| UNIQUE # Unique | ||
; | ||
|
||
uniqueConstraintDef | ||
: uniqueSpec PAREN_LEFT columnName (COMMA columnName)* PAREN_RIGHT | ||
; | ||
|
||
// <search condition> ::= <boolean term> | <search condition> OR <boolean term> | ||
// we cannot do exactly that for the way expression precedence is structured in the grammar file. | ||
// but we at least can eliminate SFW query here. | ||
searchCondition : exprOr; | ||
|
||
/** | ||
* | ||
* DATA MANIPULATION LANGUAGE (DML) | ||
|
@@ -192,9 +217,6 @@ conflictTarget | |
: PAREN_LEFT symbolPrimitive (COMMA symbolPrimitive)* PAREN_RIGHT | ||
| ON CONSTRAINT constraintName; | ||
|
||
constraintName | ||
: symbolPrimitive; | ||
|
||
conflictAction | ||
: DO NOTHING | ||
| DO REPLACE doReplace | ||
|
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.
out of curiosity, what's the rationale behind creating a separate
ddl_op
node rather than the previous modeling?