Skip to content

Commit

Permalink
Fixes for Calcite 1.38.0
Browse files Browse the repository at this point in the history
  • Loading branch information
kramerul committed Oct 17, 2024
1 parent 51d8cad commit b431c7a
Show file tree
Hide file tree
Showing 8 changed files with 14 additions and 21 deletions.
2 changes: 1 addition & 1 deletion build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
# limitations under the License.
#
set -e
VERSION=1.37.0
VERSION=1.38.0

# Java 21 doesn't suppport Java 8
if [ -d /Library/Java/JavaVirtualMachines/sapmachine-jdk-17.0.11.jdk/Contents/Home ]; then
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -422,7 +422,7 @@ Enumerable<MetaTable> tables(String catalog) {

Enumerable<MetaTable> tables(final MetaSchema schema_, LikePattern tableNamePattern) {
final CalciteMetaSchema schema = (CalciteMetaSchema) schema_;
return Linq4j.asEnumerable(schema.calciteSchema.getTableNames())
return Linq4j.asEnumerable(schema.calciteSchema.getTableNames(tableNamePattern))
.select(name -> {
final Table table =
requireNonNull(schema.calciteSchema.getTable(name, true),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -506,7 +506,7 @@ public static MySchemaPlus create(Path path) {
}

@Deprecated @Override public @Nullable Table getTable(String name) {
return schema.getTable(name);
return tables().get(name);
}

@Deprecated @Override public Set<String> getTableNames() {
Expand Down
9 changes: 1 addition & 8 deletions core/src/test/java/org/apache/calcite/test/JdbcTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -1220,7 +1220,6 @@ private void checkResultSetMetaData(Connection connection, String sql)
final CalciteConnection calciteConnection =
connection.unwrap(CalciteConnection.class);
final SchemaPlus rootSchema = calciteConnection.getRootSchema();
<<<<<<< HEAD
final SchemaPlus foodmart = rootSchema.subSchemas().get("foodmart");
assertThat(foodmart, notNullValue());
final JdbcTable timeByDay =
Expand Down Expand Up @@ -8762,14 +8761,8 @@ public FoodmartJdbcSchema(DataSource dataSource, SqlDialect dialect,
super(dataSource, dialect, convention, catalog, schema);
}

<<<<<<< HEAD
public final Table customer =
requireNonNull(getTable("customer"));
||||||| parent of c54b3c271 (EXPB-2551 Speed up schema lookup for huge schemas)
public final Table customer = getTable("customer");
=======
public final Table customer = tables().get("customer");
>>>>>>> c54b3c271 (EXPB-2551 Speed up schema lookup for huge schemas)
requireNonNull(tables().get("customer"));
}

public static class Customer {
Expand Down
8 changes: 4 additions & 4 deletions core/src/test/java/org/apache/calcite/test/LatticeTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@ private static CalciteAssert.AssertThat modelWithLattices(
final SchemaPlus schema = c.getRootSchema();
final SchemaPlus adhoc =
requireNonNull(schema.subSchemas().get("adhoc"));
assertThat(adhoc.getTableNames().contains("EMPLOYEES"), is(true));
assertThat(adhoc.tables().get("EMPLOYEES") != null, is(true));
final CalciteSchema adhocSchema =
requireNonNull(adhoc.unwrap(CalciteSchema.class));
final Map.Entry<String, CalciteSchema.LatticeEntry> entry =
Expand Down Expand Up @@ -239,8 +239,8 @@ private static CalciteAssert.AssertThat modelWithLattices(
.doWithConnection(c -> {
final SchemaPlus schema = c.getRootSchema();
final SchemaPlus adhoc =
requireNonNull(schema.getSubSchema("adhoc"));
assertThat(adhoc.getTableNames().contains("EMPLOYEES"), is(true));
requireNonNull(schema.subSchemas().get("adhoc"));
assertThat(adhoc.tables().get("EMPLOYEES") != null, is(true));
final CalciteSchema adhocSchema =
requireNonNull(adhoc.unwrap(CalciteSchema.class));
final Map.Entry<String, CalciteSchema.LatticeEntry> entry =
Expand Down Expand Up @@ -271,7 +271,7 @@ private static CalciteAssert.AssertThat modelWithLattices(
final SchemaPlus schema = c.getRootSchema();
final SchemaPlus adhoc =
requireNonNull(schema.subSchemas().get("adhoc"));
assertThat(adhoc.getTableNames().contains("EMPLOYEES"), is(true));
assertThat(adhoc.tables().get("EMPLOYEES") != null, is(true));
final CalciteSchema adhocSchema =
requireNonNull(adhoc.unwrap(CalciteSchema.class));
final Map.Entry<String, CalciteSchema.LatticeEntry> entry =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2626,7 +2626,7 @@ private void testCountWithApproxDistinct(boolean approx, String sql,
@Test void testTableMapReused() {
AbstractSchema schema =
new DruidSchema("http://localhost:8082", "http://localhost:8081", true);
assertSame(schema.getTable("wikiticker"), schema.getTable("wikiticker"));
assertSame(schema.tables().get("wikiticker"), schema.tables().get("wikiticker"));
}

@Test void testPushEqualsCastDimension() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3115,7 +3115,7 @@ private void testCountWithApproxDistinct(boolean approx, String sql, String expe
* */
@Test void testTableMapReused() {
AbstractSchema schema = new DruidSchema("http://localhost:8082", "http://localhost:8081", true);
assertSame(schema.getTable("wikipedia"), schema.getTable("wikipedia"));
assertSame(schema.tables().get("wikipedia"), schema.tables().get("wikipedia"));
}

@Test void testPushEqualsCastDimension() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -330,7 +330,7 @@ public void execute(SqlDropObject drop,
Table materializedView =
schema != null
&& drop.getKind() == SqlKind.DROP_MATERIALIZED_VIEW
? schema.plus().getTable(objectName)
? schema.plus().tables().get(objectName)
: null;

existed = schema != null && schema.removeTable(objectName);
Expand Down Expand Up @@ -382,7 +382,7 @@ public void execute(SqlTruncateTable truncate,
final Pair<@Nullable CalciteSchema, String> pair =
schema(context, true, truncate.name);
if (pair.left == null
|| pair.left.plus().getTable(pair.right) == null) {
|| pair.left.plus().tables().get(pair.right) == null) {
throw SqlUtil.newContextException(truncate.name.getParserPosition(),
RESOURCE.tableNotFound(pair.right));
}
Expand All @@ -401,7 +401,7 @@ public void execute(SqlCreateMaterializedView create,
final Pair<@Nullable CalciteSchema, String> pair =
schema(context, true, create.name);
if (pair.left != null
&& pair.left.plus().getTable(pair.right) != null) {
&& pair.left.plus().tables().get(pair.right) != null) {
// Materialized view exists.
if (!create.ifNotExists) {
// They did not specify IF NOT EXISTS, so give error.
Expand Down Expand Up @@ -588,7 +588,7 @@ public void execute(SqlCreateTableLike create,
final Pair<@Nullable CalciteSchema, String> pair =
schema(context, true, create.name);
requireNonNull(pair.left); // TODO: should not assume parent schema exists
if (pair.left.plus().getTable(pair.right) != null) {
if (pair.left.plus().tables().get(pair.right) != null) {
// Table exists.
if (create.ifNotExists) {
return;
Expand Down

0 comments on commit b431c7a

Please sign in to comment.