[CALCITE-6275] Parser for data types ignores element nullability in collections #3698
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This modifies the parser to accept types such as INTEGER NOT NULL ARRAY NULL for column types.
The only thing I don't like too much about this PR is the fact that this type is unparsed differently depending on where it appears:
These two not the same type at all, but other databases, such as Postgres, also do not accept types with nullabilities in casts. Maybe that's a bug in Postgres as well, or maybe in the SQL handling of collection types in general?
In order to provide this behavior I had to add some state to the SqlWriter which indicates the context where a type is being unparsed. Fortunately, types cannot contain other kinds of SqlNodes - e.g., expressions - so a stack of context is not necessary, a scalar will do.