Skip to content

Commit bd44a7e

Browse files
committed
Avoid using deprecated methods.
1 parent a75bf47 commit bd44a7e

File tree

9 files changed

+40
-35
lines changed

9 files changed

+40
-35
lines changed

modules/sql-engine/src/main/java/org/apache/ignite/internal/sql/engine/externalize/RelOptSchemaImpl.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,13 +62,13 @@ public RelOptTable getTableForMember(List<String> names) {
6262
throw new SqlException(Common.INTERNAL_ERR, "Expected name of exactly two parts, but was " + names);
6363
}
6464

65-
SchemaPlus schema = root.getSubSchema(names.get(0));
65+
SchemaPlus schema = root.subSchemas().get(names.get(0));
6666

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

71-
Table table = schema.getTable(names.get(1));
71+
Table table = schema.tables().get(names.get(1));
7272

7373
if (table == null) {
7474
throw new SqlException(Common.INTERNAL_ERR, "Table with name " + names + " not found");

modules/sql-engine/src/main/java/org/apache/ignite/internal/sql/engine/prepare/PrepareServiceImpl.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -400,7 +400,7 @@ private SchemaPlus getDefaultSchema(int catalogVersion, String schemaName) {
400400
assert rootSchema != null : "Root schema does not exist";
401401

402402
SchemaPlus schemaPlus = rootSchema.root();
403-
SchemaPlus defaultSchema = schemaPlus.getSubSchema(schemaName);
403+
SchemaPlus defaultSchema = schemaPlus.subSchemas().get(schemaName);
404404
// If default schema does not exist or misconfigured, we should use the root schema as default one
405405
// because there is no other schema for the validator to use.
406406
if (defaultSchema == null) {

modules/sql-engine/src/main/java/org/apache/ignite/internal/sql/engine/schema/SqlSchemaManagerImpl.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@
3939
import org.apache.calcite.rel.hint.RelHint;
4040
import org.apache.calcite.rel.type.RelDataType;
4141
import org.apache.calcite.schema.SchemaPlus;
42+
import org.apache.calcite.schema.lookup.LikePattern;
4243
import org.apache.calcite.tools.Frameworks;
4344
import org.apache.calcite.util.ImmutableIntList;
4445
import org.apache.ignite.internal.catalog.Catalog;
@@ -154,8 +155,8 @@ public IgniteTable table(int catalogVersion, int tableId) {
154155
if (rootSchema != null) {
155156
SchemaPlus schemaPlus = rootSchema.root();
156157

157-
for (String name : schemaPlus.getSubSchemaNames()) {
158-
SchemaPlus subSchema = schemaPlus.getSubSchema(name);
158+
for (String name : schemaPlus.subSchemas().getNames(LikePattern.any())) {
159+
SchemaPlus subSchema = schemaPlus.subSchemas().get(name);
159160

160161
assert subSchema != null : name;
161162

modules/sql-engine/src/test/java/org/apache/ignite/internal/sql/engine/exec/mapping/FragmentMappingTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -350,7 +350,7 @@ private IgniteRel parseQuery(IgniteSchema schema, String sqlStmt) {
350350
try {
351351
PlanningContext ctx = PlanningContext.builder()
352352
.frameworkConfig(newConfigBuilder(FRAMEWORK_CONFIG)
353-
.defaultSchema(createRootSchema(List.of(schema)).getSubSchema(schema.getName()))
353+
.defaultSchema(createRootSchema(List.of(schema)).subSchemas().get(schema.getName()))
354354
.build())
355355
.defaultSchemaName(schema.getName())
356356
.query(sqlStmt)

modules/sql-engine/src/test/java/org/apache/ignite/internal/sql/engine/framework/PredefinedSchemaManager.java

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,9 @@
2727
import java.util.List;
2828
import java.util.concurrent.CompletableFuture;
2929
import org.apache.calcite.schema.SchemaPlus;
30+
import org.apache.calcite.schema.Table;
31+
import org.apache.calcite.schema.lookup.LikePattern;
32+
import org.apache.calcite.schema.lookup.Lookup;
3033
import org.apache.calcite.tools.Frameworks;
3134
import org.apache.ignite.internal.sql.engine.schema.IgniteSchema;
3235
import org.apache.ignite.internal.sql.engine.schema.IgniteSchemas;
@@ -60,9 +63,10 @@ public PredefinedSchemaManager(Collection<IgniteSchema> schemas) {
6063
for (IgniteSchema schema : schemas) {
6164
schemaPlus.add(schema.getName(), schema);
6265

66+
Lookup<Table> tables = schema.tables();
6367
tableById.putAll(
64-
schema.getTableNames().stream()
65-
.map(schema::getTable)
68+
tables.getNames(LikePattern.any()).stream()
69+
.map(tables::get)
6670
.map(IgniteTable.class::cast)
6771
.collect(toIntMapCollector(IgniteTable::id, identity()))
6872
);

modules/sql-engine/src/test/java/org/apache/ignite/internal/sql/engine/planner/AbstractPlannerTest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -277,10 +277,10 @@ protected PlanningContext plannerCtx(
277277
}
278278

279279
SchemaPlus rootSchema = createRootSchema(schemas);
280-
SchemaPlus defaultSchema = rootSchema.getSubSchema(DEFAULT_SCHEMA);
280+
SchemaPlus defaultSchema = rootSchema.subSchemas().get(DEFAULT_SCHEMA);
281281

282282
if (defaultSchema == null && !schemas.isEmpty()) {
283-
defaultSchema = rootSchema.getSubSchema(schemas.iterator().next().getName());
283+
defaultSchema = rootSchema.subSchemas().get(schemas.iterator().next().getName());
284284
}
285285

286286
assertNotNull(defaultSchema);

modules/sql-engine/src/test/java/org/apache/ignite/internal/sql/engine/planner/PartitionPruningMetadataTest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -553,12 +553,12 @@ private static class TestCase {
553553
}
554554

555555
List<Integer> colocationKeys() {
556-
IgniteTable table = (IgniteTable) schema.getTable("T");
556+
IgniteTable table = (IgniteTable) schema.tables().get("T");
557557
return table.distribution().getKeys();
558558
}
559559

560560
List<String> columnNames() {
561-
IgniteTable table = (IgniteTable) schema.getTable("T");
561+
IgniteTable table = (IgniteTable) schema.tables().get("T");
562562
List<String> names = new ArrayList<>();
563563
TableDescriptor tableDescriptor = table.descriptor();
564564

modules/sql-engine/src/test/java/org/apache/ignite/internal/sql/engine/planner/PlannerTimeoutTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ public void testLongPlanningTimeout() {
126126
PlanningContext ctx = PlanningContext.builder()
127127
.plannerTimeout(plannerTimeout)
128128
.frameworkConfig(newConfigBuilder(FRAMEWORK_CONFIG)
129-
.defaultSchema(createRootSchema(List.of(schema)).getSubSchema(schema.getName()))
129+
.defaultSchema(createRootSchema(List.of(schema)).subSchemas().get(schema.getName()))
130130
.build())
131131
.defaultSchemaName(schema.getName())
132132
.query(sql)

modules/sql-engine/src/test/java/org/apache/ignite/internal/sql/engine/schema/SqlSchemaManagerImplTest.java

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -167,8 +167,8 @@ void testMultipleSchemas() {
167167
assertNotNull(schemas);
168168
SchemaPlus rootSchema = schemas.root();
169169

170-
assertNotNull(rootSchema.getSubSchema(PUBLIC_SCHEMA_NAME));
171-
assertNotNull(rootSchema.getSubSchema(SYSTEM_SCHEMA_NAME));
170+
assertNotNull(rootSchema.subSchemas().get(PUBLIC_SCHEMA_NAME));
171+
assertNotNull(rootSchema.subSchemas().get(SYSTEM_SCHEMA_NAME));
172172
}
173173

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

190-
SchemaPlus schemaPlus = rootSchema.getSubSchema(PUBLIC_SCHEMA_NAME);
190+
SchemaPlus schemaPlus = rootSchema.subSchemas().get(PUBLIC_SCHEMA_NAME);
191191
assertNotNull(schemaPlus);
192192

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

207-
Table table = schema.getTable(tableDescriptor.name());
207+
Table table = schema.tables().get(tableDescriptor.name());
208208
assertThat(table, notNullValue());
209209

210210
IgniteTable igniteTable = assertInstanceOf(IgniteTable.class, table);
@@ -246,11 +246,11 @@ public void testTableWithZone() {
246246
assertNotNull(schemas);
247247
SchemaPlus rootSchema = schemas.root();
248248

249-
SchemaPlus schemaPlus = rootSchema.getSubSchema(PUBLIC_SCHEMA_NAME);
249+
SchemaPlus schemaPlus = rootSchema.subSchemas().get(PUBLIC_SCHEMA_NAME);
250250
assertNotNull(schemaPlus);
251251

252252
IgniteSchema schema = unwrapSchema(schemaPlus);
253-
Table table = schema.getTable("T");
253+
Table table = schema.tables().get("T");
254254
assertNotNull(table);
255255

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

287-
SchemaPlus schemaPlus = rootSchema.getSubSchema(PUBLIC_SCHEMA_NAME);
287+
SchemaPlus schemaPlus = rootSchema.subSchemas().get(PUBLIC_SCHEMA_NAME);
288288
assertNotNull(schemaPlus);
289289

290290
IgniteTable table = getTable(unwrapSchema(schemaPlus), "TEST");
@@ -353,7 +353,7 @@ public void testTableDefaultValue() {
353353
assertNotNull(schemas);
354354
SchemaPlus rootSchema = schemas.root();
355355

356-
SchemaPlus schemaPlus = rootSchema.getSubSchema(PUBLIC_SCHEMA_NAME);
356+
SchemaPlus schemaPlus = rootSchema.subSchemas().get(PUBLIC_SCHEMA_NAME);
357357
assertNotNull(schemaPlus);
358358

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

408-
SchemaPlus schemaPlus = rootSchema.getSubSchema(PUBLIC_SCHEMA_NAME);
408+
SchemaPlus schemaPlus = rootSchema.subSchemas().get(PUBLIC_SCHEMA_NAME);
409409
assertNotNull(schemaPlus);
410410

411411
IgniteTable table = getTable(unwrapSchema(schemaPlus), "TEST");
@@ -466,7 +466,7 @@ public void testTableDistribution() {
466466
assertNotNull(schemas);
467467
SchemaPlus rootSchema = schemas.root();
468468

469-
SchemaPlus schemaPlus = rootSchema.getSubSchema(PUBLIC_SCHEMA_NAME);
469+
SchemaPlus schemaPlus = rootSchema.subSchemas().get(PUBLIC_SCHEMA_NAME);
470470
assertNotNull(schemaPlus);
471471

472472
{
@@ -517,7 +517,7 @@ public void testHashIndex() {
517517
assertNotNull(schemas);
518518
SchemaPlus rootSchema = schemas.root();
519519

520-
SchemaPlus schemaPlus = rootSchema.getSubSchema(PUBLIC_SCHEMA_NAME);
520+
SchemaPlus schemaPlus = rootSchema.subSchemas().get(PUBLIC_SCHEMA_NAME);
521521
assertNotNull(schemaPlus);
522522

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

540-
SchemaPlus schemaPlus = rootSchema.getSubSchema(PUBLIC_SCHEMA_NAME);
540+
SchemaPlus schemaPlus = rootSchema.subSchemas().get(PUBLIC_SCHEMA_NAME);
541541
assertNotNull(schemaPlus);
542542

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

574-
SchemaPlus schemaPlus = rootSchema.getSubSchema(PUBLIC_SCHEMA_NAME);
574+
SchemaPlus schemaPlus = rootSchema.subSchemas().get(PUBLIC_SCHEMA_NAME);
575575
assertNotNull(schemaPlus);
576576

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

610-
SchemaPlus schemaPlus = rootSchema.getSubSchema(PUBLIC_SCHEMA_NAME);
610+
SchemaPlus schemaPlus = rootSchema.subSchemas().get(PUBLIC_SCHEMA_NAME);
611611
assertNotNull(schemaPlus);
612612

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

633-
SchemaPlus schemaPlus = rootSchema.getSubSchema(PUBLIC_SCHEMA_NAME);
633+
SchemaPlus schemaPlus = rootSchema.subSchemas().get(PUBLIC_SCHEMA_NAME);
634634
assertNotNull(schemaPlus);
635635

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

661-
SchemaPlus schemaPlus = rootSchema.getSubSchema(PUBLIC_SCHEMA_NAME);
661+
SchemaPlus schemaPlus = rootSchema.subSchemas().get(PUBLIC_SCHEMA_NAME);
662662
assertNotNull(schemaPlus);
663663

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

699-
SchemaPlus schemaPlus = rootSchema.getSubSchema(PUBLIC_SCHEMA_NAME);
699+
SchemaPlus schemaPlus = rootSchema.subSchemas().get(PUBLIC_SCHEMA_NAME);
700700
assertNotNull(schemaPlus);
701701

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

766-
SchemaPlus schemaPlus = rootSchema.getSubSchema(SYSTEM_SCHEMA_NAME);
766+
SchemaPlus schemaPlus = rootSchema.subSchemas().get(SYSTEM_SCHEMA_NAME);
767767
assertNotNull(schemaPlus);
768768

769769
{
@@ -804,7 +804,7 @@ public void testViewColumns(SystemViewType viewType, ColumnType columnType, int
804804
assertNotNull(schemas);
805805
SchemaPlus rootSchema = schemas.root();
806806

807-
SchemaPlus schemaPlus = rootSchema.getSubSchema(SYSTEM_SCHEMA_NAME);
807+
SchemaPlus schemaPlus = rootSchema.subSchemas().get(SYSTEM_SCHEMA_NAME);
808808
assertNotNull(schemaPlus);
809809

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

855855
private static IgniteSystemView getSystemView(IgniteSchema schema, String name) {
856-
Table systemViewTable = schema.getTable(name);
856+
Table systemViewTable = schema.tables().get(name);
857857
assertNotNull(systemViewTable);
858858

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

871871
private static IgniteTable getTable(IgniteSchema schema, String name) {
872-
IgniteTable table = (IgniteTable) schema.getTable(name);
872+
IgniteTable table = (IgniteTable) schema.tables().get(name);
873873
assertNotNull(table);
874874
return table;
875875
}
876876

877877
private static @Nullable IgniteIndex findIndex(IgniteSchema schema, String tableName, String indexName) {
878-
IgniteTable table = (IgniteTable) schema.getTable(tableName);
878+
IgniteTable table = (IgniteTable) schema.tables().get(tableName);
879879
assertNotNull(table);
880880
return table.indexes().get(indexName);
881881
}

0 commit comments

Comments
 (0)