Skip to content

Commit 32069fe

Browse files
authored
IGNITE-24305 Fix broken Public API compatibility with 3.0 (#5115)
1 parent 9b5b7d6 commit 32069fe

File tree

32 files changed

+78
-65
lines changed

32 files changed

+78
-65
lines changed

modules/api/src/main/java/org/apache/ignite/table/Table.java

Lines changed: 21 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -36,11 +36,23 @@
3636
*/
3737
public interface Table {
3838
/**
39-
* Gets the name of the table.
39+
* Gets the canonical name of the table ([schema_name].[table_name]) with SQL-parser style quotation.
4040
*
41-
* @return Table name.
41+
* <p>E.g. "PUBLIC.TBL0" - for TBL0 table in PUBLIC schema (both names are case insensitive),
42+
* "\"MySchema\".\"Tbl0\"" - for Tbl0 table in MySchema schema (both names are case sensitive), etc.
43+
*
44+
* @return Canonical table name.
45+
*/
46+
default String name() {
47+
return qualifiedName().toCanonicalForm();
48+
}
49+
50+
/**
51+
* Gets the qualified name of the table.
52+
*
53+
* @return Qualified name of the table.
4254
*/
43-
QualifiedName name();
55+
QualifiedName qualifiedName();
4456

4557
/**
4658
* Gets the partition manager.
@@ -53,7 +65,7 @@ public interface Table {
5365
* Gets a record view of the table using the specified record class mapper.
5466
*
5567
* @param recMapper Record class mapper.
56-
* @param <R> Record type.
68+
* @param <R> Record type.
5769
* @return Table record view.
5870
*/
5971
<R> RecordView<R> recordView(Mapper<R> recMapper);
@@ -69,7 +81,7 @@ public interface Table {
6981
* Gets a record view of the table using the default mapper for the specified record class.
7082
*
7183
* @param recCls Record class.
72-
* @param <R> Record type.
84+
* @param <R> Record type.
7385
* @return Table record view.
7486
*/
7587
default <R> RecordView<R> recordView(Class<R> recCls) {
@@ -81,8 +93,8 @@ default <R> RecordView<R> recordView(Class<R> recCls) {
8193
*
8294
* @param keyMapper Key class mapper.
8395
* @param valMapper Value class mapper.
84-
* @param <K> Key type.
85-
* @param <V> Value type.
96+
* @param <K> Key type.
97+
* @param <V> Value type.
8698
* @return Table key-value view.
8799
*/
88100
<K, V> KeyValueView<K, V> keyValueView(Mapper<K> keyMapper, Mapper<V> valMapper);
@@ -99,8 +111,8 @@ default <R> RecordView<R> recordView(Class<R> recCls) {
99111
*
100112
* @param keyCls Key class.
101113
* @param valCls Value class.
102-
* @param <K> Key type.
103-
* @param <V> Value type.
114+
* @param <K> Key type.
115+
* @param <V> Value type.
104116
* @return Table key-value view.
105117
*/
106118
default <K, V> KeyValueView<K, V> keyValueView(Class<K> keyCls, Class<V> valCls) {

modules/catalog-dsl/src/integrationTest/java/org/apache/ignite/internal/catalog/ItCatalogDslTest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -405,9 +405,9 @@ public void createAndGetDefinitionTest() {
405405
@Test
406406
public void createAllColumnTypesFromPojo() {
407407
Table table = catalog().createTable(AllColumnTypesPojo.class);
408-
assertEquals("ALLCOLUMNTYPESPOJO", table.name().objectName());
408+
assertEquals("ALLCOLUMNTYPESPOJO", table.qualifiedName().objectName());
409409

410-
TableDefinition tableDef = catalog().tableDefinition(table.name());
410+
TableDefinition tableDef = catalog().tableDefinition(table.qualifiedName());
411411
assertEquals(tableDef.tableName(), tableDef.tableName());
412412

413413
List<ColumnDefinition> columns = tableDef.columns();

modules/client-handler/src/main/java/org/apache/ignite/client/handler/requests/table/ClientTableGetRequest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ public static CompletableFuture<Void> process(
4848
out.packNil();
4949
} else {
5050
out.packInt(((TableViewInternal) table).tableId());
51-
out.packString(quoteTableNameIfNotAllUpper(table.name().objectName()));
51+
out.packString(quoteTableNameIfNotAllUpper(table.qualifiedName().objectName()));
5252
}
5353
});
5454
}

modules/client-handler/src/main/java/org/apache/ignite/client/handler/requests/table/ClientTablesGetRequest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ public static CompletableFuture<Void> process(
4545
var tableImpl = (TableViewInternal) table;
4646

4747
out.packInt(tableImpl.tableId());
48-
out.packString(quoteTableNameIfNotAllUpper(table.name().objectName()));
48+
out.packString(quoteTableNameIfNotAllUpper(table.qualifiedName().objectName()));
4949
}
5050
});
5151
}

modules/client/src/main/java/org/apache/ignite/internal/client/compute/ClientCompute.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -466,7 +466,7 @@ private CompletableFuture<ClientTable> getTable(String tableName) {
466466
}
467467

468468
ClientTable clientTable = (ClientTable) t;
469-
tableCache.put(t.name(), clientTable);
469+
tableCache.put(t.qualifiedName(), clientTable);
470470

471471
return clientTable;
472472
});

modules/client/src/main/java/org/apache/ignite/internal/client/table/AbstractClientView.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ public CompletableFuture<AsyncCursor<T>> queryAsync(
112112
.thenCompose((schema) -> {
113113
SqlSerializer ser = new SqlSerializer.Builder()
114114
.columns(Arrays.asList(columnNames(schema.columns())))
115-
.tableName(tbl.name())
115+
.tableName(tbl.qualifiedName())
116116
.indexName(indexName != null ? QualifiedName.parse(indexName).objectName() : null)
117117
.where(criteria)
118118
.build();

modules/client/src/main/java/org/apache/ignite/internal/client/table/ClientTable.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ ReliableChannel channel() {
142142

143143
/** {@inheritDoc} */
144144
@Override
145-
public QualifiedName name() {
145+
public QualifiedName qualifiedName() {
146146
return name;
147147
}
148148

modules/client/src/test/java/org/apache/ignite/client/AbstractClientTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ public void beforeEach() throws InterruptedException {
8787

8888
protected void dropTables(Ignite ignite) {
8989
for (var t : ignite.tables().tables()) {
90-
((FakeIgniteTables) ignite.tables()).dropTable(t.name());
90+
((FakeIgniteTables) ignite.tables()).dropTable(t.qualifiedName());
9191
}
9292
}
9393

modules/client/src/test/java/org/apache/ignite/client/ClientLoggingTest.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -61,8 +61,8 @@ public void loggersSetToDifferentClientsNotInterfereWithEachOther() {
6161
var client1 = createClient(loggerFactory1, 10901, 10902);
6262
var client2 = createClient(loggerFactory2, 10901, 10902);
6363

64-
assertEquals("T", client1.tables().tables().get(0).name().objectName());
65-
assertEquals("T", client2.tables().tables().get(0).name().objectName());
64+
assertEquals("T", client1.tables().tables().get(0).qualifiedName().objectName());
65+
assertEquals("T", client2.tables().tables().get(0).qualifiedName().objectName());
6666

6767
server.close();
6868

@@ -71,8 +71,8 @@ public void loggersSetToDifferentClientsNotInterfereWithEachOther() {
7171

7272
server2 = startServer(ignite2, 10902);
7373

74-
assertEquals("T2", client1.tables().tables().get(0).name().objectName());
75-
assertEquals("T2", client2.tables().tables().get(0).name().objectName());
74+
assertEquals("T2", client1.tables().tables().get(0).qualifiedName().objectName());
75+
assertEquals("T2", client2.tables().tables().get(0).qualifiedName().objectName());
7676

7777
assertThat(loggerFactory1.logger.entries(), not(empty()));
7878
assertThat(loggerFactory2.logger.entries(), not(empty()));

modules/client/src/test/java/org/apache/ignite/client/ClientTableTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -479,7 +479,7 @@ public void testGetFromDroppedTableThrowsException() {
479479

480480
private void checkSchemaUpdate(Consumer<RecordView<Tuple>> consumer) throws Exception {
481481
try (var client2 = startClient()) {
482-
var table = client2.tables().table(defaultTable().name());
482+
var table = client2.tables().table(defaultTable().qualifiedName());
483483
Map<Integer, Object> schemas = IgniteTestUtils.getFieldValue(table, "schemas");
484484
var recView = table.recordView();
485485

modules/client/src/test/java/org/apache/ignite/client/ClientTablesTest.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,12 @@
1717

1818
package org.apache.ignite.client;
1919

20+
import static java.util.stream.Collectors.toList;
2021
import static org.hamcrest.MatcherAssert.assertThat;
2122
import static org.hamcrest.Matchers.containsInAnyOrder;
2223
import static org.junit.jupiter.api.Assertions.assertEquals;
2324
import static org.junit.jupiter.api.Assertions.assertNull;
2425

25-
import java.util.stream.Collectors;
2626
import org.apache.ignite.client.fakes.FakeIgniteTables;
2727
import org.apache.ignite.table.Table;
2828
import org.junit.jupiter.api.Test;
@@ -39,7 +39,7 @@ public void testTablesWhenTablesExist() {
3939
var tables = client.tables().tables();
4040
assertEquals(2, tables.size());
4141

42-
assertThat(tables.stream().map(t -> t.name().objectName()).collect(Collectors.toList()), containsInAnyOrder(DEFAULT_TABLE, "T"));
42+
assertThat(tables.stream().map(t -> t.qualifiedName().objectName()).collect(toList()), containsInAnyOrder(DEFAULT_TABLE, "T"));
4343
}
4444

4545
@Test
@@ -54,7 +54,7 @@ public void testTableReturnsInstanceWhenExists() {
5454
((FakeIgniteTables) server.tables()).createTable(DEFAULT_TABLE);
5555
Table table = client.tables().table(DEFAULT_TABLE);
5656

57-
assertEquals(DEFAULT_TABLE, table.name().objectName());
57+
assertEquals(DEFAULT_TABLE, table.qualifiedName().objectName());
5858
}
5959

6060
@Test

modules/client/src/test/java/org/apache/ignite/client/PartitionAwarenessTest.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -449,8 +449,8 @@ public void testExecuteColocatedTupleKeyRoutesRequestToPrimaryNode() {
449449

450450
JobDescriptor<Object, String> job = JobDescriptor.<Object, String>builder("job").build();
451451

452-
assertThat(compute().executeAsync(JobTarget.colocated(table.name(), t1), job, null), willBe(nodeKey1));
453-
assertThat(compute().executeAsync(JobTarget.colocated(table.name(), t2), job, null), willBe(nodeKey2));
452+
assertThat(compute().executeAsync(JobTarget.colocated(table.qualifiedName(), t1), job, null), willBe(nodeKey1));
453+
assertThat(compute().executeAsync(JobTarget.colocated(table.qualifiedName(), t2), job, null), willBe(nodeKey2));
454454
}
455455

456456
@Test
@@ -459,8 +459,8 @@ public void testExecuteColocatedObjectKeyRoutesRequestToPrimaryNode() {
459459
Table table = defaultTable();
460460
JobDescriptor<Object, String> job = JobDescriptor.<Object, String>builder("job").build();
461461

462-
assertThat(compute().executeAsync(JobTarget.colocated(table.name(), 1L, mapper), job, null), willBe(nodeKey1));
463-
assertThat(compute().executeAsync(JobTarget.colocated(table.name(), 2L, mapper), job, null), willBe(nodeKey2));
462+
assertThat(compute().executeAsync(JobTarget.colocated(table.qualifiedName(), 1L, mapper), job, null), willBe(nodeKey1));
463+
assertThat(compute().executeAsync(JobTarget.colocated(table.qualifiedName(), 2L, mapper), job, null), willBe(nodeKey2));
464464
}
465465

466466
@ParameterizedTest

modules/client/src/test/java/org/apache/ignite/client/ReconnectTest.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ public void clientReconnectsToAnotherAddressOnNodeFail() {
6161
.retryPolicy(new RetryLimitPolicy().retryLimit(100))
6262
.build();
6363

64-
assertEquals("T", client.tables().tables().get(0).name().objectName());
64+
assertEquals("T", client.tables().tables().get(0).qualifiedName().objectName());
6565

6666
server.close();
6767

@@ -70,7 +70,7 @@ public void clientReconnectsToAnotherAddressOnNodeFail() {
7070

7171
server2 = new TestServer(0, ignite2, null, null, null, AbstractClientTest.clusterId, null, 10950);
7272

73-
assertEquals("T2", client.tables().tables().get(0).name().objectName());
73+
assertEquals("T2", client.tables().tables().get(0).qualifiedName().objectName());
7474
}
7575

7676
@Test
@@ -85,7 +85,7 @@ public void testOperationFailsWhenAllServersFail() {
8585
.addresses("127.0.0.1:" + server.port(), "127.0.0.1:10960")
8686
.build();
8787

88-
assertEquals("T", client.tables().tables().get(0).name().objectName());
88+
assertEquals("T", client.tables().tables().get(0).qualifiedName().objectName());
8989

9090
server.close();
9191

modules/client/src/test/java/org/apache/ignite/client/RetryPolicyTest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ public void testNoRetryPolicySecondRequestFails() {
6464
initServer(reqId -> reqId % 3 == 0);
6565

6666
try (var client = getClient(null)) {
67-
assertEquals("T", client.tables().tables().get(0).name().objectName());
67+
assertEquals("T", client.tables().tables().get(0).qualifiedName().objectName());
6868
assertThrows(IgniteException.class, () -> client.tables().tables().get(0).name());
6969
}
7070
}
@@ -79,7 +79,7 @@ public void testRetryPolicyCompletesOperationWithoutException() {
7979

8080
try (var client = getClient(plc)) {
8181
for (int i = 0; i < ITER; i++) {
82-
assertEquals("T", client.tables().tables().get(0).name().objectName());
82+
assertEquals("T", client.tables().tables().get(0).qualifiedName().objectName());
8383
}
8484

8585
assertEquals(ITER / 2 - 1, plc.invocations.size());

modules/compute/src/main/java/org/apache/ignite/internal/compute/IgniteComputeImpl.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -470,10 +470,9 @@ private CompletableFuture<ClusterNode> primaryReplicaForPartition(TableViewInter
470470
return topologyService.getById(replicaMeta.getLeaseholderId());
471471
}
472472

473-
String tableName = table.name().toCanonicalForm();
474473
throw new ComputeException(
475474
Compute.PRIMARY_REPLICA_RESOLVE_ERR,
476-
"Can not find primary replica for [table=" + tableName + ", partition=" + partitionIndex + "]."
475+
"Can not find primary replica for [table=" + table.name() + ", partition=" + partitionIndex + "]."
477476
);
478477
});
479478
}

modules/runner/src/integrationTest/java/org/apache/ignite/internal/app/SyncApiOperation.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ enum SyncApiOperation {
5353
TABLES_TABLE(refs -> refs.tables.table(TEST_TABLE_NAME)),
5454

5555
TABLE_NAME(refs -> refs.table.name()),
56+
TABLE_QUALIFIED_NAME(refs -> refs.table.qualifiedName()),
5657
TABLE_KV_VIEW(refs -> refs.table.keyValueView()),
5758
TABLE_TYPED_KV_VIEW(refs -> refs.table.keyValueView(Integer.class, String.class)),
5859
TABLE_MAPPED_KV_VIEW(refs -> refs.table.keyValueView(Mapper.of(Integer.class), Mapper.of(String.class))),

modules/runner/src/integrationTest/java/org/apache/ignite/internal/runner/app/ItIgniteNodeRestartTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1291,7 +1291,7 @@ private void assertTablePresent(TableManager tableManager, String tableName) {
12911291
boolean isPresent = false;
12921292

12931293
for (TableImpl table : tables) {
1294-
if (table.name().objectName().equals(tableName)) {
1294+
if (table.qualifiedName().objectName().equals(tableName)) {
12951295
isPresent = true;
12961296

12971297
break;

modules/runner/src/integrationTest/java/org/apache/ignite/internal/runner/app/client/ItThinClientComputeMarshallingTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -276,7 +276,7 @@ void colocated() {
276276
column("v", ColumnType.INT32)
277277
)
278278
.build()
279-
).name();
279+
).qualifiedName();
280280

281281
// When run job with custom marshaller for string argument.
282282
var tup = Tuple.create().set("key", 1);

modules/runner/src/integrationTest/java/org/apache/ignite/internal/runner/app/client/ItThinClientConnectionTest.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ void testThinClientConnectsToServerNodesAndExecutesBasicTableOperations() {
5757
assertEquals(1, tables.size());
5858

5959
Table table = tables.get(0);
60-
assertEquals(TABLE_NAME, table.name().objectName());
60+
assertEquals(TABLE_NAME, table.qualifiedName().objectName());
6161

6262
var tuple = Tuple.create().set(COLUMN_KEY, 1).set(COLUMN_VAL, "Hello");
6363
var keyTuple = Tuple.create().set(COLUMN_KEY, 1);
@@ -130,14 +130,14 @@ void testExceptionHasHint() {
130130
void testServerReturnsActualTableName() {
131131
// Quoting is not necessary.
132132
Table table = client().tables().table("tbl1");
133-
assertEquals("TBL1", table.name().objectName());
133+
assertEquals("TBL1", table.qualifiedName().objectName());
134134

135135
// Quoting is necessary.
136136
client().sql().execute(null, "CREATE TABLE IF NOT EXISTS \"tbl-2\" (key INTEGER PRIMARY KEY)");
137137

138138
try {
139139
Table table2 = client().tables().table("\"tbl-2\"");
140-
assertEquals("tbl-2", table2.name().objectName());
140+
assertEquals("tbl-2", table2.qualifiedName().objectName());
141141
} finally {
142142
client().sql().execute(null, "DROP TABLE \"tbl-2\"");
143143
}

modules/runner/src/integrationTest/java/org/apache/ignite/internal/schemasync/ItSchemaForwardCompatibilityTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ void forwardIncompatibleSchemaChangesDoNotAllowSyncCommit(ForwardIncompatibleDdl
108108
containsString(String.format(
109109
"Commit failed because schema is not forward-compatible [fromSchemaVersion=1, toSchemaVersion=2, table=%s, "
110110
+ "details=%s]",
111-
table.name().objectName(),
111+
table.qualifiedName().objectName(),
112112
ddl.expectedDetails
113113
))
114114
);

modules/runner/src/integrationTest/java/org/apache/ignite/internal/schemasync/ItSchemaSyncSingleNodeTest.java

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ void readWriteOperationInTxAfterAlteringSchemaOnTargetTableIsRejected(Operation
108108
ex.getMessage(),
109109
containsString(String.format(
110110
"Table schema was updated after the transaction was started [table=%s, startSchema=1, operationSchema=2]",
111-
table.name().objectName()
111+
table.qualifiedName().objectName()
112112
))
113113
);
114114
} else {
@@ -118,7 +118,7 @@ void readWriteOperationInTxAfterAlteringSchemaOnTargetTableIsRejected(Operation
118118
ex.getMessage(),
119119
is(String.format(
120120
"Table schema was updated after the transaction was started [table=%s, startSchema=1, operationSchema=2]",
121-
table.name().objectName()
121+
table.qualifiedName().objectName()
122122
))
123123
);
124124
}
@@ -146,7 +146,7 @@ private void enlistTableInTransaction(Table table, Transaction tx) {
146146

147147
private static void executeRwReadOn(Table table, Transaction tx, int key, Cluster cluster) {
148148
cluster.doInSession(0, session -> {
149-
executeUpdate("SELECT * FROM " + table.name().toCanonicalForm() + " WHERE id = " + key, session, tx);
149+
executeUpdate("SELECT * FROM " + table.name() + " WHERE id = " + key, session, tx);
150150
});
151151
}
152152

@@ -177,7 +177,7 @@ boolean sql() {
177177
@Override
178178
void execute(Table table, Transaction tx, Cluster cluster) {
179179
cluster.doInSession(0, session -> {
180-
executeUpdate("UPDATE " + table.name().toCanonicalForm() + " SET val = 'new value' WHERE id = " + KEY, session, tx);
180+
executeUpdate("UPDATE " + table.name() + " SET val = 'new value' WHERE id = " + KEY, session, tx);
181181
});
182182
}
183183

@@ -297,7 +297,8 @@ void commitAfterDroppingTargetTableIsRejected(CommitOperation operation) {
297297
assertThat(ex, is(instanceOf(IncompatibleSchemaException.class)));
298298
assertThat(
299299
ex.getMessage(),
300-
containsString(String.format("Commit failed because a table was already dropped [table=%s]", table.name().objectName()))
300+
containsString(String.format("Commit failed because a table was already dropped [table=%s]",
301+
table.qualifiedName().objectName()))
301302
);
302303

303304
assertThat(((IncompatibleSchemaException) ex).code(), is(Transactions.TX_INCOMPATIBLE_SCHEMA_ERR));
@@ -357,7 +358,7 @@ void readingDataInFutureVersionsFails(boolean scan) {
357358
containsString(String.format(
358359
"Operation failed because it tried to access a row with newer schema version than transaction's [table=%s, "
359360
+ "txSchemaVersion=1, rowSchemaVersion=2]",
360-
table.name().objectName()
361+
table.qualifiedName().objectName()
361362
))
362363
);
363364

modules/runner/src/integrationTest/java/org/apache/ignite/internal/table/ItColumnNameMappingTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ public void createTables() {
4848
@BeforeEach
4949
public void clearTables() {
5050
for (Table t : CLUSTER.aliveNode().tables().tables()) {
51-
sql("DELETE FROM " + t.name().toCanonicalForm());
51+
sql("DELETE FROM " + t.name());
5252
}
5353
}
5454

0 commit comments

Comments
 (0)