Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -62,13 +62,13 @@ public RelOptTable getTableForMember(List<String> names) {
throw new SqlException(Common.INTERNAL_ERR, "Expected name of exactly two parts, but was " + names);
}

SchemaPlus schema = root.getSubSchema(names.get(0));
SchemaPlus schema = root.subSchemas().get(names.get(0));

if (schema == null) {
throw new SqlException(Common.INTERNAL_ERR, "Schema with name \"" + names.get(0) + "\" not found");
}

Table table = schema.getTable(names.get(1));
Table table = schema.tables().get(names.get(1));

if (table == null) {
throw new SqlException(Common.INTERNAL_ERR, "Table with name " + names + " not found");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -400,7 +400,7 @@ private SchemaPlus getDefaultSchema(int catalogVersion, String schemaName) {
assert rootSchema != null : "Root schema does not exist";

SchemaPlus schemaPlus = rootSchema.root();
SchemaPlus defaultSchema = schemaPlus.getSubSchema(schemaName);
SchemaPlus defaultSchema = schemaPlus.subSchemas().get(schemaName);
// If default schema does not exist or misconfigured, we should use the root schema as default one
// because there is no other schema for the validator to use.
if (defaultSchema == null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
import org.apache.calcite.rel.hint.RelHint;
import org.apache.calcite.rel.type.RelDataType;
import org.apache.calcite.schema.SchemaPlus;
import org.apache.calcite.schema.lookup.LikePattern;
import org.apache.calcite.tools.Frameworks;
import org.apache.calcite.util.ImmutableIntList;
import org.apache.ignite.internal.catalog.Catalog;
Expand Down Expand Up @@ -154,8 +155,8 @@ public IgniteTable table(int catalogVersion, int tableId) {
if (rootSchema != null) {
SchemaPlus schemaPlus = rootSchema.root();

for (String name : schemaPlus.getSubSchemaNames()) {
SchemaPlus subSchema = schemaPlus.getSubSchema(name);
for (String name : schemaPlus.subSchemas().getNames(LikePattern.any())) {
SchemaPlus subSchema = schemaPlus.subSchemas().get(name);

assert subSchema != null : name;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -350,7 +350,7 @@ private IgniteRel parseQuery(IgniteSchema schema, String sqlStmt) {
try {
PlanningContext ctx = PlanningContext.builder()
.frameworkConfig(newConfigBuilder(FRAMEWORK_CONFIG)
.defaultSchema(createRootSchema(List.of(schema)).getSubSchema(schema.getName()))
.defaultSchema(createRootSchema(List.of(schema)).subSchemas().get(schema.getName()))
.build())
.defaultSchemaName(schema.getName())
.query(sqlStmt)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,9 @@
import java.util.List;
import java.util.concurrent.CompletableFuture;
import org.apache.calcite.schema.SchemaPlus;
import org.apache.calcite.schema.Table;
import org.apache.calcite.schema.lookup.LikePattern;
import org.apache.calcite.schema.lookup.Lookup;
import org.apache.calcite.tools.Frameworks;
import org.apache.ignite.internal.sql.engine.schema.IgniteSchema;
import org.apache.ignite.internal.sql.engine.schema.IgniteSchemas;
Expand Down Expand Up @@ -60,9 +63,10 @@ public PredefinedSchemaManager(Collection<IgniteSchema> schemas) {
for (IgniteSchema schema : schemas) {
schemaPlus.add(schema.getName(), schema);

Lookup<Table> tables = schema.tables();
tableById.putAll(
schema.getTableNames().stream()
.map(schema::getTable)
tables.getNames(LikePattern.any()).stream()
.map(tables::get)
.map(IgniteTable.class::cast)
.collect(toIntMapCollector(IgniteTable::id, identity()))
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -277,10 +277,10 @@ protected PlanningContext plannerCtx(
}

SchemaPlus rootSchema = createRootSchema(schemas);
SchemaPlus defaultSchema = rootSchema.getSubSchema(DEFAULT_SCHEMA);
SchemaPlus defaultSchema = rootSchema.subSchemas().get(DEFAULT_SCHEMA);

if (defaultSchema == null && !schemas.isEmpty()) {
defaultSchema = rootSchema.getSubSchema(schemas.iterator().next().getName());
defaultSchema = rootSchema.subSchemas().get(schemas.iterator().next().getName());
}

assertNotNull(defaultSchema);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -553,12 +553,12 @@ private static class TestCase {
}

List<Integer> colocationKeys() {
IgniteTable table = (IgniteTable) schema.getTable("T");
IgniteTable table = (IgniteTable) schema.tables().get("T");
return table.distribution().getKeys();
}

List<String> columnNames() {
IgniteTable table = (IgniteTable) schema.getTable("T");
IgniteTable table = (IgniteTable) schema.tables().get("T");
List<String> names = new ArrayList<>();
TableDescriptor tableDescriptor = table.descriptor();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ public void testLongPlanningTimeout() {
PlanningContext ctx = PlanningContext.builder()
.plannerTimeout(plannerTimeout)
.frameworkConfig(newConfigBuilder(FRAMEWORK_CONFIG)
.defaultSchema(createRootSchema(List.of(schema)).getSubSchema(schema.getName()))
.defaultSchema(createRootSchema(List.of(schema)).subSchemas().get(schema.getName()))
.build())
.defaultSchemaName(schema.getName())
.query(sql)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -167,8 +167,8 @@ void testMultipleSchemas() {
assertNotNull(schemas);
SchemaPlus rootSchema = schemas.root();

assertNotNull(rootSchema.getSubSchema(PUBLIC_SCHEMA_NAME));
assertNotNull(rootSchema.getSubSchema(SYSTEM_SCHEMA_NAME));
assertNotNull(rootSchema.subSchemas().get(PUBLIC_SCHEMA_NAME));
assertNotNull(rootSchema.subSchemas().get(SYSTEM_SCHEMA_NAME));
}

/** Basic schema with several tables. */
Expand All @@ -187,7 +187,7 @@ public void testBasicSchema() {
assertNotNull(schemas);
SchemaPlus rootSchema = schemas.root();

SchemaPlus schemaPlus = rootSchema.getSubSchema(PUBLIC_SCHEMA_NAME);
SchemaPlus schemaPlus = rootSchema.subSchemas().get(PUBLIC_SCHEMA_NAME);
assertNotNull(schemaPlus);

IgniteSchema schema = unwrapSchema(schemaPlus);
Expand All @@ -204,7 +204,7 @@ public void testBasicSchema() {
CatalogZoneDescriptor zoneDescriptor = catalogManager.catalog(versionAfter).zone(zoneId);
assertNotNull(zoneDescriptor, "Zone does not exist: " + zoneId);

Table table = schema.getTable(tableDescriptor.name());
Table table = schema.tables().get(tableDescriptor.name());
assertThat(table, notNullValue());

IgniteTable igniteTable = assertInstanceOf(IgniteTable.class, table);
Expand Down Expand Up @@ -246,11 +246,11 @@ public void testTableWithZone() {
assertNotNull(schemas);
SchemaPlus rootSchema = schemas.root();

SchemaPlus schemaPlus = rootSchema.getSubSchema(PUBLIC_SCHEMA_NAME);
SchemaPlus schemaPlus = rootSchema.subSchemas().get(PUBLIC_SCHEMA_NAME);
assertNotNull(schemaPlus);

IgniteSchema schema = unwrapSchema(schemaPlus);
Table table = schema.getTable("T");
Table table = schema.tables().get("T");
assertNotNull(table);

IgniteTable igniteTable = assertInstanceOf(IgniteTable.class, table);
Expand Down Expand Up @@ -284,7 +284,7 @@ public void testTableColumns(ColumnType columnType, int precision, int scale) {
assertNotNull(schemas);
SchemaPlus rootSchema = schemas.root();

SchemaPlus schemaPlus = rootSchema.getSubSchema(PUBLIC_SCHEMA_NAME);
SchemaPlus schemaPlus = rootSchema.subSchemas().get(PUBLIC_SCHEMA_NAME);
assertNotNull(schemaPlus);

IgniteTable table = getTable(unwrapSchema(schemaPlus), "TEST");
Expand Down Expand Up @@ -353,7 +353,7 @@ public void testTableDefaultValue() {
assertNotNull(schemas);
SchemaPlus rootSchema = schemas.root();

SchemaPlus schemaPlus = rootSchema.getSubSchema(PUBLIC_SCHEMA_NAME);
SchemaPlus schemaPlus = rootSchema.subSchemas().get(PUBLIC_SCHEMA_NAME);
assertNotNull(schemaPlus);

IgniteTable table = getTable(unwrapSchema(schemaPlus), "TEST");
Expand Down Expand Up @@ -405,7 +405,7 @@ public void testTableWithPrimaryKey(TablePrimaryKey primaryKey) {
assertNotNull(schemas);
SchemaPlus rootSchema = schemas.root();

SchemaPlus schemaPlus = rootSchema.getSubSchema(PUBLIC_SCHEMA_NAME);
SchemaPlus schemaPlus = rootSchema.subSchemas().get(PUBLIC_SCHEMA_NAME);
assertNotNull(schemaPlus);

IgniteTable table = getTable(unwrapSchema(schemaPlus), "TEST");
Expand Down Expand Up @@ -466,7 +466,7 @@ public void testTableDistribution() {
assertNotNull(schemas);
SchemaPlus rootSchema = schemas.root();

SchemaPlus schemaPlus = rootSchema.getSubSchema(PUBLIC_SCHEMA_NAME);
SchemaPlus schemaPlus = rootSchema.subSchemas().get(PUBLIC_SCHEMA_NAME);
assertNotNull(schemaPlus);

{
Expand Down Expand Up @@ -517,7 +517,7 @@ public void testHashIndex() {
assertNotNull(schemas);
SchemaPlus rootSchema = schemas.root();

SchemaPlus schemaPlus = rootSchema.getSubSchema(PUBLIC_SCHEMA_NAME);
SchemaPlus schemaPlus = rootSchema.subSchemas().get(PUBLIC_SCHEMA_NAME);
assertNotNull(schemaPlus);

IgniteIndex index = findIndex(unwrapSchema(schemaPlus), "T1", "VAL1_IDX");
Expand All @@ -537,7 +537,7 @@ public void testHashIndex() {
assertNotNull(schemas);
SchemaPlus rootSchema = schemas.root();

SchemaPlus schemaPlus = rootSchema.getSubSchema(PUBLIC_SCHEMA_NAME);
SchemaPlus schemaPlus = rootSchema.subSchemas().get(PUBLIC_SCHEMA_NAME);
assertNotNull(schemaPlus);

IgniteIndex index = findIndex(unwrapSchema(schemaPlus), "T1", "VAL1_IDX");
Expand Down Expand Up @@ -571,7 +571,7 @@ public void testHashIndexCreationWithTable() {
assertNotNull(schemas);
SchemaPlus rootSchema = schemas.root();

SchemaPlus schemaPlus = rootSchema.getSubSchema(PUBLIC_SCHEMA_NAME);
SchemaPlus schemaPlus = rootSchema.subSchemas().get(PUBLIC_SCHEMA_NAME);
assertNotNull(schemaPlus);

IgniteIndex index = findIndex(unwrapSchema(schemaPlus), "T1", "VAL1_IDX");
Expand Down Expand Up @@ -607,7 +607,7 @@ public void testSortedIndex() {
assertNotNull(schemas);
SchemaPlus rootSchema = schemas.root();

SchemaPlus schemaPlus = rootSchema.getSubSchema(PUBLIC_SCHEMA_NAME);
SchemaPlus schemaPlus = rootSchema.subSchemas().get(PUBLIC_SCHEMA_NAME);
assertNotNull(schemaPlus);

IgniteIndex index1 = findIndex(unwrapSchema(schemaPlus), "T1", "IDX1");
Expand All @@ -630,7 +630,7 @@ public void testSortedIndex() {
assertNotNull(schemas);
SchemaPlus rootSchema = schemas.root();

SchemaPlus schemaPlus = rootSchema.getSubSchema(PUBLIC_SCHEMA_NAME);
SchemaPlus schemaPlus = rootSchema.subSchemas().get(PUBLIC_SCHEMA_NAME);
assertNotNull(schemaPlus);

IgniteIndex index = findIndex(unwrapSchema(schemaPlus), "T1", "IDX1");
Expand Down Expand Up @@ -658,7 +658,7 @@ public void testSortedIndex() {
assertNotNull(schemas);
SchemaPlus rootSchema = schemas.root();

SchemaPlus schemaPlus = rootSchema.getSubSchema(PUBLIC_SCHEMA_NAME);
SchemaPlus schemaPlus = rootSchema.subSchemas().get(PUBLIC_SCHEMA_NAME);
assertNotNull(schemaPlus);

IgniteIndex index = findIndex(unwrapSchema(schemaPlus), "T1", "IDX2");
Expand Down Expand Up @@ -696,7 +696,7 @@ public void testSortedIndexCreationWithTable() {
assertNotNull(schemas);
SchemaPlus rootSchema = schemas.root();

SchemaPlus schemaPlus = rootSchema.getSubSchema(PUBLIC_SCHEMA_NAME);
SchemaPlus schemaPlus = rootSchema.subSchemas().get(PUBLIC_SCHEMA_NAME);
assertNotNull(schemaPlus);

IgniteIndex index1 = findIndex(unwrapSchema(schemaPlus), "T1", "IDX1");
Expand Down Expand Up @@ -763,7 +763,7 @@ public void testBasicView(SystemViewType viewType, IgniteDistribution distributi
assertNotNull(schemas);
SchemaPlus rootSchema = schemas.root();

SchemaPlus schemaPlus = rootSchema.getSubSchema(SYSTEM_SCHEMA_NAME);
SchemaPlus schemaPlus = rootSchema.subSchemas().get(SYSTEM_SCHEMA_NAME);
assertNotNull(schemaPlus);

{
Expand Down Expand Up @@ -804,7 +804,7 @@ public void testViewColumns(SystemViewType viewType, ColumnType columnType, int
assertNotNull(schemas);
SchemaPlus rootSchema = schemas.root();

SchemaPlus schemaPlus = rootSchema.getSubSchema(SYSTEM_SCHEMA_NAME);
SchemaPlus schemaPlus = rootSchema.subSchemas().get(SYSTEM_SCHEMA_NAME);
assertNotNull(schemaPlus);

CatalogSchemaDescriptor schemaDescriptor = catalogManager.catalog(versionAfter).schema(SYSTEM_SCHEMA_NAME);
Expand Down Expand Up @@ -853,7 +853,7 @@ private static Stream<Arguments> systemViewDistributions() {
}

private static IgniteSystemView getSystemView(IgniteSchema schema, String name) {
Table systemViewTable = schema.getTable(name);
Table systemViewTable = schema.tables().get(name);
assertNotNull(systemViewTable);

IgniteSystemView systemView = assertInstanceOf(IgniteSystemView.class, systemViewTable);
Expand All @@ -869,13 +869,13 @@ private static IgniteSchema unwrapSchema(SchemaPlus schemaPlus) {
}

private static IgniteTable getTable(IgniteSchema schema, String name) {
IgniteTable table = (IgniteTable) schema.getTable(name);
IgniteTable table = (IgniteTable) schema.tables().get(name);
assertNotNull(table);
return table;
}

private static @Nullable IgniteIndex findIndex(IgniteSchema schema, String tableName, String indexName) {
IgniteTable table = (IgniteTable) schema.getTable(tableName);
IgniteTable table = (IgniteTable) schema.tables().get(tableName);
assertNotNull(table);
return table.indexes().get(indexName);
}
Expand Down