You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@calcite.apache.org by za...@apache.org on 2023/04/19 12:15:34 UTC
[calcite] branch main updated: [CALCITE-5650] Obtain typesystem from dialect in RelToSqlConverterTest
This is an automated email from the ASF dual-hosted git repository.
zabetak pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/calcite.git
The following commit(s) were added to refs/heads/main by this push:
new e7375ae745 [CALCITE-5650] Obtain typesystem from dialect in RelToSqlConverterTest
e7375ae745 is described below
commit e7375ae745ec18ce9df68b4945bb521ae49a053c
Author: Mihai Budiu <mb...@vmware.com>
AuthorDate: Fri Apr 14 18:22:10 2023 -0700
[CALCITE-5650] Obtain typesystem from dialect in RelToSqlConverterTest
Signed-off-by: Mihai Budiu <mb...@vmware.com>
Close apache/calcite#3155
---
.../rel/rel2sql/RelToSqlConverterStructsTest.java | 3 +-
.../calcite/rel/rel2sql/RelToSqlConverterTest.java | 39 ++++++----------------
2 files changed, 12 insertions(+), 30 deletions(-)
diff --git a/core/src/test/java/org/apache/calcite/rel/rel2sql/RelToSqlConverterStructsTest.java b/core/src/test/java/org/apache/calcite/rel/rel2sql/RelToSqlConverterStructsTest.java
index e92f102b93..284bc108a3 100644
--- a/core/src/test/java/org/apache/calcite/rel/rel2sql/RelToSqlConverterStructsTest.java
+++ b/core/src/test/java/org/apache/calcite/rel/rel2sql/RelToSqlConverterStructsTest.java
@@ -16,7 +16,6 @@
*/
package org.apache.calcite.rel.rel2sql;
-import org.apache.calcite.rel.type.RelDataTypeSystem;
import org.apache.calcite.sql.dialect.CalciteSqlDialect;
import org.apache.calcite.sql.parser.SqlParser;
import org.apache.calcite.test.CalciteAssert;
@@ -37,7 +36,7 @@ class RelToSqlConverterStructsTest {
private RelToSqlConverterTest.Sql sql(String sql) {
return new RelToSqlConverterTest.Sql(CalciteAssert.SchemaSpec.MY_DB, sql,
CalciteSqlDialect.DEFAULT, SqlParser.Config.DEFAULT, ImmutableSet.of(),
- UnaryOperator.identity(), null, ImmutableList.of(), RelDataTypeSystem.DEFAULT);
+ UnaryOperator.identity(), null, ImmutableList.of());
}
@Test void testNestedSchemaSelectStar() {
diff --git a/core/src/test/java/org/apache/calcite/rel/rel2sql/RelToSqlConverterTest.java b/core/src/test/java/org/apache/calcite/rel/rel2sql/RelToSqlConverterTest.java
index cfebf54b1b..18644c5672 100644
--- a/core/src/test/java/org/apache/calcite/rel/rel2sql/RelToSqlConverterTest.java
+++ b/core/src/test/java/org/apache/calcite/rel/rel2sql/RelToSqlConverterTest.java
@@ -112,8 +112,6 @@ import static org.hamcrest.MatcherAssert.assertThat;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertTrue;
-import static java.util.Objects.requireNonNull;
-
/**
* Tests for {@link RelToSqlConverter}.
*/
@@ -122,7 +120,7 @@ class RelToSqlConverterTest {
private Sql fixture() {
return new Sql(CalciteAssert.SchemaSpec.JDBC_FOODMART, "?",
CalciteSqlDialect.DEFAULT, SqlParser.Config.DEFAULT, ImmutableSet.of(),
- UnaryOperator.identity(), null, ImmutableList.of(), RelDataTypeSystem.DEFAULT);
+ UnaryOperator.identity(), null, ImmutableList.of());
}
/** Initiates a test case with a given SQL query. */
@@ -955,14 +953,6 @@ class RelToSqlConverterTest {
final String expectedRedshift = "SELECT CAST(\"product_id\" AS DECIMAL(38, 2))\n"
+ "FROM \"foodmart\".\"product\"";
sql(query)
- .withTypeSystem(new RelDataTypeSystemImpl() {
- @Override public int getMaxNumericPrecision() {
- // Ensures that parsed decimal will not be truncated during SQL to Rel transformation
- // The default type system sets precision to 19 so it is not sufficient to test
- // this change.
- return 100;
- }
- })
.withRedshift()
.ok(expectedRedshift);
}
@@ -6810,14 +6800,12 @@ class RelToSqlConverterTest {
private final List<Function<RelNode, RelNode>> transforms;
private final SqlParser.Config parserConfig;
private final UnaryOperator<SqlToRelConverter.Config> config;
- private final RelDataTypeSystem typeSystem;
Sql(CalciteAssert.SchemaSpec schemaSpec, String sql, SqlDialect dialect,
SqlParser.Config parserConfig, Set<SqlLibrary> librarySet,
UnaryOperator<SqlToRelConverter.Config> config,
@Nullable Function<RelBuilder, RelNode> relFn,
- List<Function<RelNode, RelNode>> transforms,
- RelDataTypeSystem typeSystem) {
+ List<Function<RelNode, RelNode>> transforms) {
this.schemaSpec = schemaSpec;
this.sql = sql;
this.dialect = dialect;
@@ -6826,22 +6814,21 @@ class RelToSqlConverterTest {
this.transforms = ImmutableList.copyOf(transforms);
this.parserConfig = parserConfig;
this.config = config;
- this.typeSystem = requireNonNull(typeSystem, "typeSystem");
}
Sql withSql(String sql) {
return new Sql(schemaSpec, sql, dialect, parserConfig, librarySet, config,
- relFn, transforms, typeSystem);
+ relFn, transforms);
}
Sql dialect(SqlDialect dialect) {
return new Sql(schemaSpec, sql, dialect, parserConfig, librarySet, config,
- relFn, transforms, typeSystem);
+ relFn, transforms);
}
Sql relFn(Function<RelBuilder, RelNode> relFn) {
return new Sql(schemaSpec, sql, dialect, parserConfig, librarySet, config,
- relFn, transforms, typeSystem);
+ relFn, transforms);
}
Sql withCalcite() {
@@ -6976,17 +6963,12 @@ class RelToSqlConverterTest {
Sql parserConfig(SqlParser.Config parserConfig) {
return new Sql(schemaSpec, sql, dialect, parserConfig, librarySet, config,
- relFn, transforms, typeSystem);
+ relFn, transforms);
}
Sql withConfig(UnaryOperator<SqlToRelConverter.Config> config) {
return new Sql(schemaSpec, sql, dialect, parserConfig, librarySet, config,
- relFn, transforms, typeSystem);
- }
-
- Sql withTypeSystem(RelDataTypeSystem typeSystem) {
- return new Sql(schemaSpec, sql, dialect, parserConfig, librarySet, config,
- relFn, transforms, typeSystem);
+ relFn, transforms);
}
final Sql withLibrary(SqlLibrary library) {
@@ -6995,7 +6977,7 @@ class RelToSqlConverterTest {
Sql withLibrarySet(Iterable<? extends SqlLibrary> librarySet) {
return new Sql(schemaSpec, sql, dialect, parserConfig,
- ImmutableSet.copyOf(librarySet), config, relFn, transforms, typeSystem);
+ ImmutableSet.copyOf(librarySet), config, relFn, transforms);
}
Sql optimize(final RuleSet ruleSet,
@@ -7012,7 +6994,7 @@ class RelToSqlConverterTest {
ImmutableList.of(), ImmutableList.of());
});
return new Sql(schemaSpec, sql, dialect, parserConfig, librarySet, config,
- relFn, transforms, typeSystem);
+ relFn, transforms);
}
Sql ok(String expectedQuery) {
@@ -7046,6 +7028,7 @@ class RelToSqlConverterTest {
} else {
final SqlToRelConverter.Config config = this.config.apply(SqlToRelConverter.config()
.withTrimUnusedFields(false));
+ RelDataTypeSystem typeSystem = dialect.getTypeSystem();
final Planner planner =
getPlanner(null, parserConfig, defaultSchema, config, librarySet, typeSystem);
SqlNode parse = planner.parse(sql);
@@ -7063,7 +7046,7 @@ class RelToSqlConverterTest {
public Sql schema(CalciteAssert.SchemaSpec schemaSpec) {
return new Sql(schemaSpec, sql, dialect, parserConfig, librarySet, config,
- relFn, transforms, typeSystem);
+ relFn, transforms);
}
}
}