-
Notifications
You must be signed in to change notification settings - Fork 2.5k
[CALCITE-7301] Add common test for SqlNode unparse after deep copy and fix operators missing createCall #4644
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
base: main
Are you sure you want to change the base?
Changes from all commits
a778f6e
3497c2c
2882a33
0cee375
2f89ff5
6f3883e
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 |
|---|---|---|
|
|
@@ -40,6 +40,7 @@ | |
| import static org.hamcrest.CoreMatchers.is; | ||
| import static org.hamcrest.MatcherAssert.assertThat; | ||
| import static org.hamcrest.Matchers.hasToString; | ||
| import static org.junit.jupiter.api.Assumptions.assumeFalse; | ||
|
|
||
| /** | ||
| * Tests the "Babel" SQL parser, that understands all dialects of SQL. | ||
|
|
@@ -415,7 +416,12 @@ private void checkParseInfixCast(String sqlType) { | |
| } | ||
|
|
||
| @Test void testPostgresSqlSetOption() { | ||
| SqlParserFixture f = fixture().withDialect(PostgresqlSqlDialect.DEFAULT); | ||
| // UnparsingTesterImpl has a check where it unparses a SqlNode into a SQL string | ||
| // using the calcite dialect, and then parses it back into a SqlNode. | ||
| // But the SQL string produced by the calcite dialect for `SET` cannot always be parsed back. | ||
|
Contributor
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. does this require filing a new issue?
Contributor
Author
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 don’t see a reason to spend time on it, as this is a very specific case. Additionally, I think almost nobody uses this syntax. I originally introduced it while working on the implementation of the Postgres wire protocol and integrating various tools on top of it. At that time, I didn’t observe much interest in this feature outside the company I was working for |
||
| assumeFalse(fixture().tester.isUnparserTest()); | ||
| SqlParserFixture f = fixture() | ||
| .withDialect(PostgresqlSqlDialect.DEFAULT); | ||
| f.sql("SET SESSION autovacuum = true") | ||
| .ok("SET \"autovacuum\" = TRUE"); | ||
| f.sql("SET SESSION autovacuum = DEFAULT") | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,30 @@ | ||
| /* | ||
| * Licensed to the Apache Software Foundation (ASF) under one or more | ||
| * contributor license agreements. See the NOTICE file distributed with | ||
| * this work for additional information regarding copyright ownership. | ||
| * The ASF licenses this file to you under the Apache License, Version 2.0 | ||
| * (the "License"); you may not use this file except in compliance with | ||
| * the License. You may obtain a copy of the License at | ||
| * | ||
| * http://www.apache.org/licenses/LICENSE-2.0 | ||
| * | ||
| * Unless required by applicable law or agreed to in writing, software | ||
| * distributed under the License is distributed on an "AS IS" BASIS, | ||
| * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| * See the License for the specific language governing permissions and | ||
| * limitations under the License. | ||
| */ | ||
| package org.apache.calcite.test; | ||
|
|
||
| import org.apache.calcite.sql.parser.SqlParserFixture; | ||
|
|
||
| /** | ||
| * Extension to {@link BabelParserTest} that ensures that every expression can | ||
| * un-parse successfully. | ||
| */ | ||
| public class BabelUnParserTest extends BabelParserTest { | ||
| @Override public SqlParserFixture fixture() { | ||
| return super.fixture() | ||
| .withTester(new UnparsingTesterImpl()); | ||
| } | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -49,6 +49,12 @@ other software versions as specified in gradle.properties. | |
| #### Breaking Changes | ||
| {: #breaking-1-42-0} | ||
|
|
||
| * [<a href="https://issues.apache.org/jira/browse/CALCITE-7301">CALCITE-7301</a>] | ||
|
Contributor
Author
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. It is a breaking change, but I hope it should not affect anyone. All For
Contributor
Author
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. @mihaibudiu I personally would prefer to include this as a breaking change, including the changes you made in your The number of arguments in the operator list has changed, and this is a runtime breaking change. Existing code may assume different behavior, for example: |
||
| Prior to this change, most `SqlNode`s in the `org.apache.calcite.sql.ddl` package could not be unparsed | ||
| when created with `SqlOperator#createCall`. To fix this, those `SqlNode`s now implement their own `SqlOperator`. | ||
| `SqlNode#getOperandList()` now returns all operands required by these operators; the number and order may differ from before. | ||
| The same applies to `SqlBabelCreateTable` and `SqlUnpivot`. | ||
|
|
||
| * [<a href="https://issues.apache.org/jira/browse/CALCITE-6942">CALCITE-6942</a>] | ||
| Rename the method `decorrelateFetchOneSort` to `decorrelateSortWithRowNumber`. | ||
|
|
||
|
|
||
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’m taking the most straightforward approach using SqlLiteral for boolean flag for
replaceand ifNotExists. Ideally,replaceandifNotExistsshould each have their ownSqlNodeimplementation.That way, we won’t need to write code like this every time:
Instead, we could just call: