-
Notifications
You must be signed in to change notification settings - Fork 4.5k
[BEAM-4196][SQL] Support complex types in DDL #5276
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
apilloud
left a comment
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 awesome! You made it sound like it was weeks out when we talked earlier. It saddens me how much this moves us away from calcite/server but I can't say it is the wrong decision.
LGTM
| public class SqlDdlNodes { | ||
| private SqlDdlNodes() {} | ||
|
|
||
| /** Creates a CREATE TABLE. */ |
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 annoys me. I don't like this extra indirection in calcite but I also don't like deviating from calcite unnecessaraly. Not much you can do about that.
8db89ba to
acf5061
Compare
|
run java precommit |
kennknowles
left a comment
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 after some more tests
| + "name varchar COMMENT 'name', \n" | ||
| + "age int COMMENT 'age', \n" | ||
| + "tags MAP<VARCHAR, VARCHAR>, \n" | ||
| + "nestedMap MAP<INTEGER, MAP<VARCHAR, INTEGER>> \n" |
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.
Can you also test:
- maps inside arrays
- arrays inside maps
- rows inside arrays
- rows inside maps
- maps inside rows
- arrays inside rows
- nested nested rows
... etc ...
At some point we might want to use QuickCheck/SmallCheck; that is one of the best ways to test valid syntax.
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.
Will do
| fieldType = SimpleType() | ||
| ) | ||
| [ | ||
| collectionTypeName = CollectionTypeName() |
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 to support INT ARRAY in that syntax for it? TBH I don't think we need to start with that, even though it is "standard" all the related dialects don't use that syntax.
And I didn't realize JavaCC generated LL(k) parsers. That's unfortunate. So I can see why the grammar has to be factored like this. But what this doesn't support is (INT ARRAY) ARRAY or the no-parens version INT ARRAY ARRAY.
I suppose it is fine to leave as-is, but probably want to file something about the limitation, or tell me that I am wrong. And lots of tests. And also feel free to remove if you don't want the complication.
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.
Yes this clause is for the postfix array support. I left it mostly because it was already kinda there, just limited to MULTISETS, not arrays. We don't support either at the moment, and I would rather remove it for now for consistency
| "create table person (\n" | ||
| + "id int COMMENT 'id', \n" | ||
| + "name varchar(31) COMMENT 'name') \n" | ||
| + "name varchar COMMENT 'name') \n" |
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.
OK, I commented on the CLI test, but this is the better place for the parser tests.
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.
Adding QuickCheck tests
| public List<SqlNode> getOperandList() { | ||
| return ImmutableNullableList.of(name, columnList, type, comment, location, tblProperties); | ||
| throw new UnsupportedOperationException( | ||
| "Getting operands CREATE TABLE is unsupported at the moment"); |
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.
Just curious - where is it used? You can't really do much except copy the node if you don't know what kind of node it is, so just asking for my own education how Calcite (or BeamSQL) uses this.
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.
It's mostly used by implementations of the SqlCall to access their parameters. SqlCreate itself doesn't really need it but we might (or might not) need something like this for JDBC integration, depending on how CREATE TABLE parsing will be implemented there
…e types Create Schema.Fields instead of SqlDataTypeSpec, this will allow us to parse any types directly into Schema types, not limiting ourselves to primitive types supported by SqlDataTypeSpec
Add support for declaring fields of arrays of primitive types
Parse Row fields
Column is only used in Table for DDL and similar use cases. It seems better to use Schema in these places instead to avoid going back and forth between them
Support ARRAY<type> definition
Support MAP<primitiveTypeKey, typeValue>
Add support for Row<fields>
Add random arbitrary field type generation with QuickCheck to verify correctness of schema creation by CREATE TABLE
acf5061 to
8b349e3
Compare
|
Updated:
|
|
run java precommit |
|
whoa it's green |
|
Awesome. That's next-level test assurance. |
Support complex types in DDL
Supported syntax:
Follow this checklist to help us incorporate your contribution quickly and easily:
[BEAM-XXX] Fixes bug in ApproximateQuantiles, where you replaceBEAM-XXXwith the appropriate JIRA issue../gradlew buildto make sure basic checks pass. A more thorough check will be performed on your pull request automatically.