-
Notifications
You must be signed in to change notification settings - Fork 2.5k
[CALCITE-7339] Most classes in SqlDdlNodes use an incorrect SqlCallFactory #4696
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
5978019 to
e73665b
Compare
|
I don't understand this place very well. It would be great if @dssysolyatin could help to take a look. |
|
@mihaibudiu You decided not to wait for the PR #4644 and did the work yourself. That’s totally understandable. I’m sorry I couldn’t finish my PR in time, so I understand why you moved forward. If possible, please use SqlBasicOperator. See the discussion here:
If method is private: we can change and use SqlBasicOperator instead. See example inside #4644 Regarding SqlAttributeDefinition:
|
|
I tried to use these classes and I couldn't. |
|
So @dssysolyatin your recommendation is to switch to use SqlOperator everywhere? |
|
Recommendation is to use private static final SqlOperator OPERATOR =
SqlBasicOperator.create("ATTRIBUTE_DEF", SqlKind.ATTRIBUTE_DEF)
.withCallFactory((operator, functionQualifier, pos, operands) ->
new SqlAttributeDefinition(
pos,
(SqlIdentifier) requireNonNull(operands[0]),
(SqlDataTypeSpec) requireNonNull(operands[1]),
operands[2], null));
Do you mean you tried
In current cases, all
Is a simple string insufficient to represent a Locale and Collation? I think it what one of the constructor does: public SqlCollation(
@JsonProperty("collationName") String collation,
@JsonProperty("coercibility") Coercibility coercibility) { |
|
@dssysolyatin turns out that if you switch from SqlSpecialOperator to SqlBasicOperators quite a few BabelQuidem tests start failing, I didn't investigate why. But your PR may have the same issue. |
e73665b to
1fea942
Compare
dssysolyatin
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.
turns out that if you switch from SqlSpecialOperator to SqlBasicOperators quite a few BabelQuidem tests start failing, I didn't investigate why. But your PR may have the same issue.
Okay, then don’t spend time on it. I’ll look into it separately
core/src/main/java/org/apache/calcite/sql/ddl/SqlCreateFunction.java
Outdated
Show resolved
Hide resolved
|
|
||
| /** Test case for <a href="https://issues.apache.org/jira/browse/CALCITE-7339">[CALCITE-7339] | ||
| * Most classes in SqlDdlNodes use an incorrect SqlCallFactory</a>. */ | ||
| @Test void testShuttle() throws SqlParseException { |
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.
Does this test tests everything ?
Can we just add common test SqlParserTest.java but have boolean flag which enable it only for ServerUnParserTest ?
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.
I don't think that my changes affect parsing and unparsing, they affect for sure visitors that mutate these classes.
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 one way to check that all operators have createCall and that it creates SqlCall correctly.
- Parse the SQL string into a SqlNode.
- Unparse it and save the result as sql1.
- Parse the SQL again.
- Apply a shuttle that makes a deep copy of the tree.
- Unparse copied tree and check that the SQL string is the same as in step 2.
This way, we do not need to write a separate test for each SqlOperator. Having separate tests is also good, but with separate tests we might forget to write one and miss validating some cases.
Anyway, you can just skip this part as separate tests are also OK for me.
3481fdf to
a5bbda0
Compare
|
@dssysolyatin I hope I have made the changes you suggested. |
|
|
||
| /** Test case for <a href="https://issues.apache.org/jira/browse/CALCITE-7339">[CALCITE-7339] | ||
| * Most classes in SqlDdlNodes use an incorrect SqlCallFactory</a>. */ | ||
| @Test void testShuttle() throws SqlParseException { |
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 one way to check that all operators have createCall and that it creates SqlCall correctly.
- Parse the SQL string into a SqlNode.
- Unparse it and save the result as sql1.
- Parse the SQL again.
- Apply a shuttle that makes a deep copy of the tree.
- Unparse copied tree and check that the SQL string is the same as in step 2.
This way, we do not need to write a separate test for each SqlOperator. Having separate tests is also good, but with separate tests we might forget to write one and miss validating some cases.
Anyway, you can just skip this part as separate tests are also OK for me.
|
I see your point, that would have been simpler, but since I did it, I will probably leave it like this. At least it's obvious what is being tested. |
…ctory Signed-off-by: Mihai Budiu <mbudiu@feldera.com>
a5bbda0 to
09dbd7f
Compare
|



I fixed most classes, but I don't know how to fix the SqlAttributeDefinition fully.