Skip to content

Commit

Permalink
[CALCITE-6693] Add Source SQL Dialect to RelToSqlConverterTest
Browse files Browse the repository at this point in the history
  • Loading branch information
wangyanjing committed Nov 16, 2024
1 parent f347fba commit db271e5
Show file tree
Hide file tree
Showing 3 changed files with 158 additions and 125 deletions.
10 changes: 8 additions & 2 deletions core/src/main/java/org/apache/calcite/prepare/PlannerImpl.java
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@
import org.apache.calcite.sql.SqlOperatorTable;
import org.apache.calcite.sql.parser.SqlParseException;
import org.apache.calcite.sql.parser.SqlParser;
import org.apache.calcite.sql.parser.SqlParser.Config;
import org.apache.calcite.sql.util.SqlOperatorTables;
import org.apache.calcite.sql.validate.SqlValidator;
import org.apache.calcite.sql2rel.RelDecorrelator;
Expand Down Expand Up @@ -117,14 +118,14 @@ public PlannerImpl(FrameworkConfig config) {
this.convertletTable = config.getConvertletTable();
this.executor = config.getExecutor();
this.context = config.getContext();
this.connectionConfig = connConfig(context, parserConfig);
this.connectionConfig = connConfig(context, parserConfig, sqlValidatorConfig);
this.typeSystem = config.getTypeSystem();
reset();
}

/** Gets a user-defined config and appends default connection values. */
private static CalciteConnectionConfig connConfig(Context context,
SqlParser.Config parserConfig) {
Config parserConfig, SqlValidator.Config sqlValidatorConfig) {
CalciteConnectionConfigImpl config =
context.maybeUnwrap(CalciteConnectionConfigImpl.class)
.orElse(CalciteConnectionConfig.DEFAULT);
Expand All @@ -138,6 +139,11 @@ private static CalciteConnectionConfig connConfig(Context context,
config.set(CalciteConnectionProperty.CONFORMANCE,
String.valueOf(parserConfig.conformance()));
}
if (!config.isSet(CalciteConnectionProperty.DEFAULT_NULL_COLLATION)) {
config =
config.set(CalciteConnectionProperty.DEFAULT_NULL_COLLATION,
String.valueOf(sqlValidatorConfig.defaultNullCollation()));
}
return config;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,8 @@ class RelToSqlConverterStructsTest {

private RelToSqlConverterTest.Sql sql(String sql) {
return new RelToSqlConverterTest.Sql(CalciteAssert.SchemaSpec.MY_DB, sql,
CalciteSqlDialect.DEFAULT, SqlParser.Config.DEFAULT, ImmutableSet.of(),
CalciteSqlDialect.DEFAULT, CalciteSqlDialect.DEFAULT,
SqlParser.Config.DEFAULT, ImmutableSet.of(),
UnaryOperator.identity(), null, ImmutableList.of());
}

Expand Down
Loading

0 comments on commit db271e5

Please sign in to comment.