You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ignite.apache.org by vk...@apache.org on 2022/01/25 00:02:46 UTC
[ignite-3] branch ignite-3.0.0-alpha4 updated: IGNITE-16322 Fix database objects names case inconsisten between SQL and KV API (#563)
This is an automated email from the ASF dual-hosted git repository.
vkulichenko pushed a commit to branch ignite-3.0.0-alpha4
in repository https://gitbox.apache.org/repos/asf/ignite-3.git
The following commit(s) were added to refs/heads/ignite-3.0.0-alpha4 by this push:
new 50a08ba IGNITE-16322 Fix database objects names case inconsisten between SQL and KV API (#563)
50a08ba is described below
commit 50a08baf141000588e45406ca8aaaa4b35aee467
Author: Taras Ledkov <tl...@gridgain.com>
AuthorDate: Mon Jan 24 10:12:25 2022 -0800
IGNITE-16322 Fix database objects names case inconsisten between SQL and KV API (#563)
---
.../main/java/org/apache/ignite/table/Tuple.java | 62 +++++++---
.../java/org/apache/ignite/table/TupleImpl.java | 11 +-
.../apache/ignite/table/manager/IgniteTables.java | 32 +++--
.../apache/ignite/table/mapper/MapperBuilder.java | 40 ++++--
.../ignite/table/mapper/OneColumnMapperImpl.java | 3 +-
.../ignite/internal/client/table/ClientTuple.java | 9 +-
.../client/ClientKeyValueBinaryViewTest.java | 2 +-
.../ignite/client/ClientKeyValueViewTest.java | 4 +-
.../apache/ignite/client/ClientRecordViewTest.java | 4 +-
.../org/apache/ignite/client/ClientTableTest.java | 8 +-
.../org/apache/ignite/client/ClientTupleTest.java | 90 +++++++-------
.../java/org/apache/ignite/client/CustomTuple.java | 17 +--
.../ignite/client/fakes/FakeIgniteTables.java | 54 ++++----
.../ignite/internal/util/IgniteObjectName.java | 137 +++++++++++++++++++++
.../Table/CustomTestIgniteTuple.cs | 6 +-
.../Apache.Ignite.Tests/Table/IgniteTupleTests.cs | 49 +++++++-
.../dotnet/Apache.Ignite.Tests/Table/TableTests.cs | 2 +-
.../Apache.Ignite.Tests/Table/TablesTests.cs | 2 +-
.../dotnet/Apache.Ignite/Table/IgniteTuple.cs | 21 +++-
.../runner/app/AbstractSchemaChangeTest.java | 19 ++-
.../runner/app/ItTableApiContractTest.java | 10 +-
.../app/client/ItAbstractThinClientTest.java | 2 +-
.../definition/builder/AbstractIndexBuilder.java | 3 +-
.../builder/ColumnDefinitionBuilderImpl.java | 3 +-
.../builder/HashIndexDefinitionBuilderImpl.java | 9 +-
.../builder/PrimaryKeyDefinitionBuilderImpl.java | 17 ++-
.../builder/SortedIndexDefinitionBuilderImpl.java | 3 +-
.../builder/TableDefinitionBuilderImpl.java | 7 +-
.../marshaller/asm/AsmMarshallerGenerator.java | 2 +-
.../marshaller/asm/ColumnAccessCodeGenerator.java | 63 ++++++----
.../asm/ObjectMarshallerCodeGenerator.java | 22 ++--
.../builder/HashIndexDefinitionBuilderTest.java | 2 +-
.../SchemaConfigurationConverterTest.java | 2 +-
.../schema/marshaller/KvMarshallerTest.java | 126 +++++++++----------
.../internal/schema/marshaller/MapperTest.java | 115 +++++++++++------
.../schema/marshaller/RecordMarshallerTest.java | 94 +++++++-------
.../RecordMarshallerValidationsTest.java | 20 +--
.../sql/engine/exec/ddl/DdlCommandHandler.java | 51 ++++++--
.../index/RocksDbSortedIndexStorageTest.java | 2 +-
.../internal/table/AbstractRowTupleAdapter.java | 7 +-
.../internal/table/distributed/TableManager.java | 9 +-
.../internal/table/InteropOperationsTest.java | 4 +-
.../table/KeyValueBinaryViewOperationsTest.java | 57 +++------
.../KeyValueViewOperationsSimpleSchemaTest.java | 4 +-
.../internal/table/KeyValueViewOperationsTest.java | 56 ++++-----
.../internal/table/MutableRowTupleAdapterTest.java | 48 ++++----
.../table/RecordBinaryViewOperationsTest.java | 48 ++++----
.../internal/table/RecordViewOperationsTest.java | 54 ++++----
.../ignite/internal/table/TxAbstractTest.java | 8 +-
.../internal/table/impl/TestTupleBuilder.java | 7 +-
.../org/apache/ignite/table/TupleImplTest.java | 4 +-
51 files changed, 889 insertions(+), 542 deletions(-)
diff --git a/modules/api/src/main/java/org/apache/ignite/table/Tuple.java b/modules/api/src/main/java/org/apache/ignite/table/Tuple.java
index 3166ec0..ef0579c 100644
--- a/modules/api/src/main/java/org/apache/ignite/table/Tuple.java
+++ b/modules/api/src/main/java/org/apache/ignite/table/Tuple.java
@@ -30,6 +30,8 @@ import org.jetbrains.annotations.NotNull;
/**
* Tuple represents arbitrary set of columns whose values is accessible by column name.
+ * Attention: column name arguments passed to the methods of the tuple must use SQL-parser style quotation, e.g.
+ * "myColumn" - means name "MYCOLUMN", "\"MyColumn\"" - "MyColumn", etc.
*
* <p>Provides specialized method for some value-types to avoid boxing/unboxing.
*/
@@ -189,7 +191,9 @@ public interface Tuple extends Iterable<Object> {
/**
* Gets column value when a column with specified name is present in this tuple; returns default value otherwise.
*
- * @param columnName Column name.
+ * @param columnName Column name with SQL-parser style quotation, e.g.
+ * "myColumn" - returns the value of the column with name "MYCOLUMN",
+ * "\"MyColumn\"" - "MyColumn", etc.
* @param defaultValue Default value.
* @param <T> Column default value type.
* @return Column value if this tuple contains a column with the specified name. Otherwise returns {@code defaultValue}.
@@ -199,7 +203,9 @@ public interface Tuple extends Iterable<Object> {
/**
* Sets column value.
*
- * @param columnName Column name.
+ * @param columnName Column name with SQL-parser style quotation, e.g.
+ * "myColumn" - sets the column with name "MYCOLUMN",
+ * "\"MyColumn\"" - "MyColumn", etc.
* @param value Value to set.
* @return {@code this} for chaining.
*/
@@ -208,7 +214,9 @@ public interface Tuple extends Iterable<Object> {
/**
* Gets column value for given column name.
*
- * @param columnName Column name.
+ * @param columnName Column name with SQL-parser style quotation, e.g.
+ * "myColumn" - returns the value of the column with name "MYCOLUMN",
+ * "\"MyColumn\"" - "MyColumn", etc.
* @param <T> Value type.
* @return Column value.
* @throws IllegalArgumentException If column with given name doesn't exists.
@@ -264,7 +272,9 @@ public interface Tuple extends Iterable<Object> {
/**
* Gets {@code short} column value.
*
- * @param columnName Column name.
+ * @param columnName Column name with SQL-parser style quotation, e.g.
+ * "myColumn" - returns the value of the column with name "MYCOLUMN",
+ * "\"MyColumn\"" - "MyColumn", etc.
* @return Column value.
* @throws IllegalArgumentException If column with given name doesn't exists.
*/
@@ -282,7 +292,9 @@ public interface Tuple extends Iterable<Object> {
/**
* Gets {@code int} column value.
*
- * @param columnName Column name.
+ * @param columnName Column name with SQL-parser style quotation, e.g.
+ * "myColumn" - returns the value of the column with name "MYCOLUMN",
+ * "\"MyColumn\"" - "MyColumn", etc.
* @return Column value.
* @throws IllegalArgumentException If column with given name doesn't exists.
*/
@@ -300,7 +312,9 @@ public interface Tuple extends Iterable<Object> {
/**
* Gets {@code long} column value.
*
- * @param columnName Column name.
+ * @param columnName Column name with SQL-parser style quotation, e.g.
+ * "myColumn" - returns the value of the column with name "MYCOLUMN",
+ * "\"MyColumn\"" - "MyColumn", etc.
* @return Column value.
* @throws IllegalArgumentException If column with given name doesn't exists.
*/
@@ -318,7 +332,9 @@ public interface Tuple extends Iterable<Object> {
/**
* Gets {@code float} column value.
*
- * @param columnName Column name.
+ * @param columnName Column name with SQL-parser style quotation, e.g.
+ * "myColumn" - returns the value of the column with name "MYCOLUMN",
+ * "\"MyColumn\"" - "MyColumn", etc.
* @return Column value.
* @throws IllegalArgumentException If column with given name doesn't exists.
*/
@@ -336,7 +352,9 @@ public interface Tuple extends Iterable<Object> {
/**
* Gets {@code double} column value.
*
- * @param columnName Column name.
+ * @param columnName Column name with SQL-parser style quotation, e.g.
+ * "myColumn" - returns the value of the column with name "MYCOLUMN",
+ * "\"MyColumn\"" - "MyColumn", etc.
* @return Column value.
* @throws IllegalArgumentException If column with given name doesn't exists.
*/
@@ -354,7 +372,9 @@ public interface Tuple extends Iterable<Object> {
/**
* Gets {@code String} column value.
*
- * @param columnName Column name.
+ * @param columnName Column name with SQL-parser style quotation, e.g.
+ * "myColumn" - returns the value of the column with name "MYCOLUMN",
+ * "\"MyColumn\"" - "MyColumn", etc.
* @return Column value.
* @throws IllegalArgumentException If column with given name doesn't exists.
*/
@@ -372,7 +392,9 @@ public interface Tuple extends Iterable<Object> {
/**
* Gets {@code UUID} column value.
*
- * @param columnName Column name.
+ * @param columnName Column name with SQL-parser style quotation, e.g.
+ * "myColumn" - returns the value of the column with name "MYCOLUMN",
+ * "\"MyColumn\"" - "MyColumn", etc.
* @return Column value.
* @throws IllegalArgumentException If column with given name doesn't exists.
*/
@@ -390,7 +412,9 @@ public interface Tuple extends Iterable<Object> {
/**
* Gets {@code BitSet} column value.
*
- * @param columnName Column name.
+ * @param columnName Column name with SQL-parser style quotation, e.g.
+ * "myColumn" - returns the value of the column with name "MYCOLUMN",
+ * "\"MyColumn\"" - "MyColumn", etc.
* @return Column value.
* @throws IllegalArgumentException If column with given name doesn't exists.
*/
@@ -408,7 +432,9 @@ public interface Tuple extends Iterable<Object> {
/**
* Gets {@code LocalDate} column value.
*
- * @param columnName Column name.
+ * @param columnName Column name with SQL-parser style quotation, e.g.
+ * "myColumn" - returns the value of the column with name "MYCOLUMN",
+ * "\"MyColumn\"" - "MyColumn", etc.
* @return Column value.
* @throws IllegalArgumentException If column with given name doesn't exists.
*/
@@ -426,7 +452,9 @@ public interface Tuple extends Iterable<Object> {
/**
* Gets {@code LocalTime} column value.
*
- * @param columnName Column name.
+ * @param columnName Column name with SQL-parser style quotation, e.g.
+ * "myColumn" - returns the value of the column with name "MYCOLUMN",
+ * "\"MyColumn\"" - "MyColumn", etc.
* @return Column value.
* @throws IllegalArgumentException If column with given name doesn't exists.
*/
@@ -444,7 +472,9 @@ public interface Tuple extends Iterable<Object> {
/**
* Gets {@code LocalDateTime} column value.
*
- * @param columnName Column name.
+ * @param columnName Column name with SQL-parser style quotation, e.g.
+ * "myColumn" - returns the value of the column with name "MYCOLUMN",
+ * "\"MyColumn\"" - "MyColumn", etc.
* @return Column value.
* @throws IllegalArgumentException If column with given name doesn't exists.
*/
@@ -462,7 +492,9 @@ public interface Tuple extends Iterable<Object> {
/**
* Gets {@code Instant} column value.
*
- * @param columnName Column name.
+ * @param columnName Column name with SQL-parser style quotation, e.g.
+ * "myColumn" - returns the value of the column with name "MYCOLUMN",
+ * "\"MyColumn\"" - "MyColumn", etc.
* @return Column value.
* @throws IllegalArgumentException If column with given name doesn't exists.
*/
diff --git a/modules/api/src/main/java/org/apache/ignite/table/TupleImpl.java b/modules/api/src/main/java/org/apache/ignite/table/TupleImpl.java
index 6d7955f..0a0d2c2 100644
--- a/modules/api/src/main/java/org/apache/ignite/table/TupleImpl.java
+++ b/modules/api/src/main/java/org/apache/ignite/table/TupleImpl.java
@@ -32,6 +32,7 @@ import java.util.Map;
import java.util.Objects;
import java.util.UUID;
import org.apache.ignite.binary.BinaryObject;
+import org.apache.ignite.internal.util.IgniteObjectName;
import org.jetbrains.annotations.NotNull;
/**
@@ -99,13 +100,15 @@ class TupleImpl implements Tuple, Serializable {
/** {@inheritDoc} */
@Override
public Tuple set(@NotNull String columnName, Object val) {
- int idx = colMapping.computeIfAbsent(Objects.requireNonNull(columnName), name -> colMapping.size());
+ String columnName0 = IgniteObjectName.parse(columnName);
+
+ int idx = colMapping.computeIfAbsent(Objects.requireNonNull(columnName0), name -> colMapping.size());
if (idx == colNames.size()) {
- colNames.add(idx, columnName);
+ colNames.add(idx, columnName0);
colValues.add(idx, val);
} else {
- colNames.set(idx, columnName);
+ colNames.set(idx, columnName0);
colValues.set(idx, val);
}
@@ -125,7 +128,7 @@ class TupleImpl implements Tuple, Serializable {
public int columnIndex(@NotNull String columnName) {
Objects.requireNonNull(columnName);
- Integer idx = colMapping.get(columnName);
+ Integer idx = colMapping.get(IgniteObjectName.parse(columnName));
return idx == null ? -1 : idx;
}
diff --git a/modules/api/src/main/java/org/apache/ignite/table/manager/IgniteTables.java b/modules/api/src/main/java/org/apache/ignite/table/manager/IgniteTables.java
index e20e8b7..d88f2e7 100644
--- a/modules/api/src/main/java/org/apache/ignite/table/manager/IgniteTables.java
+++ b/modules/api/src/main/java/org/apache/ignite/table/manager/IgniteTables.java
@@ -33,7 +33,9 @@ public interface IgniteTables {
/**
* Creates a new table with the given {@code name}. If a table with the same name already exists, an exception will be thrown.
*
- * @param name Table name.
+ * @param name Canonical name of the table ([schemaName].[tableName]) with SQL-parser style quotation, e.g.
+ * "public.tbl0" - the table "PUBLIC.TBL0" will be created,
+ * "PUBLIC.\"Tbl0\"" - "PUBLIC.Tbl0", "\"MySchema\".\"Tbl0\"" - "MySchema.Tbl0", etc.
* @param tableInitChange Table changer.
* @return Newly created table.
* @throws TableAlreadyExistsException If table with given name already exists.
@@ -48,7 +50,9 @@ public interface IgniteTables {
* Creates a new table with the given {@code name} asynchronously. If a table with the same name already exists, a future will be
* completed with the {@link TableAlreadyExistsException}.
*
- * @param name Table name.
+ * @param name Canonical name of the table ([schemaName].[tableName]) with SQL-parser style quotation, e.g.
+ * "public.tbl0" - the table "PUBLIC.TBL0" will be created,
+ * "PUBLIC.\"Tbl0\"" - "PUBLIC.Tbl0", "\"MySchema\".\"Tbl0\"" - "MySchema.Tbl0", etc.
* @param tableInitChange Table changer.
* @return Future representing pending completion of the operation.
* @throws IgniteException If an unspecified platform exception has happened internally. Is thrown when:
@@ -62,7 +66,9 @@ public interface IgniteTables {
/**
* Alters a cluster table. If the appropriate table does not exist, an exception will be thrown.
*
- * @param name Table name.
+ * @param name Canonical name of the table ([schemaName].[tableName]) with SQL-parser style quotation, e.g.
+ * "public.tbl0" - the table "PUBLIC.TBL0" will be changed,
+ * "PUBLIC.\"Tbl0\"" - "PUBLIC.Tbl0", "\"MySchema\".\"Tbl0\"" - "MySchema.Tbl0", etc.
* @param tableChange Table changer.
* @throws TableNotFoundException If a table with the {@code name} does not exist.
* @throws IgniteException If an unspecified platform exception has happened internally. Is thrown when:
@@ -76,7 +82,9 @@ public interface IgniteTables {
* Alters a cluster table. If the appropriate table does not exist, a future will
* complete with the {@link TableNotFoundException}.
*
- * @param name Table name.
+ * @param name Canonical name of the table ([schemaName].[tableName]) with SQL-parser style quotation, e.g.
+ * "public.tbl0" - the table "PUBLIC.TBL0" will be changed,
+ * "PUBLIC.\"Tbl0\"" - "PUBLIC.Tbl0", "\"MySchema\".\"Tbl0\"" - "MySchema.Tbl0", etc.
* @param tableChange Table changer.
* @return Future representing pending completion of the operation.
* @throws IgniteException If an unspecified platform exception has happened internally. Is thrown when:
@@ -90,7 +98,9 @@ public interface IgniteTables {
/**
* Drops a table with the name specified. If the appropriate table does not exist, an exception will be thrown.
*
- * @param name Table name.
+ * @param name Canonical name of the table ([schemaName].[tableName]) with SQL-parser style quotation, e.g.
+ * "public.tbl0" - the table "PUBLIC.TBL0" will be dropped,
+ * "PUBLIC.\"Tbl0\"" - "PUBLIC.Tbl0", "\"MySchema\".\"Tbl0\"" - "MySchema.Tbl0", etc.
* @throws TableNotFoundException If a table with the {@code name} does not exist.
* @throws IgniteException If an unspecified platform exception has happened internally. Is thrown when:
* <ul>
@@ -103,7 +113,9 @@ public interface IgniteTables {
* Drops a table with the name specified. If the appropriate table does not exist, a future will
* complete with the {@link TableNotFoundException}.
*
- * @param name Table name.
+ * @param name Canonical name of the table ([schemaName].[tableName]) with SQL-parser style quotation, e.g.
+ * "public.tbl0" - the table "PUBLIC.TBL0" will be dropped,
+ * "PUBLIC.\"Tbl0\"" - "PUBLIC.Tbl0", "\"MySchema\".\"Tbl0\"" - "MySchema.Tbl0", etc.
* @return Future representing pending completion of the operation.
* @throws IgniteException If an unspecified platform exception has happened internally. Is thrown when:
* <ul>
@@ -138,7 +150,9 @@ public interface IgniteTables {
/**
* Gets a table by name, if it was created before.
*
- * @param name Name of the table.
+ * @param name Canonical name of the table ([schemaName].[tableName]) with SQL-parser style quotation, e.g.
+ * "public.tbl0" - the table "PUBLIC.TBL0" will be looked up,
+ * "PUBLIC.\"Tbl0\"" - "PUBLIC.Tbl0", "\"MySchema\".\"Tbl0\"" - "MySchema.Tbl0", etc.
* @return Tables with corresponding name or {@code null} if table isn't created.
* @throws IgniteException If an unspecified platform exception has happened internally. Is thrown when:
* <ul>
@@ -150,7 +164,9 @@ public interface IgniteTables {
/**
* Gets a table by name, if it was created before.
*
- * @param name Name of the table.
+ * @param name Canonical name of the table ([schemaName].[tableName]) with SQL-parser style quotation, e.g.
+ * "public.tbl0" - the table "PUBLIC.TBL0" will be looked up,
+ * "PUBLIC.\"Tbl0\"" - "PUBLIC.Tbl0", "\"MySchema\".\"Tbl0\"" - "MySchema.Tbl0", etc.
* @return Future representing pending completion of the operation.
* @throws IgniteException If an unspecified platform exception has happened internally. Is thrown when:
* <ul>
diff --git a/modules/api/src/main/java/org/apache/ignite/table/mapper/MapperBuilder.java b/modules/api/src/main/java/org/apache/ignite/table/mapper/MapperBuilder.java
index 6e91895..e6a54d9 100644
--- a/modules/api/src/main/java/org/apache/ignite/table/mapper/MapperBuilder.java
+++ b/modules/api/src/main/java/org/apache/ignite/table/mapper/MapperBuilder.java
@@ -24,6 +24,7 @@ import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
import java.util.Objects;
+import org.apache.ignite.internal.util.IgniteObjectName;
import org.jetbrains.annotations.NotNull;
/**
@@ -77,7 +78,9 @@ public final class MapperBuilder<T> {
* Creates a mapper builder for a natively supported type.
*
* @param targetType Target type.
- * @param mappedColumn Column name to map to.
+ * @param mappedColumn Column name to map to; column name must use SQL-parser style quotation, e.g.
+ * "myColumn" - means column name "MYCOLUMN",
+ * "\"MyColumn\"" - "MyColumn", etc.
*/
MapperBuilder(@NotNull Class<T> targetType, String mappedColumn) {
this.targetType = Mapper.ensureNativelySupported(targetType);
@@ -134,7 +137,7 @@ public final class MapperBuilder<T> {
* Ensure field name is valid and field with this name exists.
*
* @param fieldName Field name.
- * @return Field name for chaining.
+ * @return Field's name for chaining.
* @throws IllegalArgumentException If field is {@code null} or class has no declared field with given name.
*/
private String requireValidField(String fieldName) {
@@ -154,8 +157,11 @@ public final class MapperBuilder<T> {
* Maps a field to a column.
*
* @param fieldName Field name.
- * @param columnName Column name.
- * @param fieldColumnPairs Vararg that accepts (fieldName, columnName) pairs.
+ * @param columnName Column name with SQL-parser style quotation, e.g.
+ * "myColumn" - means column name "MYCOLUMN",
+ * "\"MyColumn\"" - "MyColumn", etc.
+ * @param fieldColumnPairs Vararg that accepts (fieldName, columnName) pairs, column's names should use SQL SQL-parser style
+ * quotation like {@code columnName} parameter.
* @return {@code this} for chaining.
* @throws IllegalArgumentException If a field name has not paired column name in {@code fieldColumnPairs}, or a column was already
* mapped to another field.
@@ -164,17 +170,22 @@ public final class MapperBuilder<T> {
public MapperBuilder<T> map(@NotNull String fieldName, @NotNull String columnName, String... fieldColumnPairs) {
ensureNotStale();
+ String colName0 = IgniteObjectName.parse(columnName);
+
if (columnToFields == null) {
throw new IllegalArgumentException("Natively supported types doesn't support field mapping.");
} else if (fieldColumnPairs.length % 2 != 0) {
throw new IllegalArgumentException("fieldColumnPairs length should be even.");
- } else if (columnToFields.put(Objects.requireNonNull(columnName), requireValidField(fieldName)) != null) {
- throw new IllegalArgumentException("Mapping for a column already exists: " + columnName);
+ } else if (columnToFields.put(Objects.requireNonNull(colName0), requireValidField(fieldName)) != null) {
+ throw new IllegalArgumentException("Mapping for a column already exists: " + colName0);
}
for (int i = 0; i < fieldColumnPairs.length; i += 2) {
- if (columnToFields.put(Objects.requireNonNull(fieldColumnPairs[i + 1]), requireValidField(fieldColumnPairs[i])) != null) {
- throw new IllegalArgumentException("Mapping for a column already exists: " + columnName);
+ if (columnToFields.put(
+ IgniteObjectName.parse(Objects.requireNonNull(fieldColumnPairs[i + 1])),
+ requireValidField(fieldColumnPairs[i])) != null
+ ) {
+ throw new IllegalArgumentException("Mapping for a column already exists: " + colName0);
}
}
@@ -188,7 +199,9 @@ public final class MapperBuilder<T> {
* @param <ObjectT> Value type. Must match the object field type if the individual field is mapped to a given column.
* @param <ColumnT> Column type.
* @param fieldName Field name.
- * @param columnName Column name.
+ * @param columnName Column name with SQL-parser style quotation, e.g.
+ * "myColumn" - means column name "MYCOLUMN",
+ * "\"MyColumn\"" - "MyColumn", etc.
* @param converter Converter for objects of {@link ColumnT} and {@link ObjectT}.
*/
public <ObjectT, ColumnT> MapperBuilder<T> map(
@@ -207,13 +220,15 @@ public final class MapperBuilder<T> {
*
* @param <ObjectT> Value type. Must match either the object field type if a field mapped to given column, or the object type {@link T}
* @param <ColumnT> Column type.
- * @param columnName Column name.
+ * @param columnName Column name with SQL-parser style quotation, e.g.
+ * "myColumn" - means column name "MYCOLUMN",
+ * "\"MyColumn\"" - "MyColumn", etc.
* @param converter Converter for objects of {@link ColumnT} and {@link ObjectT}.
*/
public <ObjectT, ColumnT> MapperBuilder<T> convert(@NotNull String columnName, @NotNull TypeConverter<ObjectT, ColumnT> converter) {
ensureNotStale();
- if (columnConverters.put(columnName, converter) != null) {
+ if (columnConverters.put(IgniteObjectName.parse(columnName), converter) != null) {
throw new IllegalArgumentException("Column converter already exists: " + columnName);
}
@@ -261,7 +276,8 @@ public final class MapperBuilder<T> {
Arrays.stream(targetType.getDeclaredFields())
.map(Field::getName)
.filter(fldName -> !fields.contains(fldName))
- .forEach(fldName -> mapping.putIfAbsent(fldName, fldName)); // Ignore manually mapped fields/columns.
+ // Ignore manually mapped fields/columns.
+ .forEach(fldName -> mapping.putIfAbsent(fldName.toUpperCase(), fldName));
}
return new PojoMapperImpl<>(targetType, mapping, columnConverters);
diff --git a/modules/api/src/main/java/org/apache/ignite/table/mapper/OneColumnMapperImpl.java b/modules/api/src/main/java/org/apache/ignite/table/mapper/OneColumnMapperImpl.java
index 22d387f..ef16cea 100644
--- a/modules/api/src/main/java/org/apache/ignite/table/mapper/OneColumnMapperImpl.java
+++ b/modules/api/src/main/java/org/apache/ignite/table/mapper/OneColumnMapperImpl.java
@@ -17,6 +17,7 @@
package org.apache.ignite.table.mapper;
+import org.apache.ignite.internal.util.IgniteObjectName;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
@@ -37,7 +38,7 @@ class OneColumnMapperImpl<ObjectT> implements OneColumnMapper<ObjectT> {
OneColumnMapperImpl(@NotNull Class<ObjectT> targetType, @Nullable String mappedColumn, @Nullable TypeConverter<ObjectT, ?> converter) {
this.targetType = targetType;
- this.mappedColumn = mappedColumn;
+ this.mappedColumn = IgniteObjectName.parse(mappedColumn);
this.converter = converter;
}
diff --git a/modules/client/src/main/java/org/apache/ignite/internal/client/table/ClientTuple.java b/modules/client/src/main/java/org/apache/ignite/internal/client/table/ClientTuple.java
index f63e4eb..bdff03e 100644
--- a/modules/client/src/main/java/org/apache/ignite/internal/client/table/ClientTuple.java
+++ b/modules/client/src/main/java/org/apache/ignite/internal/client/table/ClientTuple.java
@@ -26,6 +26,7 @@ import java.util.Iterator;
import java.util.Objects;
import java.util.UUID;
import org.apache.ignite.binary.BinaryObject;
+import org.apache.ignite.internal.util.IgniteObjectName;
import org.apache.ignite.table.Tuple;
import org.jetbrains.annotations.NotNull;
@@ -78,7 +79,7 @@ public final class ClientTuple implements Tuple {
/** {@inheritDoc} */
@Override
public Tuple set(@NotNull String columnName, Object value) {
- var col = schema.column(columnName);
+ var col = schema.column(IgniteObjectName.parse(columnName));
vals[col.schemaIndex() - minColumnIndex] = value == null ? NULL_OBJ : value;
@@ -88,7 +89,7 @@ public final class ClientTuple implements Tuple {
/** {@inheritDoc} */
@Override
public <T> T valueOrDefault(@NotNull String columnName, T def) {
- var col = schema.columnSafe(columnName);
+ var col = schema.columnSafe(IgniteObjectName.parse(columnName));
if (col == null) {
return def;
@@ -102,7 +103,7 @@ public final class ClientTuple implements Tuple {
/** {@inheritDoc} */
@Override
public <T> T value(@NotNull String columnName) {
- var col = schema.column(columnName);
+ var col = schema.column(IgniteObjectName.parse(columnName));
return getValue(col.schemaIndex() - minColumnIndex);
}
@@ -132,7 +133,7 @@ public final class ClientTuple implements Tuple {
/** {@inheritDoc} */
@Override
public int columnIndex(@NotNull String columnName) {
- var col = schema.columnSafe(columnName);
+ var col = schema.columnSafe(IgniteObjectName.parse(columnName));
if (col == null || col.schemaIndex() < minColumnIndex || col.schemaIndex() > maxColumnIndex) {
return -1;
diff --git a/modules/client/src/test/java/org/apache/ignite/client/ClientKeyValueBinaryViewTest.java b/modules/client/src/test/java/org/apache/ignite/client/ClientKeyValueBinaryViewTest.java
index c8b6d73..ea0cfc6 100644
--- a/modules/client/src/test/java/org/apache/ignite/client/ClientKeyValueBinaryViewTest.java
+++ b/modules/client/src/test/java/org/apache/ignite/client/ClientKeyValueBinaryViewTest.java
@@ -172,7 +172,7 @@ public class ClientKeyValueBinaryViewTest extends AbstractClientTableTest {
KeyValueView<Tuple, Tuple> kvView = defaultTable().keyValueView();
var ex = assertThrows(IgniteClientException.class, () -> kvView.contains(null, Tuple.create()));
- assertTrue(ex.getMessage().contains("Missed key column: id"), ex.getMessage());
+ assertTrue(ex.getMessage().contains("Missed key column: ID"), ex.getMessage());
}
@Test
diff --git a/modules/client/src/test/java/org/apache/ignite/client/ClientKeyValueViewTest.java b/modules/client/src/test/java/org/apache/ignite/client/ClientKeyValueViewTest.java
index 65b7acd..d2e1e6d 100644
--- a/modules/client/src/test/java/org/apache/ignite/client/ClientKeyValueViewTest.java
+++ b/modules/client/src/test/java/org/apache/ignite/client/ClientKeyValueViewTest.java
@@ -193,7 +193,7 @@ public class ClientKeyValueViewTest extends AbstractClientTableTest {
IgniteClientException e = assertThrows(IgniteClientException.class, () -> kvView.get(null, new NamePojo()));
- assertEquals("No field found for column id", e.getMessage());
+ assertEquals("No field found for column ID", e.getMessage());
}
@Test
@@ -224,7 +224,7 @@ public class ClientKeyValueViewTest extends AbstractClientTableTest {
assertNull(res.zdouble);
for (int i = 0; i < binRes.columnCount(); i++) {
- if (binRes.columnName(i).endsWith("id")) {
+ if (binRes.columnName(i).endsWith("ID")) {
continue;
}
diff --git a/modules/client/src/test/java/org/apache/ignite/client/ClientRecordViewTest.java b/modules/client/src/test/java/org/apache/ignite/client/ClientRecordViewTest.java
index 95a9075..d3e65f9 100644
--- a/modules/client/src/test/java/org/apache/ignite/client/ClientRecordViewTest.java
+++ b/modules/client/src/test/java/org/apache/ignite/client/ClientRecordViewTest.java
@@ -191,7 +191,7 @@ public class ClientRecordViewTest extends AbstractClientTableTest {
IgniteClientException e = assertThrows(IgniteClientException.class, () -> recordView.get(null, new NamePojo()));
- assertEquals("No field found for column id", e.getMessage());
+ assertEquals("No field found for column ID", e.getMessage());
}
@Test
@@ -219,7 +219,7 @@ public class ClientRecordViewTest extends AbstractClientTableTest {
assertNull(res.zdouble);
for (int i = 0; i < binRes.columnCount(); i++) {
- if (binRes.columnName(i).endsWith("id")) {
+ if (binRes.columnName(i).endsWith("ID")) {
continue;
}
diff --git a/modules/client/src/test/java/org/apache/ignite/client/ClientTableTest.java b/modules/client/src/test/java/org/apache/ignite/client/ClientTableTest.java
index 738bb42..a39f594 100644
--- a/modules/client/src/test/java/org/apache/ignite/client/ClientTableTest.java
+++ b/modules/client/src/test/java/org/apache/ignite/client/ClientTableTest.java
@@ -46,7 +46,7 @@ public class ClientTableTest extends AbstractClientTableTest {
var ex = assertThrows(IgniteClientException.class, () -> table.get(null, key));
- assertTrue(ex.getMessage().contains("Missed key column: id"),
+ assertTrue(ex.getMessage().contains("Missed key column: ID"),
ex.getMessage());
}
@@ -68,8 +68,8 @@ public class ClientTableTest extends AbstractClientTableTest {
assertEquals(DEFAULT_ID, resTuple.value(0));
assertEquals(2, resTuple.columnCount());
- assertEquals("id", resTuple.columnName(0));
- assertEquals("name", resTuple.columnName(1));
+ assertEquals("ID", resTuple.columnName(0));
+ assertEquals("NAME", resTuple.columnName(1));
var iter = tuple.iterator();
@@ -379,6 +379,6 @@ public class ClientTableTest extends AbstractClientTableTest {
var ex = assertThrows(IgniteClientException.class, () -> defaultTable().recordView().upsert(null, tuple));
- assertTrue(ex.getMessage().contains("Incorrect value type for column 'id': Expected Integer, but got String"), ex.getMessage());
+ assertTrue(ex.getMessage().contains("Incorrect value type for column 'ID': Expected Integer, but got String"), ex.getMessage());
}
}
diff --git a/modules/client/src/test/java/org/apache/ignite/client/ClientTupleTest.java b/modules/client/src/test/java/org/apache/ignite/client/ClientTupleTest.java
index dee4e74..5205d33 100644
--- a/modules/client/src/test/java/org/apache/ignite/client/ClientTupleTest.java
+++ b/modules/client/src/test/java/org/apache/ignite/client/ClientTupleTest.java
@@ -47,8 +47,8 @@ import org.junit.jupiter.api.Test;
*/
public class ClientTupleTest {
private static final ClientSchema SCHEMA = new ClientSchema(1, new ClientColumn[]{
- new ClientColumn("id", ClientDataType.INT64, false, true, 0),
- new ClientColumn("name", ClientDataType.STRING, false, false, 1)
+ new ClientColumn("ID", ClientDataType.INT64, false, true, 0),
+ new ClientColumn("NAME", ClientDataType.STRING, false, false, 1)
});
@Test
@@ -94,13 +94,13 @@ public class ClientTupleTest {
@Test
public void testSetThrowsWhenColumnIsNotPresent() {
var ex = assertThrows(IgniteException.class, () -> getBuilder().set("x", "y"));
- assertEquals("Column is not present in schema: x", ex.getMessage());
+ assertEquals("Column is not present in schema: X", ex.getMessage());
}
@Test
public void testValueThrowsWhenColumnIsNotPresent() {
var ex = assertThrows(IgniteException.class, () -> getBuilder().value("x"));
- assertEquals("Column is not present in schema: x", ex.getMessage());
+ assertEquals("Column is not present in schema: X", ex.getMessage());
var ex2 = assertThrows(IndexOutOfBoundsException.class, () -> getBuilder().value(100));
assertEquals("Index 100 out of bounds for length 2", ex2.getMessage());
@@ -113,8 +113,8 @@ public class ClientTupleTest {
@Test
public void testColumnNameReturnsNameByIndex() {
- assertEquals("id", getTuple().columnName(0));
- assertEquals("name", getTuple().columnName(1));
+ assertEquals("ID", getTuple().columnName(0));
+ assertEquals("NAME", getTuple().columnName(1));
}
@Test
@@ -137,19 +137,19 @@ public class ClientTupleTest {
@Test
public void testTypedGetters() {
var schema = new ClientSchema(100, new ClientColumn[]{
- new ClientColumn("i8", ClientDataType.INT8, false, false, 0),
- new ClientColumn("i16", ClientDataType.INT16, false, false, 1),
- new ClientColumn("i32", ClientDataType.INT32, false, false, 2),
- new ClientColumn("i64", ClientDataType.INT64, false, false, 3),
- new ClientColumn("float", ClientDataType.FLOAT, false, false, 4),
- new ClientColumn("double", ClientDataType.DOUBLE, false, false, 5),
- new ClientColumn("uuid", ClientDataType.UUID, false, false, 6),
- new ClientColumn("str", ClientDataType.STRING, false, false, 7),
- new ClientColumn("bits", ClientDataType.BITMASK, false, false, 8),
- new ClientColumn("time", ClientDataType.TIME, false, false, 9),
- new ClientColumn("date", ClientDataType.DATE, false, false, 10),
- new ClientColumn("datetime", ClientDataType.DATETIME, false, false, 11),
- new ClientColumn("timestamp", ClientDataType.TIMESTAMP, false, false, 12)
+ new ClientColumn("I8", ClientDataType.INT8, false, false, 0),
+ new ClientColumn("I16", ClientDataType.INT16, false, false, 1),
+ new ClientColumn("I32", ClientDataType.INT32, false, false, 2),
+ new ClientColumn("I64", ClientDataType.INT64, false, false, 3),
+ new ClientColumn("FLOAT", ClientDataType.FLOAT, false, false, 4),
+ new ClientColumn("DOUBLE", ClientDataType.DOUBLE, false, false, 5),
+ new ClientColumn("UUID", ClientDataType.UUID, false, false, 6),
+ new ClientColumn("STR", ClientDataType.STRING, false, false, 7),
+ new ClientColumn("BITS", ClientDataType.BITMASK, false, false, 8),
+ new ClientColumn("TIME", ClientDataType.TIME, false, false, 9),
+ new ClientColumn("DATE", ClientDataType.DATE, false, false, 10),
+ new ClientColumn("DATETIME", ClientDataType.DATETIME, false, false, 11),
+ new ClientColumn("TIMESTAMP", ClientDataType.TIMESTAMP, false, false, 12)
});
var uuid = UUID.randomUUID();
@@ -251,19 +251,19 @@ public class ClientTupleTest {
@Test
public void testTupleEquality() {
var schema = new ClientSchema(100, new ClientColumn[]{
- new ClientColumn("i8", ClientDataType.INT8, false, false, 0),
- new ClientColumn("i16", ClientDataType.INT16, false, false, 1),
- new ClientColumn("i32", ClientDataType.INT32, false, false, 2),
- new ClientColumn("i64", ClientDataType.INT64, false, false, 3),
- new ClientColumn("float", ClientDataType.FLOAT, false, false, 4),
- new ClientColumn("double", ClientDataType.DOUBLE, false, false, 5),
- new ClientColumn("uuid", ClientDataType.UUID, false, false, 6),
- new ClientColumn("str", ClientDataType.STRING, false, false, 7),
- new ClientColumn("bits", ClientDataType.BITMASK, false, false, 8),
- new ClientColumn("time", ClientDataType.TIME, false, false, 9),
- new ClientColumn("date", ClientDataType.DATE, false, false, 10),
- new ClientColumn("datetime", ClientDataType.DATETIME, false, false, 11),
- new ClientColumn("timestamp", ClientDataType.TIMESTAMP, false, false, 12)
+ new ClientColumn("I8", ClientDataType.INT8, false, false, 0),
+ new ClientColumn("I16", ClientDataType.INT16, false, false, 1),
+ new ClientColumn("I32", ClientDataType.INT32, false, false, 2),
+ new ClientColumn("I64", ClientDataType.INT64, false, false, 3),
+ new ClientColumn("FLOAT", ClientDataType.FLOAT, false, false, 4),
+ new ClientColumn("DOUBLE", ClientDataType.DOUBLE, false, false, 5),
+ new ClientColumn("UUID", ClientDataType.UUID, false, false, 6),
+ new ClientColumn("STR", ClientDataType.STRING, false, false, 7),
+ new ClientColumn("BITS", ClientDataType.BITMASK, false, false, 8),
+ new ClientColumn("TIME", ClientDataType.TIME, false, false, 9),
+ new ClientColumn("DATE", ClientDataType.DATE, false, false, 10),
+ new ClientColumn("DATETIME", ClientDataType.DATETIME, false, false, 11),
+ new ClientColumn("TIMESTAMP", ClientDataType.TIMESTAMP, false, false, 12)
});
var uuid = UUID.randomUUID();
@@ -304,19 +304,19 @@ public class ClientTupleTest {
@Test
public void testTupleEqualityCompatibility() {
var schema = new ClientSchema(100, new ClientColumn[]{
- new ClientColumn("i8", ClientDataType.INT8, false, false, 0),
- new ClientColumn("i16", ClientDataType.INT16, false, false, 1),
- new ClientColumn("i32", ClientDataType.INT32, false, false, 2),
- new ClientColumn("i64", ClientDataType.INT64, false, false, 3),
- new ClientColumn("float", ClientDataType.FLOAT, false, false, 4),
- new ClientColumn("double", ClientDataType.DOUBLE, false, false, 5),
- new ClientColumn("uuid", ClientDataType.UUID, false, false, 6),
- new ClientColumn("str", ClientDataType.STRING, false, false, 7),
- new ClientColumn("bits", ClientDataType.BITMASK, false, false, 8),
- new ClientColumn("time", ClientDataType.TIME, false, false, 9),
- new ClientColumn("date", ClientDataType.DATE, false, false, 10),
- new ClientColumn("datetime", ClientDataType.DATETIME, false, false, 11),
- new ClientColumn("timestamp", ClientDataType.TIMESTAMP, false, false, 12)
+ new ClientColumn("I8", ClientDataType.INT8, false, false, 0),
+ new ClientColumn("I16", ClientDataType.INT16, false, false, 1),
+ new ClientColumn("I32", ClientDataType.INT32, false, false, 2),
+ new ClientColumn("I64", ClientDataType.INT64, false, false, 3),
+ new ClientColumn("FLOAT", ClientDataType.FLOAT, false, false, 4),
+ new ClientColumn("DOUBLE", ClientDataType.DOUBLE, false, false, 5),
+ new ClientColumn("UUID", ClientDataType.UUID, false, false, 6),
+ new ClientColumn("STR", ClientDataType.STRING, false, false, 7),
+ new ClientColumn("BITS", ClientDataType.BITMASK, false, false, 8),
+ new ClientColumn("TIME", ClientDataType.TIME, false, false, 9),
+ new ClientColumn("DATE", ClientDataType.DATE, false, false, 10),
+ new ClientColumn("DATETIME", ClientDataType.DATETIME, false, false, 11),
+ new ClientColumn("TIMESTAMP", ClientDataType.TIMESTAMP, false, false, 12)
});
var uuid = UUID.randomUUID();
diff --git a/modules/client/src/test/java/org/apache/ignite/client/CustomTuple.java b/modules/client/src/test/java/org/apache/ignite/client/CustomTuple.java
index e980bc6..e6dc323 100644
--- a/modules/client/src/test/java/org/apache/ignite/client/CustomTuple.java
+++ b/modules/client/src/test/java/org/apache/ignite/client/CustomTuple.java
@@ -25,6 +25,7 @@ import java.util.BitSet;
import java.util.Iterator;
import java.util.UUID;
import org.apache.ignite.binary.BinaryObject;
+import org.apache.ignite.internal.util.IgniteObjectName;
import org.apache.ignite.table.Tuple;
import org.jetbrains.annotations.NotNull;
@@ -67,9 +68,9 @@ public class CustomTuple implements Tuple {
public String columnName(int columnIndex) {
switch (columnIndex) {
case 0:
- return "id";
+ return "ID";
case 1:
- return "name";
+ return "NAME";
default:
break;
}
@@ -80,10 +81,10 @@ public class CustomTuple implements Tuple {
/** {@inheritDoc} */
@Override
public int columnIndex(@NotNull String columnName) {
- switch (columnName) {
- case "id":
+ switch (IgniteObjectName.parse(columnName)) {
+ case "ID":
return 0;
- case "name":
+ case "NAME":
return 1;
default:
break;
@@ -95,10 +96,10 @@ public class CustomTuple implements Tuple {
/** {@inheritDoc} */
@Override
public <T> T valueOrDefault(@NotNull String columnName, T def) {
- switch (columnName) {
- case "id":
+ switch (IgniteObjectName.parse(columnName)) {
+ case "ID":
return (T) id;
- case "name":
+ case "NAME":
return (T) name;
default:
break;
diff --git a/modules/client/src/test/java/org/apache/ignite/client/fakes/FakeIgniteTables.java b/modules/client/src/test/java/org/apache/ignite/client/fakes/FakeIgniteTables.java
index 5c69493..67d7f92 100644
--- a/modules/client/src/test/java/org/apache/ignite/client/fakes/FakeIgniteTables.java
+++ b/modules/client/src/test/java/org/apache/ignite/client/fakes/FakeIgniteTables.java
@@ -178,16 +178,16 @@ public class FakeIgniteTables implements IgniteTables, IgniteTablesInternal {
case 1:
return new SchemaDescriptor(
1,
- new Column[]{new Column("id", NativeTypes.INT64, false)},
- new Column[]{new Column("name", NativeTypes.STRING, true)});
+ new Column[]{new Column("id".toUpperCase(), NativeTypes.INT64, false)},
+ new Column[]{new Column("name".toUpperCase(), NativeTypes.STRING, true)});
case 2:
return new SchemaDescriptor(
2,
- new Column[]{new Column("id", NativeTypes.INT64, false)},
+ new Column[]{new Column("id".toUpperCase(), NativeTypes.INT64, false)},
new Column[]{
- new Column("name", NativeTypes.STRING, true),
- new Column("xyz", NativeTypes.STRING, true)
+ new Column("name".toUpperCase(), NativeTypes.STRING, true),
+ new Column("xyz".toUpperCase(), NativeTypes.STRING, true)
});
default:
return null;
@@ -204,25 +204,25 @@ public class FakeIgniteTables implements IgniteTables, IgniteTablesInternal {
return new SchemaDescriptor(
v,
new Column[]{
- new Column("gid", NativeTypes.INT32, false),
- new Column("id", NativeTypes.STRING, false)
+ new Column("gid".toUpperCase(), NativeTypes.INT32, false),
+ new Column("id".toUpperCase(), NativeTypes.STRING, false)
},
new Column[]{
- new Column("zbyte", NativeTypes.INT8, true),
- new Column("zshort", NativeTypes.INT16, true),
- new Column("zint", NativeTypes.INT32, true),
- new Column("zlong", NativeTypes.INT64, true),
- new Column("zfloat", NativeTypes.FLOAT, true),
- new Column("zdouble", NativeTypes.DOUBLE, true),
- new Column("zdate", NativeTypes.DATE, true),
- new Column("ztime", NativeTypes.time(), true),
- new Column("ztimestamp", NativeTypes.timestamp(), true),
- new Column("zstring", NativeTypes.STRING, true),
- new Column("zbytes", NativeTypes.BYTES, true),
- new Column("zuuid", NativeTypes.UUID, true),
- new Column("zbitmask", NativeTypes.bitmaskOf(16), true),
- new Column("zdecimal", NativeTypes.decimalOf(20, 3), true),
- new Column("znumber", NativeTypes.numberOf(24), true),
+ new Column("zbyte".toUpperCase(), NativeTypes.INT8, true),
+ new Column("zshort".toUpperCase(), NativeTypes.INT16, true),
+ new Column("zint".toUpperCase(), NativeTypes.INT32, true),
+ new Column("zlong".toUpperCase(), NativeTypes.INT64, true),
+ new Column("zfloat".toUpperCase(), NativeTypes.FLOAT, true),
+ new Column("zdouble".toUpperCase(), NativeTypes.DOUBLE, true),
+ new Column("zdate".toUpperCase(), NativeTypes.DATE, true),
+ new Column("ztime".toUpperCase(), NativeTypes.time(), true),
+ new Column("ztimestamp".toUpperCase(), NativeTypes.timestamp(), true),
+ new Column("zstring".toUpperCase(), NativeTypes.STRING, true),
+ new Column("zbytes".toUpperCase(), NativeTypes.BYTES, true),
+ new Column("zuuid".toUpperCase(), NativeTypes.UUID, true),
+ new Column("zbitmask".toUpperCase(), NativeTypes.bitmaskOf(16), true),
+ new Column("zdecimal".toUpperCase(), NativeTypes.decimalOf(20, 3), true),
+ new Column("znumber".toUpperCase(), NativeTypes.numberOf(24), true),
});
}
@@ -236,12 +236,12 @@ public class FakeIgniteTables implements IgniteTables, IgniteTablesInternal {
return new SchemaDescriptor(
v,
new Column[]{
- new Column("id", NativeTypes.INT32, false)
+ new Column("id".toUpperCase(), NativeTypes.INT32, false)
},
new Column[]{
- new Column("num", NativeTypes.INT8, true, () -> (byte) 42),
- new Column("str", NativeTypes.STRING, true, () -> "def_str"),
- new Column("str_non_null", NativeTypes.STRING, false, () -> "def_str2"),
+ new Column("num".toUpperCase(), NativeTypes.INT8, true, () -> (byte) 42),
+ new Column("str".toUpperCase(), NativeTypes.STRING, true, () -> "def_str"),
+ new Column("str_non_null".toUpperCase(), NativeTypes.STRING, false, () -> "def_str2"),
});
}
@@ -255,7 +255,7 @@ public class FakeIgniteTables implements IgniteTables, IgniteTablesInternal {
private SchemaDescriptor getOneColumnSchema(Integer v) {
return new SchemaDescriptor(
v,
- new Column[]{new Column("id", NativeTypes.STRING, false)},
+ new Column[]{new Column("id".toUpperCase(), NativeTypes.STRING, false)},
new Column[0]);
}
}
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/util/IgniteObjectName.java b/modules/core/src/main/java/org/apache/ignite/internal/util/IgniteObjectName.java
new file mode 100644
index 0000000..7e8ab77
--- /dev/null
+++ b/modules/core/src/main/java/org/apache/ignite/internal/util/IgniteObjectName.java
@@ -0,0 +1,137 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.internal.util;
+
+import java.util.List;
+import java.util.stream.Collectors;
+import org.apache.ignite.lang.IgniteInternalException;
+
+/**
+ * Utility methods used for cluster's named objects: schemas, tables, columns, indexes, etc.
+ */
+public class IgniteObjectName {
+ /** No instance methods. */
+ private IgniteObjectName() {
+ }
+
+ /**
+ * Parse database's object name: unquote name or cast to upper case not-quoted name.
+ *
+ * @param str String to parse object name.
+ * @return Unquoted name or name is cast to upper case. "tbl0" -> "TBL0", "\"Tbl0\"" -> "Tbl0".
+ */
+ public static String parse(String str) {
+ if (str == null || str.isEmpty()) {
+ return str;
+ }
+
+ if (str.startsWith("\"") && str.endsWith("\"")) {
+ if (str.length() == 1) {
+ throw new IgniteInternalException("Invalid identifier: single quota");
+ }
+
+ return str.substring(1, str.length() - 1);
+ } else {
+ return str.toUpperCase();
+ }
+ }
+
+ /**
+ * Parse canonical table [schemaName].[tableName], unquote identifiers and normalize case, e.g. "public.tbl0" -> "PUBLIC.TBL0",
+ * "PUBLIC.\"Tbl0\"" -> "PUBLIC.Tbl0", "\"MySchema\".\"Tbl0\"" -> "MySchema.Tbl0", etc.
+ *
+ * @param str String to parse canonical name.
+ * @return Unquote identifiers and normalize case.
+ */
+ public static String parseCanonicalName(String str) {
+ if (str == null || str.isEmpty()) {
+ throw new IgniteInternalException("Invalid identifier: empty string");
+ }
+
+ StringBuilder name = new StringBuilder();
+ boolean quoted = false;
+ int idBegin = 0;
+ int idEnd = 0;
+
+ for (int i = 0; i < str.length(); ++i) {
+ switch (str.charAt(i)) {
+ case '\"':
+ if (quoted) {
+ idEnd = i;
+ } else {
+ idBegin = i + 1;
+ quoted = true;
+ }
+
+ break;
+
+ case '.':
+ if (!quoted) {
+ idEnd = i;
+ }
+
+ String id = str.substring(idBegin, idEnd);
+
+ name.append(quoted ? id : id.toUpperCase()).append('.');
+
+ quoted = false;
+ idBegin = i + 1;
+
+ break;
+
+ default:
+ break;
+ }
+ }
+
+ if (!quoted) {
+ idEnd = str.length();
+ }
+
+ // append last name
+ String id = str.substring(idBegin, idEnd);
+
+ name.append(quoted ? id : id.toUpperCase());
+
+ return name.toString();
+ }
+
+ /**
+ * Quote all database's objects names at the collection.
+ *
+ * @param names Collection of objects names.
+ * @return List of the quoted objects names.
+ */
+ public static List<String> quoteNames(List<String> names) {
+ if (names == null) {
+ return null;
+ }
+
+ return names.stream().map(IgniteObjectName::quote).collect(Collectors.toList());
+ }
+
+ /**
+ * Quote database's object name, e.g. "myColumn" -> "\"myColumn\""
+ *
+ * @param str Object name.
+ * @return Quoted object name.
+ */
+ public static String quote(String str) {
+ return "\"" + str + "\"";
+ }
+}
\ No newline at end of file
diff --git a/modules/platforms/dotnet/Apache.Ignite.Tests/Table/CustomTestIgniteTuple.cs b/modules/platforms/dotnet/Apache.Ignite.Tests/Table/CustomTestIgniteTuple.cs
index 37af9f3..42ee0bf 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Tests/Table/CustomTestIgniteTuple.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Tests/Table/CustomTestIgniteTuple.cs
@@ -38,12 +38,12 @@ namespace Apache.Ignite.Tests.Table
public object? this[string name]
{
- get => name switch { "key" => Key, _ => Value };
+ get => name switch { "KEY" => Key, _ => Value };
set => throw new System.NotImplementedException();
}
- public string GetName(int ordinal) => ordinal switch { 0 => "key", _ => "val" };
+ public string GetName(int ordinal) => ordinal switch { 0 => "KEY", _ => "VAL" };
- public int GetOrdinal(string name) => name switch { "key" => 0, _ => 1 };
+ public int GetOrdinal(string name) => name switch { "KEY" => 0, _ => 1 };
}
}
diff --git a/modules/platforms/dotnet/Apache.Ignite.Tests/Table/IgniteTupleTests.cs b/modules/platforms/dotnet/Apache.Ignite.Tests/Table/IgniteTupleTests.cs
index b399aac..f4dce4d 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Tests/Table/IgniteTupleTests.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Tests/Table/IgniteTupleTests.cs
@@ -18,6 +18,7 @@
namespace Apache.Ignite.Tests.Table
{
using System;
+ using System.Collections.Generic;
using Ignite.Table;
using NUnit.Framework;
@@ -43,10 +44,14 @@ namespace Apache.Ignite.Tests.Table
Assert.AreEqual(1, tuple[0]);
Assert.AreEqual(Guid.Empty, tuple[1]);
- Assert.AreEqual("foo", tuple.GetName(0));
- Assert.AreEqual("bar", tuple.GetName(1));
+ Assert.AreEqual("FOO", tuple.GetName(0));
+ Assert.AreEqual("BAR", tuple.GetName(1));
Assert.AreEqual(0, tuple.GetOrdinal("foo"));
+ Assert.AreEqual(0, tuple.GetOrdinal("Foo"));
+ Assert.AreEqual(0, tuple.GetOrdinal("FOO"));
+ Assert.AreEqual(0, tuple.GetOrdinal("\"FOO\""));
+ Assert.AreEqual(-1, tuple.GetOrdinal("\"Foo\""));
Assert.AreEqual(1, tuple.GetOrdinal("bar"));
tuple[0] = 2;
@@ -61,6 +66,42 @@ namespace Apache.Ignite.Tests.Table
}
[Test]
+ public void TestGetNullOrEmptyNameThrowsException()
+ {
+ var tuple = new IgniteTuple { ["Foo"] = 1 };
+
+ var ex = Assert.Throws<IgniteClientException>(() => tuple.GetOrdinal(string.Empty));
+ Assert.AreEqual("Column name can not be null or empty.", ex!.Message);
+
+ ex = Assert.Throws<IgniteClientException>(() => tuple.GetOrdinal(null!));
+ Assert.AreEqual("Column name can not be null or empty.", ex!.Message);
+
+ ex = Assert.Throws<IgniteClientException>(() =>
+ {
+ var unused = tuple[string.Empty];
+ });
+ Assert.AreEqual("Column name can not be null or empty.", ex!.Message);
+
+ ex = Assert.Throws<IgniteClientException>(() =>
+ {
+ var unused = tuple[null!];
+ });
+ Assert.AreEqual("Column name can not be null or empty.", ex!.Message);
+ }
+
+ [Test]
+ public void TestGetNonExistingNameThrowsException()
+ {
+ var tuple = new IgniteTuple { ["Foo"] = 1 };
+
+ var ex = Assert.Throws<KeyNotFoundException>(() =>
+ {
+ var unused = tuple["bar"];
+ });
+ Assert.AreEqual("The given key 'BAR' was not present in the dictionary.", ex!.Message);
+ }
+
+ [Test]
public void TestToStringEmpty()
{
Assert.AreEqual("IgniteTuple []", new IgniteTuple().ToString());
@@ -70,7 +111,7 @@ namespace Apache.Ignite.Tests.Table
public void TestToStringOneField()
{
var tuple = new IgniteTuple { ["foo"] = 1 };
- Assert.AreEqual("IgniteTuple [foo=1]", tuple.ToString());
+ Assert.AreEqual("IgniteTuple [FOO=1]", tuple.ToString());
}
[Test]
@@ -82,7 +123,7 @@ namespace Apache.Ignite.Tests.Table
["b"] = "abcd"
};
- Assert.AreEqual("IgniteTuple [foo=1, b=abcd]", tuple.ToString());
+ Assert.AreEqual("IgniteTuple [FOO=1, B=abcd]", tuple.ToString());
}
[Test]
diff --git a/modules/platforms/dotnet/Apache.Ignite.Tests/Table/TableTests.cs b/modules/platforms/dotnet/Apache.Ignite.Tests/Table/TableTests.cs
index e615f55..b303c74 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Tests/Table/TableTests.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Tests/Table/TableTests.cs
@@ -73,7 +73,7 @@ namespace Apache.Ignite.Tests.Table
var ex = Assert.ThrowsAsync<IgniteClientException>(async () => await Table.UpsertAsync(null, new IgniteTuple()));
Assert.AreEqual(
- "Missed key column: key",
+ "Missed key column: KEY",
ex!.Message);
}
diff --git a/modules/platforms/dotnet/Apache.Ignite.Tests/Table/TablesTests.cs b/modules/platforms/dotnet/Apache.Ignite.Tests/Table/TablesTests.cs
index c1d0896..1c93a65 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Tests/Table/TablesTests.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Tests/Table/TablesTests.cs
@@ -33,7 +33,7 @@ namespace Apache.Ignite.Tests.Table
var tables = await Client.Tables.GetTablesAsync();
Assert.AreEqual(1, tables.Count);
- Assert.AreEqual("PUB.tbl1", tables[0].Name);
+ Assert.AreEqual("PUB.TBL1", tables[0].Name);
}
[Test]
diff --git a/modules/platforms/dotnet/Apache.Ignite/Table/IgniteTuple.cs b/modules/platforms/dotnet/Apache.Ignite/Table/IgniteTuple.cs
index ed893fd..2a1090a 100644
--- a/modules/platforms/dotnet/Apache.Ignite/Table/IgniteTuple.cs
+++ b/modules/platforms/dotnet/Apache.Ignite/Table/IgniteTuple.cs
@@ -55,9 +55,11 @@ namespace Apache.Ignite.Table
/// <inheritdoc/>
public object? this[string name]
{
- get => _pairs[_indexes[name]].Value;
+ get => _pairs[_indexes[ParseName(name)]].Value;
set
{
+ name = ParseName(name);
+
var pair = (name, value);
if (_indexes.TryGetValue(name, out var index))
@@ -77,7 +79,7 @@ namespace Apache.Ignite.Table
public string GetName(int ordinal) => _pairs[ordinal].Key;
/// <inheritdoc/>
- public int GetOrdinal(string name) => _indexes.TryGetValue(name, out var index) ? index : -1;
+ public int GetOrdinal(string name) => _indexes.TryGetValue(ParseName(name), out var index) ? index : -1;
/// <inheritdoc />
public override string ToString()
@@ -118,5 +120,20 @@ namespace Apache.Ignite.Table
{
return IIgniteTuple.GetHashCode(this);
}
+
+ private static string ParseName(string str)
+ {
+ if (string.IsNullOrEmpty(str))
+ {
+ throw new IgniteClientException("Column name can not be null or empty.");
+ }
+
+ if (str.Length > 2 && str.StartsWith('"') && str.EndsWith('"'))
+ {
+ return str.Substring(1, str.Length - 2);
+ }
+
+ return str.ToUpperInvariant();
+ }
}
}
diff --git a/modules/runner/src/integrationTest/java/org/apache/ignite/internal/runner/app/AbstractSchemaChangeTest.java b/modules/runner/src/integrationTest/java/org/apache/ignite/internal/runner/app/AbstractSchemaChangeTest.java
index 40e18af..e061ad2 100644
--- a/modules/runner/src/integrationTest/java/org/apache/ignite/internal/runner/app/AbstractSchemaChangeTest.java
+++ b/modules/runner/src/integrationTest/java/org/apache/ignite/internal/runner/app/AbstractSchemaChangeTest.java
@@ -35,6 +35,7 @@ import org.apache.ignite.configuration.schemas.table.ColumnChange;
import org.apache.ignite.internal.ItUtils;
import org.apache.ignite.internal.testframework.WorkDirectory;
import org.apache.ignite.internal.testframework.WorkDirectoryExtension;
+import org.apache.ignite.internal.util.IgniteObjectName;
import org.apache.ignite.internal.util.IgniteUtils;
import org.apache.ignite.lang.IgniteException;
import org.apache.ignite.schema.SchemaBuilders;
@@ -225,7 +226,7 @@ abstract class AbstractSchemaChangeTest {
*/
protected static void dropColumn(List<Ignite> nodes, String colName) {
nodes.get(0).tables()
- .alterTable(TABLE, chng -> chng.changeColumns(cols -> cols.delete(colName)));
+ .alterTable(TABLE, chng -> chng.changeColumns(cols -> cols.delete(IgniteObjectName.parse(colName))));
}
/**
@@ -239,8 +240,11 @@ abstract class AbstractSchemaChangeTest {
nodes.get(0).tables().alterTable(TABLE,
tblChanger -> tblChanger.changeColumns(
colListChanger -> colListChanger
- .rename(oldName, newName)
- .update(newName, colChanger -> colChanger.changeName(newName))
+ .rename(IgniteObjectName.parse(oldName), IgniteObjectName.parse(newName))
+ .update(
+ IgniteObjectName.parse(newName),
+ colChanger -> colChanger.changeName(IgniteObjectName.parse(newName))
+ )
)
);
}
@@ -256,7 +260,10 @@ abstract class AbstractSchemaChangeTest {
nodes.get(0).tables().alterTable(TABLE,
tblChanger -> tblChanger.changeColumns(
colListChanger -> colListChanger
- .update(colName, colChanger -> colChanger.changeDefaultValue(defSup.get().toString()))
+ .update(
+ IgniteObjectName.parse(colName),
+ colChanger -> colChanger.changeDefaultValue(defSup.get().toString())
+ )
)
);
}
@@ -271,7 +278,9 @@ abstract class AbstractSchemaChangeTest {
private static void assertColumnChangeFailed(List<Ignite> grid, String colName, Consumer<ColumnChange> colChanger) {
assertThrows(IgniteException.class, () ->
grid.get(0).tables().alterTable(TABLE,
- tblChanger -> tblChanger.changeColumns(listChanger -> listChanger.update(colName, colChanger))
+ tblChanger -> tblChanger.changeColumns(
+ listChanger -> listChanger.update(IgniteObjectName.parse(colName), colChanger)
+ )
)
);
}
diff --git a/modules/runner/src/integrationTest/java/org/apache/ignite/internal/runner/app/ItTableApiContractTest.java b/modules/runner/src/integrationTest/java/org/apache/ignite/internal/runner/app/ItTableApiContractTest.java
index 28218a3..1f9be83 100644
--- a/modules/runner/src/integrationTest/java/org/apache/ignite/internal/runner/app/ItTableApiContractTest.java
+++ b/modules/runner/src/integrationTest/java/org/apache/ignite/internal/runner/app/ItTableApiContractTest.java
@@ -106,7 +106,7 @@ public class ItTableApiContractTest extends AbstractBasicIntegrationTest {
/**
* Checks a contract for asynchronous dropping table.
*
- * @throws Exception If fialed.
+ * @throws Exception If failed.
*/
@Test
public void testDropTableAsync() throws Exception {
@@ -148,7 +148,7 @@ public class ItTableApiContractTest extends AbstractBasicIntegrationTest {
ignite.tables().alterTable(TABLE_NAME,
chng -> chng.changeColumns(cols -> {
- cols.create("name", colChg -> convert(SchemaBuilders.column("name", ColumnType.string()).asNullable(true)
+ cols.create("NAME", colChg -> convert(SchemaBuilders.column("name", ColumnType.string()).asNullable(true)
.withDefaultValueExpression("default").build(), colChg));
}));
@@ -158,7 +158,7 @@ public class ItTableApiContractTest extends AbstractBasicIntegrationTest {
assertThrows(TableNotFoundException.class, () -> ignite.tables().alterTable(TABLE_NAME + "_not_exist",
chng -> chng.changeColumns(cols -> {
- cols.create("name", colChg -> convert(SchemaBuilders.column("name", ColumnType.string()).asNullable(true)
+ cols.create("NAME", colChg -> convert(SchemaBuilders.column("name", ColumnType.string()).asNullable(true)
.withDefaultValueExpression("default").build(), colChg));
})));
}
@@ -181,13 +181,13 @@ public class ItTableApiContractTest extends AbstractBasicIntegrationTest {
CompletableFuture<Void> altTblFut1 = ignite.tables().alterTableAsync(TABLE_NAME,
chng -> chng.changeColumns(cols -> {
- cols.create("name", colChg -> convert(SchemaBuilders.column("name", ColumnType.string()).asNullable(true)
+ cols.create("NAME", colChg -> convert(SchemaBuilders.column("NAME", ColumnType.string()).asNullable(true)
.withDefaultValueExpression("default").build(), colChg));
}));
CompletableFuture<Void> altTblFut2 = ignite.tables().alterTableAsync(TABLE_NAME + "_not_exist",
chng -> chng.changeColumns(cols -> {
- cols.create("name", colChg -> convert(SchemaBuilders.column("name", ColumnType.string()).asNullable(true)
+ cols.create("NAME", colChg -> convert(SchemaBuilders.column("NAME", ColumnType.string()).asNullable(true)
.withDefaultValueExpression("default").build(), colChg));
}));
diff --git a/modules/runner/src/integrationTest/java/org/apache/ignite/internal/runner/app/client/ItAbstractThinClientTest.java b/modules/runner/src/integrationTest/java/org/apache/ignite/internal/runner/app/client/ItAbstractThinClientTest.java
index bbb2123..cf2cc80 100644
--- a/modules/runner/src/integrationTest/java/org/apache/ignite/internal/runner/app/client/ItAbstractThinClientTest.java
+++ b/modules/runner/src/integrationTest/java/org/apache/ignite/internal/runner/app/client/ItAbstractThinClientTest.java
@@ -54,7 +54,7 @@ import org.junit.jupiter.api.extension.ExtendWith;
public abstract class ItAbstractThinClientTest extends IgniteAbstractTest {
protected static final String SCHEMA_NAME = "PUB";
- protected static final String TABLE_NAME = "tbl1";
+ protected static final String TABLE_NAME = "TBL1";
protected static final String COLUMN_KEY = "key";
diff --git a/modules/schema/src/main/java/org/apache/ignite/internal/schema/definition/builder/AbstractIndexBuilder.java b/modules/schema/src/main/java/org/apache/ignite/internal/schema/definition/builder/AbstractIndexBuilder.java
index 107b402..b73390d 100644
--- a/modules/schema/src/main/java/org/apache/ignite/internal/schema/definition/builder/AbstractIndexBuilder.java
+++ b/modules/schema/src/main/java/org/apache/ignite/internal/schema/definition/builder/AbstractIndexBuilder.java
@@ -19,6 +19,7 @@ package org.apache.ignite.internal.schema.definition.builder;
import java.util.Collections;
import java.util.Map;
+import org.apache.ignite.internal.util.IgniteObjectName;
import org.apache.ignite.schema.definition.builder.SchemaObjectBuilder;
/**
@@ -50,7 +51,7 @@ public abstract class AbstractIndexBuilder implements SchemaObjectBuilder {
* @param unique Unique flag.
*/
AbstractIndexBuilder(String name, boolean unique) {
- this.name = name;
+ this.name = IgniteObjectName.parse(name);
this.unique = unique;
}
diff --git a/modules/schema/src/main/java/org/apache/ignite/internal/schema/definition/builder/ColumnDefinitionBuilderImpl.java b/modules/schema/src/main/java/org/apache/ignite/internal/schema/definition/builder/ColumnDefinitionBuilderImpl.java
index 8997ae3..d932b08 100644
--- a/modules/schema/src/main/java/org/apache/ignite/internal/schema/definition/builder/ColumnDefinitionBuilderImpl.java
+++ b/modules/schema/src/main/java/org/apache/ignite/internal/schema/definition/builder/ColumnDefinitionBuilderImpl.java
@@ -19,6 +19,7 @@ package org.apache.ignite.internal.schema.definition.builder;
import java.util.Map;
import org.apache.ignite.internal.schema.definition.ColumnDefinitionImpl;
+import org.apache.ignite.internal.util.IgniteObjectName;
import org.apache.ignite.schema.definition.ColumnDefinition;
import org.apache.ignite.schema.definition.ColumnType;
import org.apache.ignite.schema.definition.builder.ColumnDefinitionBuilder;
@@ -46,7 +47,7 @@ public class ColumnDefinitionBuilderImpl implements ColumnDefinitionBuilder {
* @param colType Column type.
*/
public ColumnDefinitionBuilderImpl(String colName, ColumnType colType) {
- this.colName = colName;
+ this.colName = IgniteObjectName.parse(colName);
this.colType = colType;
}
diff --git a/modules/schema/src/main/java/org/apache/ignite/internal/schema/definition/builder/HashIndexDefinitionBuilderImpl.java b/modules/schema/src/main/java/org/apache/ignite/internal/schema/definition/builder/HashIndexDefinitionBuilderImpl.java
index 6d888f1..1322542 100644
--- a/modules/schema/src/main/java/org/apache/ignite/internal/schema/definition/builder/HashIndexDefinitionBuilderImpl.java
+++ b/modules/schema/src/main/java/org/apache/ignite/internal/schema/definition/builder/HashIndexDefinitionBuilderImpl.java
@@ -17,11 +17,12 @@
package org.apache.ignite.internal.schema.definition.builder;
-import static java.util.Arrays.asList;
-
+import java.util.Arrays;
import java.util.List;
import java.util.Map;
+import java.util.stream.Collectors;
import org.apache.ignite.internal.schema.definition.index.HashIndexDefinitionImpl;
+import org.apache.ignite.internal.util.IgniteObjectName;
import org.apache.ignite.schema.definition.builder.HashIndexDefinitionBuilder;
import org.apache.ignite.schema.definition.index.HashIndexDefinition;
@@ -44,7 +45,7 @@ public class HashIndexDefinitionBuilderImpl extends AbstractIndexBuilder impleme
/** {@inheritDoc} */
@Override
public HashIndexDefinitionBuilder withColumns(List<String> columns) {
- this.columns = columns;
+ this.columns = columns.stream().map(IgniteObjectName::parse).collect(Collectors.toList());
return this;
}
@@ -52,7 +53,7 @@ public class HashIndexDefinitionBuilderImpl extends AbstractIndexBuilder impleme
/** {@inheritDoc} */
@Override
public HashIndexDefinitionBuilder withColumns(String... columns) {
- this.columns = asList(columns);
+ this.columns = Arrays.stream(columns).map(IgniteObjectName::parse).collect(Collectors.toList());
return this;
}
diff --git a/modules/schema/src/main/java/org/apache/ignite/internal/schema/definition/builder/PrimaryKeyDefinitionBuilderImpl.java b/modules/schema/src/main/java/org/apache/ignite/internal/schema/definition/builder/PrimaryKeyDefinitionBuilderImpl.java
index 4c46538..2c1c58b 100644
--- a/modules/schema/src/main/java/org/apache/ignite/internal/schema/definition/builder/PrimaryKeyDefinitionBuilderImpl.java
+++ b/modules/schema/src/main/java/org/apache/ignite/internal/schema/definition/builder/PrimaryKeyDefinitionBuilderImpl.java
@@ -17,14 +17,15 @@
package org.apache.ignite.internal.schema.definition.builder;
-import static java.util.Arrays.asList;
-
+import java.util.Arrays;
import java.util.List;
import java.util.Map;
import java.util.Set;
+import java.util.stream.Collectors;
import org.apache.ignite.internal.schema.definition.index.PrimaryKeyDefinitionImpl;
import org.apache.ignite.internal.tostring.IgniteToStringInclude;
import org.apache.ignite.internal.util.CollectionUtils;
+import org.apache.ignite.internal.util.IgniteObjectName;
import org.apache.ignite.schema.definition.PrimaryKeyDefinition;
import org.apache.ignite.schema.definition.builder.PrimaryKeyDefinitionBuilder;
import org.apache.ignite.schema.definition.builder.SchemaObjectBuilder;
@@ -47,7 +48,7 @@ public class PrimaryKeyDefinitionBuilderImpl implements SchemaObjectBuilder, Pri
/** {@inheritDoc} */
@Override
public PrimaryKeyDefinitionBuilderImpl withColumns(String... columns) {
- this.columns = asList(columns);
+ this.columns = Arrays.stream(columns).map(IgniteObjectName::parse).collect(Collectors.toList());
return this;
}
@@ -55,7 +56,7 @@ public class PrimaryKeyDefinitionBuilderImpl implements SchemaObjectBuilder, Pri
/** {@inheritDoc} */
@Override
public PrimaryKeyDefinitionBuilderImpl withColumns(List<String> columns) {
- this.columns = columns;
+ this.columns = columns.stream().map(IgniteObjectName::parse).collect(Collectors.toList());
return this;
}
@@ -63,7 +64,9 @@ public class PrimaryKeyDefinitionBuilderImpl implements SchemaObjectBuilder, Pri
/** {@inheritDoc} */
@Override
public PrimaryKeyDefinitionBuilderImpl withAffinityColumns(String... affinityColumns) {
- this.affinityColumns = asList(affinityColumns);
+ this.affinityColumns = affinityColumns == null
+ ? null
+ : Arrays.stream(affinityColumns).map(IgniteObjectName::parse).collect(Collectors.toList());
return this;
}
@@ -71,7 +74,9 @@ public class PrimaryKeyDefinitionBuilderImpl implements SchemaObjectBuilder, Pri
/** {@inheritDoc} */
@Override
public PrimaryKeyDefinitionBuilderImpl withAffinityColumns(List<String> affinityColumns) {
- this.affinityColumns = affinityColumns;
+ this.affinityColumns = affinityColumns == null
+ ? null
+ : affinityColumns.stream().map(IgniteObjectName::parse).collect(Collectors.toList());
return this;
}
diff --git a/modules/schema/src/main/java/org/apache/ignite/internal/schema/definition/builder/SortedIndexDefinitionBuilderImpl.java b/modules/schema/src/main/java/org/apache/ignite/internal/schema/definition/builder/SortedIndexDefinitionBuilderImpl.java
index 2fd506d..84500b5 100644
--- a/modules/schema/src/main/java/org/apache/ignite/internal/schema/definition/builder/SortedIndexDefinitionBuilderImpl.java
+++ b/modules/schema/src/main/java/org/apache/ignite/internal/schema/definition/builder/SortedIndexDefinitionBuilderImpl.java
@@ -23,6 +23,7 @@ import java.util.Map;
import java.util.stream.Collectors;
import org.apache.ignite.internal.schema.definition.index.SortedIndexColumnDefinitionImpl;
import org.apache.ignite.internal.schema.definition.index.SortedIndexDefinitionImpl;
+import org.apache.ignite.internal.util.IgniteObjectName;
import org.apache.ignite.schema.definition.builder.SortedIndexDefinitionBuilder;
import org.apache.ignite.schema.definition.index.SortOrder;
import org.apache.ignite.schema.definition.index.SortedIndexColumnDefinition;
@@ -134,7 +135,7 @@ public class SortedIndexDefinitionBuilderImpl extends AbstractIndexBuilder imple
/** {@inheritDoc} */
@Override
public SortedIndexColumnBuilderImpl withName(String name) {
- this.name = name;
+ this.name = IgniteObjectName.parse(name);
return this;
}
diff --git a/modules/schema/src/main/java/org/apache/ignite/internal/schema/definition/builder/TableDefinitionBuilderImpl.java b/modules/schema/src/main/java/org/apache/ignite/internal/schema/definition/builder/TableDefinitionBuilderImpl.java
index 47827ea..9f69d40 100644
--- a/modules/schema/src/main/java/org/apache/ignite/internal/schema/definition/builder/TableDefinitionBuilderImpl.java
+++ b/modules/schema/src/main/java/org/apache/ignite/internal/schema/definition/builder/TableDefinitionBuilderImpl.java
@@ -27,6 +27,7 @@ import java.util.Map;
import java.util.Set;
import java.util.stream.Collectors;
import org.apache.ignite.internal.schema.definition.TableDefinitionImpl;
+import org.apache.ignite.internal.util.IgniteObjectName;
import org.apache.ignite.schema.SchemaBuilders;
import org.apache.ignite.schema.definition.ColumnDefinition;
import org.apache.ignite.schema.definition.PrimaryKeyDefinition;
@@ -62,8 +63,8 @@ public class TableDefinitionBuilderImpl implements TableDefinitionBuilder {
* @param tableName Table name.
*/
public TableDefinitionBuilderImpl(String schemaName, String tableName) {
- this.schemaName = schemaName;
- this.tableName = tableName;
+ this.schemaName = IgniteObjectName.parse(schemaName);
+ this.tableName = IgniteObjectName.parse(tableName);
}
/** {@inheritDoc} */
@@ -97,7 +98,7 @@ public class TableDefinitionBuilderImpl implements TableDefinitionBuilder {
/** {@inheritDoc} */
@Override
public TableDefinitionBuilder withPrimaryKey(String colName) {
- primaryKeyDefinition = SchemaBuilders.primaryKey().withColumns(colName).build();
+ primaryKeyDefinition = SchemaBuilders.primaryKey().withColumns(IgniteObjectName.parse(colName)).build();
return this;
}
diff --git a/modules/schema/src/main/java/org/apache/ignite/internal/schema/marshaller/asm/AsmMarshallerGenerator.java b/modules/schema/src/main/java/org/apache/ignite/internal/schema/marshaller/asm/AsmMarshallerGenerator.java
index f0f9dfe..23ea7ab 100644
--- a/modules/schema/src/main/java/org/apache/ignite/internal/schema/marshaller/asm/AsmMarshallerGenerator.java
+++ b/modules/schema/src/main/java/org/apache/ignite/internal/schema/marshaller/asm/AsmMarshallerGenerator.java
@@ -210,7 +210,7 @@ public class AsmMarshallerGenerator implements MarshallerFactory {
if (mode == BinaryMode.POJO) {
return new ObjectMarshallerCodeGenerator(columns, cls, firstColIdx);
} else {
- return new IdentityMarshallerCodeGenerator(ColumnAccessCodeGenerator.createAccessor(mode, firstColIdx));
+ return new IdentityMarshallerCodeGenerator(ColumnAccessCodeGenerator.createAccessor(mode, null, firstColIdx));
}
}
diff --git a/modules/schema/src/main/java/org/apache/ignite/internal/schema/marshaller/asm/ColumnAccessCodeGenerator.java b/modules/schema/src/main/java/org/apache/ignite/internal/schema/marshaller/asm/ColumnAccessCodeGenerator.java
index 99d6ef6..0a43090 100644
--- a/modules/schema/src/main/java/org/apache/ignite/internal/schema/marshaller/asm/ColumnAccessCodeGenerator.java
+++ b/modules/schema/src/main/java/org/apache/ignite/internal/schema/marshaller/asm/ColumnAccessCodeGenerator.java
@@ -39,52 +39,52 @@ public class ColumnAccessCodeGenerator {
* @param colIdx Column index in the schema.
* @return Row column access code generator.
*/
- public static ColumnAccessCodeGenerator createAccessor(BinaryMode mode, int colIdx) {
+ public static ColumnAccessCodeGenerator createAccessor(BinaryMode mode, String fieldName, int colIdx) {
switch (mode) {
case P_BYTE:
- return new ColumnAccessCodeGenerator("byteValue", "appendByte", byte.class, colIdx);
+ return new ColumnAccessCodeGenerator("byteValue", "appendByte", byte.class, fieldName, colIdx);
case P_SHORT:
- return new ColumnAccessCodeGenerator("shortValue", "appendShort", short.class, colIdx);
+ return new ColumnAccessCodeGenerator("shortValue", "appendShort", short.class, fieldName, colIdx);
case P_INT:
- return new ColumnAccessCodeGenerator("intValue", "appendInt", int.class, colIdx);
+ return new ColumnAccessCodeGenerator("intValue", "appendInt", int.class, fieldName, colIdx);
case P_LONG:
- return new ColumnAccessCodeGenerator("longValue", "appendLong", long.class, colIdx);
+ return new ColumnAccessCodeGenerator("longValue", "appendLong", long.class, fieldName, colIdx);
case P_FLOAT:
- return new ColumnAccessCodeGenerator("floatValue", "appendFloat", float.class, colIdx);
+ return new ColumnAccessCodeGenerator("floatValue", "appendFloat", float.class, fieldName, colIdx);
case P_DOUBLE:
- return new ColumnAccessCodeGenerator("doubleValue", "appendDouble", double.class, colIdx);
+ return new ColumnAccessCodeGenerator("doubleValue", "appendDouble", double.class, fieldName, colIdx);
case BYTE:
- return new ColumnAccessCodeGenerator("byteValueBoxed", "appendByte", Byte.class, byte.class, colIdx);
+ return new ColumnAccessCodeGenerator("byteValueBoxed", "appendByte", Byte.class, byte.class, fieldName, colIdx);
case SHORT:
- return new ColumnAccessCodeGenerator("shortValueBoxed", "appendShort", Short.class, short.class, colIdx);
+ return new ColumnAccessCodeGenerator("shortValueBoxed", "appendShort", Short.class, short.class, fieldName, colIdx);
case INT:
- return new ColumnAccessCodeGenerator("intValueBoxed", "appendInt", Integer.class, int.class, colIdx);
+ return new ColumnAccessCodeGenerator("intValueBoxed", "appendInt", Integer.class, int.class, fieldName, colIdx);
case LONG:
- return new ColumnAccessCodeGenerator("longValueBoxed", "appendLong", Long.class, long.class, colIdx);
+ return new ColumnAccessCodeGenerator("longValueBoxed", "appendLong", Long.class, long.class, fieldName, colIdx);
case FLOAT:
- return new ColumnAccessCodeGenerator("floatValueBoxed", "appendFloat", Float.class, float.class, colIdx);
+ return new ColumnAccessCodeGenerator("floatValueBoxed", "appendFloat", Float.class, float.class, fieldName, colIdx);
case DOUBLE:
- return new ColumnAccessCodeGenerator("doubleValueBoxed", "appendDouble", Double.class, double.class, colIdx);
+ return new ColumnAccessCodeGenerator("doubleValueBoxed", "appendDouble", Double.class, double.class, fieldName, colIdx);
case STRING:
- return new ColumnAccessCodeGenerator("stringValue", "appendString", String.class, colIdx);
+ return new ColumnAccessCodeGenerator("stringValue", "appendString", String.class, fieldName, colIdx);
case UUID:
- return new ColumnAccessCodeGenerator("uuidValue", "appendUuid", UUID.class, colIdx);
+ return new ColumnAccessCodeGenerator("uuidValue", "appendUuid", UUID.class, fieldName, colIdx);
case BYTE_ARR:
- return new ColumnAccessCodeGenerator("bytesValue", "appendBytes", byte[].class, colIdx);
+ return new ColumnAccessCodeGenerator("bytesValue", "appendBytes", byte[].class, fieldName, colIdx);
case BITSET:
- return new ColumnAccessCodeGenerator("bitmaskValue", "appendBitmask", BitSet.class, colIdx);
+ return new ColumnAccessCodeGenerator("bitmaskValue", "appendBitmask", BitSet.class, fieldName, colIdx);
case NUMBER:
- return new ColumnAccessCodeGenerator("numberValue", "appendNumber", BigInteger.class, colIdx);
+ return new ColumnAccessCodeGenerator("numberValue", "appendNumber", BigInteger.class, fieldName, colIdx);
case DECIMAL:
- return new ColumnAccessCodeGenerator("decimalValue", "appendDecimal", BigDecimal.class, colIdx);
+ return new ColumnAccessCodeGenerator("decimalValue", "appendDecimal", BigDecimal.class, fieldName, colIdx);
case DATE:
- return new ColumnAccessCodeGenerator("dateValue", "appendDate", LocalDate.class, colIdx);
+ return new ColumnAccessCodeGenerator("dateValue", "appendDate", LocalDate.class, fieldName, colIdx);
case TIME:
- return new ColumnAccessCodeGenerator("timeValue", "appendTime", LocalTime.class, colIdx);
+ return new ColumnAccessCodeGenerator("timeValue", "appendTime", LocalTime.class, fieldName, colIdx);
case DATETIME:
- return new ColumnAccessCodeGenerator("dateTimeValue", "appendDateTime", LocalDateTime.class, colIdx);
+ return new ColumnAccessCodeGenerator("dateTimeValue", "appendDateTime", LocalDateTime.class, fieldName, colIdx);
case TIMESTAMP:
- return new ColumnAccessCodeGenerator("timestampValue", "appendTimestamp", Instant.class, colIdx);
+ return new ColumnAccessCodeGenerator("timestampValue", "appendTimestamp", Instant.class, fieldName, colIdx);
default:
throw new IgniteInternalException("Unsupported binary mode: " + mode);
}
@@ -105,6 +105,9 @@ public class ColumnAccessCodeGenerator {
/** Column index in the schema. */
private final int colIdx;
+ /** Field name. */
+ private final String filedName;
+
/**
* Constructor.
*
@@ -113,8 +116,8 @@ public class ColumnAccessCodeGenerator {
* @param mappedType Mapped value type.
* @param colIdx Column index in the schema.
*/
- ColumnAccessCodeGenerator(String readMethodName, String writeMethodName, Class<?> mappedType, int colIdx) {
- this(readMethodName, writeMethodName, mappedType, mappedType, colIdx);
+ ColumnAccessCodeGenerator(String readMethodName, String writeMethodName, Class<?> mappedType, String fieldName, int colIdx) {
+ this(readMethodName, writeMethodName, mappedType, mappedType, fieldName, colIdx);
}
/**
@@ -127,12 +130,13 @@ public class ColumnAccessCodeGenerator {
* @param colIdx Column index in the schema.
*/
ColumnAccessCodeGenerator(String readMethodName, String writeMethodName, Class<?> mappedType,
- Class<?> writeArgType, int colIdx) {
+ Class<?> writeArgType, String fieldName, int colIdx) {
this.readMethodName = readMethodName;
this.writeMethodName = writeMethodName;
this.colIdx = colIdx;
this.mappedType = mappedType;
this.writeArgType = writeArgType;
+ this.filedName = fieldName;
}
/**
@@ -169,4 +173,11 @@ public class ColumnAccessCodeGenerator {
public Class<?> mappedType() {
return mappedType;
}
+
+ /**
+ * Gets field name.
+ */
+ public String fieldName() {
+ return filedName;
+ }
}
diff --git a/modules/schema/src/main/java/org/apache/ignite/internal/schema/marshaller/asm/ObjectMarshallerCodeGenerator.java b/modules/schema/src/main/java/org/apache/ignite/internal/schema/marshaller/asm/ObjectMarshallerCodeGenerator.java
index 63b356f..1e00937 100644
--- a/modules/schema/src/main/java/org/apache/ignite/internal/schema/marshaller/asm/ObjectMarshallerCodeGenerator.java
+++ b/modules/schema/src/main/java/org/apache/ignite/internal/schema/marshaller/asm/ObjectMarshallerCodeGenerator.java
@@ -31,8 +31,12 @@ import com.facebook.presto.bytecode.expression.BytecodeExpressions;
import java.lang.invoke.MethodHandles;
import java.lang.invoke.VarHandle;
import java.lang.reflect.Field;
+import java.util.Arrays;
import java.util.Collections;
import java.util.EnumSet;
+import java.util.Map;
+import java.util.function.Function;
+import java.util.stream.Collectors;
import org.apache.ignite.internal.schema.Columns;
import org.apache.ignite.internal.schema.marshaller.MarshallerUtil;
import org.apache.ignite.internal.schema.row.RowAssembler;
@@ -60,14 +64,18 @@ class ObjectMarshallerCodeGenerator implements MarshallerCodeGenerator {
this.targetClass = targetClass;
columnAccessors = new ColumnAccessCodeGenerator[columns.length()];
- try {
- for (int i = 0; i < columns.length(); i++) {
- final Field field = targetClass.getDeclaredField(columns.column(i).name());
+ Map<String, Field> flds = Arrays.stream(targetClass.getDeclaredFields())
+ .collect(Collectors.toMap(f -> f.getName().toUpperCase(), Function.identity()));
- columnAccessors[i] = ColumnAccessCodeGenerator.createAccessor(MarshallerUtil.mode(field.getType()), i + firstColIdx);
+ for (int i = 0; i < columns.length(); i++) {
+ final Field field = flds.get(columns.column(i).name());
+
+ if (field == null) {
+ throw new IgniteInternalException("Field not found for column [col=" + columns.column(i) + ']');
}
- } catch (NoSuchFieldException ex) {
- throw new IgniteInternalException(ex);
+
+ columnAccessors[i] = ColumnAccessCodeGenerator.createAccessor(MarshallerUtil.mode(field.getType()), field.getName(),
+ i + firstColIdx);
}
}
@@ -171,7 +179,7 @@ class ObjectMarshallerCodeGenerator implements MarshallerCodeGenerator {
"findVarHandle",
VarHandle.class,
BytecodeExpressions.getStatic(targetClassField),
- BytecodeExpressions.constantString(columns.column(i).name()),
+ BytecodeExpressions.constantString(columnAccessors[i].fieldName()),
BytecodeExpressions.constantClass(columnAccessors[i].mappedType())
))
);
diff --git a/modules/schema/src/test/java/org/apache/ignite/internal/schema/builder/HashIndexDefinitionBuilderTest.java b/modules/schema/src/test/java/org/apache/ignite/internal/schema/builder/HashIndexDefinitionBuilderTest.java
index bcaca29..af1575a 100644
--- a/modules/schema/src/test/java/org/apache/ignite/internal/schema/builder/HashIndexDefinitionBuilderTest.java
+++ b/modules/schema/src/test/java/org/apache/ignite/internal/schema/builder/HashIndexDefinitionBuilderTest.java
@@ -40,7 +40,7 @@ public class HashIndexDefinitionBuilderTest {
.withHints(Collections.singletonMap("param", "value"));
HashIndexDefinition idx = builder.build();
- assertEquals("testHI", idx.name());
+ assertEquals("TESTHI", idx.name());
assertEquals(3, idx.columns().size());
}
diff --git a/modules/schema/src/test/java/org/apache/ignite/internal/schema/configuration/SchemaConfigurationConverterTest.java b/modules/schema/src/test/java/org/apache/ignite/internal/schema/configuration/SchemaConfigurationConverterTest.java
index 2eb9d2f..f8c9964 100644
--- a/modules/schema/src/test/java/org/apache/ignite/internal/schema/configuration/SchemaConfigurationConverterTest.java
+++ b/modules/schema/src/test/java/org/apache/ignite/internal/schema/configuration/SchemaConfigurationConverterTest.java
@@ -174,7 +174,7 @@ public class SchemaConfigurationConverterTest {
SortedIndexDefinition idx2 = (SortedIndexDefinition) getIdx(idx.name(), tbl.indices());
assertNotNull(idx2);
- assertEquals("pk_sorted", idx2.name());
+ assertEquals("PK_SORTED", idx2.name());
assertEquals("SORTED", idx2.type());
assertEquals(idx.columns().stream().map(IndexColumnDefinition::name).collect(Collectors.toList()),
idx2.columns().stream().map(IndexColumnDefinition::name).collect(Collectors.toList()));
diff --git a/modules/schema/src/test/java/org/apache/ignite/internal/schema/marshaller/KvMarshallerTest.java b/modules/schema/src/test/java/org/apache/ignite/internal/schema/marshaller/KvMarshallerTest.java
index 0c76c40..51e67f8 100644
--- a/modules/schema/src/test/java/org/apache/ignite/internal/schema/marshaller/KvMarshallerTest.java
+++ b/modules/schema/src/test/java/org/apache/ignite/internal/schema/marshaller/KvMarshallerTest.java
@@ -173,12 +173,12 @@ public class KvMarshallerTest {
Assumptions.assumeFalse(factory instanceof AsmMarshallerGenerator, "Generated marshaller doesn't support truncated values, yet.");
Column[] cols = new Column[]{
- new Column("primitiveIntCol", INT32, false),
- new Column("primitiveLongCol", INT64, false),
- new Column("primitiveFloatCol", FLOAT, false),
- new Column("primitiveDoubleCol", DOUBLE, false),
- new Column("stringCol", STRING, false),
- new Column("uuidCol", UUID, false),
+ new Column("primitiveIntCol".toUpperCase(), INT32, false),
+ new Column("primitiveLongCol".toUpperCase(), INT64, false),
+ new Column("primitiveFloatCol".toUpperCase(), FLOAT, false),
+ new Column("primitiveDoubleCol".toUpperCase(), DOUBLE, false),
+ new Column("stringCol".toUpperCase(), STRING, false),
+ new Column("uuidCol".toUpperCase(), UUID, false),
};
SchemaDescriptor schema = new SchemaDescriptor(1, cols, columnsAllTypes());
@@ -204,9 +204,9 @@ public class KvMarshallerTest {
@MethodSource("marshallerFactoryProvider")
public void wideType(MarshallerFactory factory) throws MarshallerException {
Column[] cols = new Column[]{
- new Column("primitiveLongCol", INT64, false),
- new Column("primitiveDoubleCol", DOUBLE, false),
- new Column("stringCol", STRING, true),
+ new Column("primitiveLongCol".toUpperCase(), INT64, false),
+ new Column("primitiveDoubleCol".toUpperCase(), DOUBLE, false),
+ new Column("stringCol".toUpperCase(), STRING, true),
};
SchemaDescriptor schema = new SchemaDescriptor(1, cols, cols);
@@ -251,11 +251,11 @@ public class KvMarshallerTest {
Assumptions.assumeFalse(factory instanceof AsmMarshallerGenerator, "Generated marshaller doesn't support column mapping, yet.");
SchemaDescriptor schema = new SchemaDescriptor(1,
- new Column[]{new Column("key", INT64, false)},
+ new Column[]{new Column("key".toUpperCase(), INT64, false)},
new Column[]{
- new Column("col1", INT64, false),
- new Column("col2", INT64, true),
- new Column("col3", STRING, false)
+ new Column("col1".toUpperCase(), INT64, false),
+ new Column("col2".toUpperCase(), INT64, true),
+ new Column("col3".toUpperCase(), STRING, false)
});
Mapper<TestKeyObject> keyMapper = Mapper.builder(TestKeyObject.class)
@@ -290,8 +290,8 @@ public class KvMarshallerTest {
@MethodSource("marshallerFactoryProvider")
public void classWithWrongFieldType(MarshallerFactory factory) {
Column[] cols = new Column[]{
- new Column("bitmaskCol", NativeTypes.bitmaskOf(42), true),
- new Column("shortCol", UUID, true)
+ new Column("bitmaskCol".toUpperCase(), NativeTypes.bitmaskOf(42), true),
+ new Column("shortCol".toUpperCase(), UUID, true)
};
SchemaDescriptor schema = new SchemaDescriptor(1, cols, cols);
@@ -316,8 +316,8 @@ public class KvMarshallerTest {
@MethodSource("marshallerFactoryProvider")
public void classWithoutKeyField(MarshallerFactory factory) {
Column[] keyCols = new Column[]{
- new Column("id", INT64, false),
- new Column("id2", INT64, false),
+ new Column("id".toUpperCase(), INT64, false),
+ new Column("id2".toUpperCase(), INT64, false),
};
Column[] valCols = new Column[]{
@@ -334,8 +334,8 @@ public class KvMarshallerTest {
@MethodSource("marshallerFactoryProvider")
public void classWithIncorrectBitmaskSize(MarshallerFactory factory) {
Column[] cols = new Column[]{
- new Column("primitiveLongCol", INT64, false),
- new Column("bitmaskCol", NativeTypes.bitmaskOf(9), true),
+ new Column("primitiveLongCol".toUpperCase(), INT64, false),
+ new Column("bitmaskCol".toUpperCase(), NativeTypes.bitmaskOf(9), true),
};
SchemaDescriptor schema = new SchemaDescriptor(1, cols, cols);
@@ -357,8 +357,8 @@ public class KvMarshallerTest {
@MethodSource("marshallerFactoryProvider")
public void classWithPrivateConstructor(MarshallerFactory factory) throws MarshallerException {
Column[] cols = new Column[]{
- new Column("primLongCol", INT64, false),
- new Column("primIntCol", INT32, false),
+ new Column("primLongCol".toUpperCase(), INT64, false),
+ new Column("primIntCol".toUpperCase(), INT32, false),
};
SchemaDescriptor schema = new SchemaDescriptor(1, cols, cols);
@@ -400,7 +400,7 @@ public class KvMarshallerTest {
@MethodSource("marshallerFactoryProvider")
public void privateClass(MarshallerFactory factory) throws MarshallerException {
Column[] cols = new Column[]{
- new Column("primLongCol", INT64, false),
+ new Column("primLongCol".toUpperCase(), INT64, false),
};
SchemaDescriptor schema = new SchemaDescriptor(1, cols, cols);
@@ -429,13 +429,13 @@ public class KvMarshallerTest {
Thread.currentThread().setContextClassLoader(new DynamicClassLoader(getClass().getClassLoader()));
Column[] keyCols = new Column[]{
- new Column("key", INT64, false)
+ new Column("key".toUpperCase(), INT64, false)
};
Column[] valCols = new Column[]{
- new Column("col0", INT64, false),
- new Column("col1", INT64, false),
- new Column("col2", INT64, false),
+ new Column("col0".toUpperCase(), INT64, false),
+ new Column("col1".toUpperCase(), INT64, false),
+ new Column("col2".toUpperCase(), INT64, false),
};
SchemaDescriptor schema = new SchemaDescriptor(1, keyCols, valCols);
@@ -475,20 +475,20 @@ public class KvMarshallerTest {
final byte[] serializedPojo = serializeObject(pojo);
final KvMarshaller<Long, TestPojo> marshaller1 = factory.create(schema,
- Mapper.of(Long.class, "key"),
- Mapper.of(TestPojo.class, "val", new SerializingConverter<>()));
+ Mapper.of(Long.class, "\"key\""),
+ Mapper.of(TestPojo.class, "\"val\"", new SerializingConverter<>()));
final KvMarshaller<Long, byte[]> marshaller2 = factory.create(schema,
- Mapper.of(Long.class, "key"),
- Mapper.of(byte[].class, "val"));
+ Mapper.of(Long.class, "\"key\""),
+ Mapper.of(byte[].class, "\"val\""));
final KvMarshaller<Long, TestPojoWrapper> marshaller3 = factory.create(schema,
- Mapper.of(Long.class, "key"),
- Mapper.builder(TestPojoWrapper.class).map("pojoField", "val", new SerializingConverter<>()).build());
+ Mapper.of(Long.class, "\"key\""),
+ Mapper.builder(TestPojoWrapper.class).map("pojoField", "\"val\"", new SerializingConverter<>()).build());
final KvMarshaller<Long, TestPojoWrapper> marshaller4 = factory.create(schema,
- Mapper.of(Long.class, "key"),
- Mapper.builder(TestPojoWrapper.class).map("rawField", "val").build());
+ Mapper.of(Long.class, "\"key\""),
+ Mapper.builder(TestPojoWrapper.class).map("rawField", "\"val\"").build());
BinaryRow row = marshaller1.marshal(1L, pojo);
BinaryRow row2 = marshaller2.marshal(1L, serializedPojo);
@@ -542,8 +542,8 @@ public class KvMarshallerTest {
SchemaDescriptor schema = new SchemaDescriptor(1, keyCols, valCols);
KvMarshaller<Object, Object> marshaller = factory.create(schema,
- Mapper.of((Class<Object>) key.getClass(), "key"),
- Mapper.of((Class<Object>) val.getClass(), "val"));
+ Mapper.of((Class<Object>) key.getClass(), "\"key\""),
+ Mapper.of((Class<Object>) val.getClass(), "\"val\""));
BinaryRow row = marshaller.marshal(key, val);
Object key1 = marshaller.unmarshalKey(new Row(schema, row));
@@ -624,33 +624,33 @@ public class KvMarshallerTest {
private Column[] columnsAllTypes() {
Column[] cols = new Column[]{
- new Column("primitiveByteCol", INT8, false, () -> (byte) 0x42),
- new Column("primitiveShortCol", INT16, false, () -> (short) 0x4242),
- new Column("primitiveIntCol", INT32, false, () -> 0x42424242),
- new Column("primitiveLongCol", INT64, false),
- new Column("primitiveFloatCol", FLOAT, false),
- new Column("primitiveDoubleCol", DOUBLE, false),
-
- new Column("byteCol", INT8, true),
- new Column("shortCol", INT16, true),
- new Column("intCol", INT32, true),
- new Column("longCol", INT64, true),
- new Column("nullLongCol", INT64, true),
- new Column("floatCol", FLOAT, true),
- new Column("doubleCol", DOUBLE, true),
-
- new Column("dateCol", DATE, true),
- new Column("timeCol", time(), true),
- new Column("dateTimeCol", datetime(), true),
- new Column("timestampCol", timestamp(), true),
-
- new Column("uuidCol", UUID, true),
- new Column("bitmaskCol", NativeTypes.bitmaskOf(42), true),
- new Column("stringCol", STRING, true),
- new Column("nullBytesCol", BYTES, true),
- new Column("bytesCol", BYTES, true),
- new Column("numberCol", NativeTypes.numberOf(12), true),
- new Column("decimalCol", NativeTypes.decimalOf(19, 3), true),
+ new Column("primitiveByteCol".toUpperCase(), INT8, false, () -> (byte) 0x42),
+ new Column("primitiveShortCol".toUpperCase(), INT16, false, () -> (short) 0x4242),
+ new Column("primitiveIntCol".toUpperCase(), INT32, false, () -> 0x42424242),
+ new Column("primitiveLongCol".toUpperCase(), INT64, false),
+ new Column("primitiveFloatCol".toUpperCase(), FLOAT, false),
+ new Column("primitiveDoubleCol".toUpperCase(), DOUBLE, false),
+
+ new Column("byteCol".toUpperCase(), INT8, true),
+ new Column("shortCol".toUpperCase(), INT16, true),
+ new Column("intCol".toUpperCase(), INT32, true),
+ new Column("longCol".toUpperCase(), INT64, true),
+ new Column("nullLongCol".toUpperCase(), INT64, true),
+ new Column("floatCol".toUpperCase(), FLOAT, true),
+ new Column("doubleCol".toUpperCase(), DOUBLE, true),
+
+ new Column("dateCol".toUpperCase(), DATE, true),
+ new Column("timeCol".toUpperCase(), time(), true),
+ new Column("dateTimeCol".toUpperCase(), datetime(), true),
+ new Column("timestampCol".toUpperCase(), timestamp(), true),
+
+ new Column("uuidCol".toUpperCase(), UUID, true),
+ new Column("bitmaskCol".toUpperCase(), NativeTypes.bitmaskOf(42), true),
+ new Column("stringCol".toUpperCase(), STRING, true),
+ new Column("nullBytesCol".toUpperCase(), BYTES, true),
+ new Column("bytesCol".toUpperCase(), BYTES, true),
+ new Column("numberCol".toUpperCase(), NativeTypes.numberOf(12), true),
+ new Column("decimalCol".toUpperCase(), NativeTypes.decimalOf(19, 3), true),
};
// Validate all types are tested.
Set<NativeTypeSpec> testedTypes = Arrays.stream(cols).map(c -> c.type().spec())
diff --git a/modules/schema/src/test/java/org/apache/ignite/internal/schema/marshaller/MapperTest.java b/modules/schema/src/test/java/org/apache/ignite/internal/schema/marshaller/MapperTest.java
index 466e588..24b841c 100644
--- a/modules/schema/src/test/java/org/apache/ignite/internal/schema/marshaller/MapperTest.java
+++ b/modules/schema/src/test/java/org/apache/ignite/internal/schema/marshaller/MapperTest.java
@@ -43,7 +43,6 @@ import org.junit.jupiter.api.Test;
* Columns mappers test.
*/
public class MapperTest {
-
@Test
public void supportedClassKinds() {
class LocalClass {
@@ -107,15 +106,17 @@ public class MapperTest {
}) {
assertNull(((OneColumnMapper<?>) Mapper.of(c)).mappedColumn());
- assertEquals("col1", ((OneColumnMapper<?>) Mapper.of(c, "col1")).mappedColumn());
+ assertEquals("COL1", ((OneColumnMapper<?>) Mapper.of(c, "col1")).mappedColumn());
assertNull(((OneColumnMapper<?>) Mapper.of(c, "col1")).converter());
}
// One-column mapping with converter.
- assertEquals("col1", ((OneColumnMapper<String>) Mapper.of(String.class, "col1", conv)).mappedColumn());
+ assertEquals("COL1", ((OneColumnMapper<String>) Mapper.of(String.class, "col1", conv)).mappedColumn());
assertNotNull(((OneColumnMapper<String>) Mapper.of(String.class, "col1", conv)).converter());
+ assertEquals("col1", ((OneColumnMapper<String>) Mapper.of(String.class, "\"col1\"", conv)).mappedColumn());
+
// Multi-column mapping
assertThrows(IllegalArgumentException.class, () -> Mapper.of(String.class, "value", "col1"));
assertThrows(IllegalArgumentException.class, () -> Mapper.of(String.class, "value", "col1", "coder", "col2"));
@@ -139,42 +140,54 @@ public class MapperTest {
{
PojoMapper<TestObject> mapper = (PojoMapper<TestObject>) Mapper.of(TestObject.class);
- assertEquals("id", mapper.fieldForColumn("id"));
- assertEquals("longCol", mapper.fieldForColumn("longCol"));
- assertEquals("stringCol", mapper.fieldForColumn("stringCol"));
- assertNull(mapper.fieldForColumn("val"));
+ assertEquals("id", mapper.fieldForColumn("ID"));
+ assertEquals("longCol", mapper.fieldForColumn("LONGCOL"));
+ assertEquals("stringCol", mapper.fieldForColumn("STRINGCOL"));
+ assertNull(mapper.fieldForColumn("VAL"));
}
{
PojoMapper<TestObject> mapper = (PojoMapper<TestObject>) Mapper.of(TestObject.class, "id", "col1");
- assertEquals("id", mapper.fieldForColumn("col1"));
- assertNull(mapper.fieldForColumn("id"));
- assertNull(mapper.fieldForColumn("longCol"));
- assertNull(mapper.fieldForColumn("stringCol"));
- assertNull(mapper.fieldForColumn("val"));
+ assertEquals("id", mapper.fieldForColumn("COL1"));
+ assertNull(mapper.fieldForColumn("ID"));
+ assertNull(mapper.fieldForColumn("LONGCOL"));
+ assertNull(mapper.fieldForColumn("STRINGCOL"));
+ assertNull(mapper.fieldForColumn("VAL"));
}
{
PojoMapper<TestObject> mapper = (PojoMapper<TestObject>) Mapper.of(TestObject.class, "id", "col1", "stringCol", "stringCol");
- assertEquals("id", mapper.fieldForColumn("col1"));
- assertEquals("stringCol", mapper.fieldForColumn("stringCol"));
- assertNull(mapper.fieldForColumn("longCol"));
- assertNull(mapper.fieldForColumn("val"));
+ assertEquals("id", mapper.fieldForColumn("COL1"));
+ assertEquals("stringCol", mapper.fieldForColumn("STRINGCOL"));
+ assertNull(mapper.fieldForColumn("LONGCOL"));
+ assertNull(mapper.fieldForColumn("VAL"));
}
{
PojoMapper<TestObject> mapper = (PojoMapper<TestObject>) Mapper.of(TestObject.class, "id", "col1");
- assertEquals("id", mapper.fieldForColumn("col1"));
- assertNull(mapper.fieldForColumn("longCol"));
- assertNull(mapper.fieldForColumn("stringCol"));
- assertNull(mapper.fieldForColumn("val"));
+ assertEquals("id", mapper.fieldForColumn("COL1"));
+ assertNull(mapper.fieldForColumn("LONGCOL"));
+ assertNull(mapper.fieldForColumn("STRINGCOL"));
+ assertNull(mapper.fieldForColumn("VAL"));
+ }
+
+ {
+ assertEquals("COL1", ((OneColumnMapper<TestObject>) Mapper.of(TestObject.class, "col1", conv)).mappedColumn());
}
{
- assertEquals("col1", ((OneColumnMapper<TestObject>) Mapper.of(TestObject.class, "col1", conv)).mappedColumn());
+ PojoMapper<TestObject> mapper = (PojoMapper<TestObject>) Mapper.of(TestObject.class,
+ "id", "\"col1\"",
+ "longCol", "\"longCol\"");
+
+ assertEquals("id", mapper.fieldForColumn("col1"));
+ assertEquals("longCol", mapper.fieldForColumn("longCol"));
+ assertNull(mapper.fieldForColumn("ID"));
+ assertNull(mapper.fieldForColumn("STRINGCOL"));
+ assertNull(mapper.fieldForColumn("VAL"));
}
}
@@ -280,9 +293,9 @@ public class MapperTest {
{
PojoMapper<TestObject> mapper = (PojoMapper<TestObject>) Mapper.builder(TestObject.class).automap().build();
- assertEquals("id", mapper.fieldForColumn("id"));
- assertEquals("longCol", mapper.fieldForColumn("longCol"));
- assertEquals("stringCol", mapper.fieldForColumn("stringCol"));
+ assertEquals("id", mapper.fieldForColumn("ID"));
+ assertEquals("longCol", mapper.fieldForColumn("LONGCOL"));
+ assertEquals("stringCol", mapper.fieldForColumn("STRINGCOL"));
assertNull(mapper.fieldForColumn("val"));
}
@@ -291,10 +304,10 @@ public class MapperTest {
PojoMapper<TestObject> mapper = (PojoMapper<TestObject>) Mapper.builder(TestObject.class)
.map("id", "col1").automap().build();
- assertEquals("id", mapper.fieldForColumn("col1"));
+ assertEquals("id", mapper.fieldForColumn("COL1"));
assertNull(mapper.fieldForColumn("id"));
- assertEquals("longCol", mapper.fieldForColumn("longCol"));
- assertEquals("stringCol", mapper.fieldForColumn("stringCol"));
+ assertEquals("longCol", mapper.fieldForColumn("LONGCOL"));
+ assertEquals("stringCol", mapper.fieldForColumn("STRINGCOL"));
assertNull(mapper.fieldForColumn("val"));
}
@@ -303,10 +316,10 @@ public class MapperTest {
PojoMapper<TestObject> mapper = (PojoMapper<TestObject>) Mapper.builder(TestObject.class)
.automap().map("id", "col1").build();
- assertEquals("id", mapper.fieldForColumn("col1"));
+ assertEquals("id", mapper.fieldForColumn("COL1"));
assertNull(mapper.fieldForColumn("id"));
- assertEquals("longCol", mapper.fieldForColumn("longCol"));
- assertEquals("stringCol", mapper.fieldForColumn("stringCol"));
+ assertEquals("longCol", mapper.fieldForColumn("LONGCOL"));
+ assertEquals("stringCol", mapper.fieldForColumn("STRINGCOL"));
assertNull(mapper.fieldForColumn("val"));
}
@@ -316,8 +329,8 @@ public class MapperTest {
.map("id", "col1").convert("col1", new TestConverter())
.build();
- assertEquals("id", mapper.fieldForColumn("col1"));
- assertNotNull(mapper.converterForColumn("col1"));
+ assertEquals("id", mapper.fieldForColumn("COL1"));
+ assertNotNull(mapper.converterForColumn("COL1"));
assertNull(mapper.fieldForColumn("id"));
assertNull(mapper.converterForColumn("id"));
@@ -329,6 +342,18 @@ public class MapperTest {
.convert("col1", new TestConverter())
.map("id", "col1").build();
+ assertEquals("id", mapper.fieldForColumn("COL1"));
+ assertNotNull(mapper.converterForColumn("COL1"));
+
+ assertNull(mapper.fieldForColumn("id"));
+ assertNull(mapper.converterForColumn("id"));
+ }
+
+ {
+ PojoMapper<TestObject> mapper = (PojoMapper<TestObject>) Mapper.builder(TestObject.class)
+ .convert("\"col1\"", new TestConverter())
+ .map("id", "\"col1\"").build();
+
assertEquals("id", mapper.fieldForColumn("col1"));
assertNotNull(mapper.converterForColumn("col1"));
@@ -341,10 +366,10 @@ public class MapperTest {
.convert("col2", new TestConverter())
.map("id", "col1", new TestConverter()).build();
- assertEquals("id", mapper.fieldForColumn("col1"));
- assertNull(mapper.fieldForColumn("col2")); // OK. Orphan converter will never used.
- assertNotNull(mapper.converterForColumn("col1"));
- assertNotNull(mapper.converterForColumn("col2"));
+ assertEquals("id", mapper.fieldForColumn("COL1"));
+ assertNull(mapper.fieldForColumn("COL2")); // OK. Orphan converter will never used.
+ assertNotNull(mapper.converterForColumn("COL1"));
+ assertNotNull(mapper.converterForColumn("COL2"));
assertNull(mapper.fieldForColumn("id"));
assertNull(mapper.converterForColumn("id"));
@@ -355,6 +380,20 @@ public class MapperTest {
.map("id", "col1", new TestConverter())
.map("stringCol", "stringCol", new TestConverter()).build();
+ assertEquals("id", mapper.fieldForColumn("COL1"));
+ assertEquals("stringCol", mapper.fieldForColumn("STRINGCOL"));
+ assertNotNull(mapper.converterForColumn("COL1"));
+ assertNotNull(mapper.converterForColumn("STRINGCOL"));
+
+ assertNull(mapper.fieldForColumn("id"));
+ assertNull(mapper.converterForColumn("id"));
+ }
+
+ {
+ PojoMapper<TestObject> mapper = (PojoMapper<TestObject>) Mapper.builder(TestObject.class)
+ .map("id", "\"col1\"", new TestConverter())
+ .map("stringCol", "\"stringCol\"", new TestConverter()).build();
+
assertEquals("id", mapper.fieldForColumn("col1"));
assertEquals("stringCol", mapper.fieldForColumn("stringCol"));
assertNotNull(mapper.converterForColumn("col1"));
@@ -369,8 +408,8 @@ public class MapperTest {
PojoMapper<TestObject> mapper = (PojoMapper<TestObject>) Mapper.builder(TestObject.class)
.convert("col1", new TestConverter()).automap().build();
- assertEquals("id", mapper.fieldForColumn("id"));
- assertNotNull(mapper.converterForColumn("col1"));
+ assertEquals("id", mapper.fieldForColumn("ID"));
+ assertNotNull(mapper.converterForColumn("COL1"));
assertNull(mapper.converterForColumn("id"));
}
}
diff --git a/modules/schema/src/test/java/org/apache/ignite/internal/schema/marshaller/RecordMarshallerTest.java b/modules/schema/src/test/java/org/apache/ignite/internal/schema/marshaller/RecordMarshallerTest.java
index 6e7af22..42512d1 100644
--- a/modules/schema/src/test/java/org/apache/ignite/internal/schema/marshaller/RecordMarshallerTest.java
+++ b/modules/schema/src/test/java/org/apache/ignite/internal/schema/marshaller/RecordMarshallerTest.java
@@ -142,8 +142,8 @@ public class RecordMarshallerTest {
1,
keyColumns(),
new Column[]{
- new Column("primitiveDoubleCol", DOUBLE, false),
- new Column("stringCol", STRING, true),
+ new Column("primitiveDoubleCol".toUpperCase(), DOUBLE, false),
+ new Column("stringCol".toUpperCase(), STRING, true),
}
);
@@ -175,11 +175,11 @@ public class RecordMarshallerTest {
@MethodSource("marshallerFactoryProvider")
public void mapping(MarshallerFactory factory) throws MarshallerException {
SchemaDescriptor schema = new SchemaDescriptor(1,
- new Column[]{new Column("key", INT64, false)},
+ new Column[]{new Column("key".toUpperCase(), INT64, false)},
new Column[]{
- new Column("col1", INT32, false),
- new Column("col2", INT64, true),
- new Column("col3", STRING, false)
+ new Column("col1".toUpperCase(), INT32, false),
+ new Column("col2".toUpperCase(), INT64, true),
+ new Column("col3".toUpperCase(), STRING, false)
});
Mapper<TestObject> mapper = Mapper.builder(TestObject.class)
@@ -210,8 +210,8 @@ public class RecordMarshallerTest {
1,
keyColumns(),
new Column[]{
- new Column("bitmaskCol", NativeTypes.bitmaskOf(42), true),
- new Column("shortCol", UUID, true)
+ new Column("bitmaskCol".toUpperCase(), NativeTypes.bitmaskOf(42), true),
+ new Column("shortCol".toUpperCase(), UUID, true)
}
);
@@ -233,8 +233,8 @@ public class RecordMarshallerTest {
1,
keyColumns(),
new Column[]{
- new Column("primitiveLongCol", INT64, false),
- new Column("bitmaskCol", NativeTypes.bitmaskOf(9), true),
+ new Column("primitiveLongCol".toUpperCase(), INT64, false),
+ new Column("bitmaskCol".toUpperCase(), NativeTypes.bitmaskOf(9), true),
}
);
@@ -254,8 +254,8 @@ public class RecordMarshallerTest {
public void classWithPrivateConstructor(MarshallerFactory factory) throws MarshallerException, IllegalAccessException {
SchemaDescriptor schema = new SchemaDescriptor(
1,
- new Column[]{new Column("primLongCol", INT64, false)},
- new Column[]{new Column("primIntCol", INT32, false)}
+ new Column[]{new Column("primLongCol".toUpperCase(), INT64, false)},
+ new Column[]{new Column("primIntCol".toUpperCase(), INT32, false)}
);
RecordMarshaller<TestObjectWithPrivateConstructor> marshaller = factory.create(schema, TestObjectWithPrivateConstructor.class);
@@ -274,8 +274,8 @@ public class RecordMarshallerTest {
public void classWithNoDefaultConstructor(MarshallerFactory factory) {
SchemaDescriptor schema = new SchemaDescriptor(
1,
- new Column[]{new Column("primLongCol", INT64, false)},
- new Column[]{new Column("primIntCol", INT32, false)}
+ new Column[]{new Column("primLongCol".toUpperCase(), INT64, false)},
+ new Column[]{new Column("primIntCol".toUpperCase(), INT32, false)}
);
final Object rec = TestObjectWithNoDefaultConstructor.randomObject(rnd);
@@ -288,8 +288,8 @@ public class RecordMarshallerTest {
public void privateClass(MarshallerFactory factory) throws MarshallerException {
SchemaDescriptor schema = new SchemaDescriptor(
1,
- new Column[]{new Column("primLongCol", INT64, false)},
- new Column[]{new Column("primIntCol", INT32, false)}
+ new Column[]{new Column("primLongCol".toUpperCase(), INT64, false)},
+ new Column[]{new Column("primIntCol".toUpperCase(), INT32, false)}
);
final ObjectFactory<PrivateTestObject> objFactory = new ObjectFactory<>(PrivateTestObject.class);
@@ -313,13 +313,13 @@ public class RecordMarshallerTest {
Thread.currentThread().setContextClassLoader(new DynamicClassLoader(getClass().getClassLoader()));
Column[] keyCols = new Column[]{
- new Column("key", INT64, false)
+ new Column("key".toUpperCase(), INT64, false)
};
Column[] valCols = new Column[]{
- new Column("col0", INT64, false),
- new Column("col1", INT64, false),
- new Column("col2", INT64, false),
+ new Column("col0".toUpperCase(), INT64, false),
+ new Column("col1".toUpperCase(), INT64, false),
+ new Column("col2".toUpperCase(), INT64, false),
};
SchemaDescriptor schema = new SchemaDescriptor(1, keyCols, valCols);
@@ -421,38 +421,38 @@ public class RecordMarshallerTest {
private Column[] keyColumns() {
return new Column[]{
- new Column("primitiveLongCol", INT64, false),
- new Column("intCol", INT32, true)
+ new Column("primitiveLongCol".toUpperCase(), INT64, false),
+ new Column("intCol".toUpperCase(), INT32, true)
};
}
private Column[] valueColumnsAllTypes() {
return new Column[]{
- new Column("primitiveByteCol", INT8, false, () -> (byte) 0x42),
- new Column("primitiveShortCol", INT16, false, () -> (short) 0x4242),
- new Column("primitiveIntCol", INT32, false, () -> 0x42424242),
- new Column("primitiveFloatCol", FLOAT, false),
- new Column("primitiveDoubleCol", DOUBLE, false),
-
- new Column("byteCol", INT8, true),
- new Column("shortCol", INT16, true),
- new Column("longCol", INT64, true),
- new Column("nullLongCol", INT64, true),
- new Column("floatCol", FLOAT, true),
- new Column("doubleCol", DOUBLE, true),
-
- new Column("dateCol", DATE, true),
- new Column("timeCol", time(), true),
- new Column("dateTimeCol", datetime(), true),
- new Column("timestampCol", timestamp(), true),
-
- new Column("uuidCol", UUID, true),
- new Column("bitmaskCol", NativeTypes.bitmaskOf(42), true),
- new Column("stringCol", STRING, true),
- new Column("nullBytesCol", BYTES, true),
- new Column("bytesCol", BYTES, true),
- new Column("numberCol", NativeTypes.numberOf(12), true),
- new Column("decimalCol", NativeTypes.decimalOf(19, 3), true),
+ new Column("primitiveByteCol".toUpperCase(), INT8, false, () -> (byte) 0x42),
+ new Column("primitiveShortCol".toUpperCase(), INT16, false, () -> (short) 0x4242),
+ new Column("primitiveIntCol".toUpperCase(), INT32, false, () -> 0x42424242),
+ new Column("primitiveFloatCol".toUpperCase(), FLOAT, false),
+ new Column("primitiveDoubleCol".toUpperCase(), DOUBLE, false),
+
+ new Column("byteCol".toUpperCase(), INT8, true),
+ new Column("shortCol".toUpperCase(), INT16, true),
+ new Column("longCol".toUpperCase(), INT64, true),
+ new Column("nullLongCol".toUpperCase(), INT64, true),
+ new Column("floatCol".toUpperCase(), FLOAT, true),
+ new Column("doubleCol".toUpperCase(), DOUBLE, true),
+
+ new Column("dateCol".toUpperCase(), DATE, true),
+ new Column("timeCol".toUpperCase(), time(), true),
+ new Column("dateTimeCol".toUpperCase(), datetime(), true),
+ new Column("timestampCol".toUpperCase(), timestamp(), true),
+
+ new Column("uuidCol".toUpperCase(), UUID, true),
+ new Column("bitmaskCol".toUpperCase(), NativeTypes.bitmaskOf(42), true),
+ new Column("stringCol".toUpperCase(), STRING, true),
+ new Column("nullBytesCol".toUpperCase(), BYTES, true),
+ new Column("bytesCol".toUpperCase(), BYTES, true),
+ new Column("numberCol".toUpperCase(), NativeTypes.numberOf(12), true),
+ new Column("decimalCol".toUpperCase(), NativeTypes.decimalOf(19, 3), true),
};
}
diff --git a/modules/schema/src/test/java/org/apache/ignite/internal/schema/marshaller/RecordMarshallerValidationsTest.java b/modules/schema/src/test/java/org/apache/ignite/internal/schema/marshaller/RecordMarshallerValidationsTest.java
index 18d81f9..20f4b2e 100644
--- a/modules/schema/src/test/java/org/apache/ignite/internal/schema/marshaller/RecordMarshallerValidationsTest.java
+++ b/modules/schema/src/test/java/org/apache/ignite/internal/schema/marshaller/RecordMarshallerValidationsTest.java
@@ -37,7 +37,7 @@ import org.junit.jupiter.params.provider.MethodSource;
*/
public class RecordMarshallerValidationsTest {
/** Key columns for test. */
- private static Column[] KEY_COLS = new Column[]{new Column("id", INT32, false)};
+ private static Column[] KEY_COLS = new Column[]{new Column("id".toUpperCase(), INT32, false)};
/**
* Returns list of marshaller factories for the test.
@@ -53,8 +53,8 @@ public class RecordMarshallerValidationsTest {
@MethodSource("marshallerFactoryProvider")
public void testColsWithDefaultValue(MarshallerFactory factory) throws MarshallerException {
Column[] valCols = new Column[] {
- new Column("fbyte1", INT32, false),
- new Column("fbyte2", INT32, false, () -> 0x42)
+ new Column("fbyte1".toUpperCase(), INT32, false),
+ new Column("fbyte2".toUpperCase(), INT32, false, () -> 0x42)
};
SchemaDescriptor schema = new SchemaDescriptor(1, KEY_COLS, valCols);
@@ -79,8 +79,8 @@ public class RecordMarshallerValidationsTest {
@MethodSource("marshallerFactoryProvider")
public void testColsWithNullable(MarshallerFactory factory) throws MarshallerException {
Column[] valCols = new Column[] {
- new Column("fbyte1", INT32, false),
- new Column("fbyte2", INT32, true)
+ new Column("fbyte1".toUpperCase(), INT32, false),
+ new Column("fbyte2".toUpperCase(), INT32, true)
};
SchemaDescriptor schema = new SchemaDescriptor(1, KEY_COLS, valCols);
@@ -106,8 +106,8 @@ public class RecordMarshallerValidationsTest {
@MethodSource("marshallerFactoryProvider")
public void testReadOnly(MarshallerFactory factory) throws MarshallerException {
Column[] valCols = new Column[] {
- new Column("fbyte1", INT32, false),
- new Column("fbyte2", INT32, false)
+ new Column("fbyte1".toUpperCase(), INT32, false),
+ new Column("fbyte2".toUpperCase(), INT32, false)
};
SchemaDescriptor schema = new SchemaDescriptor(1, KEY_COLS, valCols);
@@ -132,9 +132,9 @@ public class RecordMarshallerValidationsTest {
@MethodSource("marshallerFactoryProvider")
public void truncatedKey(MarshallerFactory factory) throws MarshallerException {
SchemaDescriptor schema = new SchemaDescriptor(1, new Column[]{
- new Column("k1", INT32, false),
- new Column("k2", INT32, false)},
- new Column[]{new Column("v1", STRING, false)}
+ new Column("k1".toUpperCase(), INT32, false),
+ new Column("k2".toUpperCase(), INT32, false)},
+ new Column[]{new Column("v1".toUpperCase(), STRING, false)}
);
RecordMarshaller<TestK1K2V1> marshallerFull = factory.create(schema, TestK1K2V1.class);
diff --git a/modules/sql-engine/src/main/java/org/apache/ignite/internal/sql/engine/exec/ddl/DdlCommandHandler.java b/modules/sql-engine/src/main/java/org/apache/ignite/internal/sql/engine/exec/ddl/DdlCommandHandler.java
index 9442fab..2d30895 100644
--- a/modules/sql-engine/src/main/java/org/apache/ignite/internal/sql/engine/exec/ddl/DdlCommandHandler.java
+++ b/modules/sql-engine/src/main/java/org/apache/ignite/internal/sql/engine/exec/ddl/DdlCommandHandler.java
@@ -45,6 +45,7 @@ import org.apache.ignite.internal.sql.engine.prepare.ddl.DropIndexCommand;
import org.apache.ignite.internal.sql.engine.prepare.ddl.DropTableCommand;
import org.apache.ignite.internal.sql.engine.type.IgniteTypeFactory;
import org.apache.ignite.internal.table.distributed.TableManager;
+import org.apache.ignite.internal.util.IgniteObjectName;
import org.apache.ignite.internal.util.IgniteUtils;
import org.apache.ignite.internal.util.Pair;
import org.apache.ignite.lang.ColumnAlreadyExistsException;
@@ -111,15 +112,19 @@ public class DdlCommandHandler {
/** Handles create table command. */
private void handleCreateTable(CreateTableCommand cmd) {
final PrimaryKeyDefinitionBuilder pkeyDef = SchemaBuilders.primaryKey();
- pkeyDef.withColumns(cmd.primaryKeyColumns());
- pkeyDef.withAffinityColumns(cmd.affColumns());
+
+ pkeyDef.withColumns(IgniteObjectName.quoteNames(cmd.primaryKeyColumns()));
+ pkeyDef.withAffinityColumns(IgniteObjectName.quoteNames(cmd.affColumns()));
final IgniteTypeFactory typeFactory = pctx.typeFactory();
final List<org.apache.ignite.schema.definition.ColumnDefinition> colsInner = new ArrayList<>();
for (ColumnDefinition col : cmd.columns()) {
- ColumnDefinitionBuilder col0 = SchemaBuilders.column(col.name(), typeFactory.columnType(col.type()))
+ ColumnDefinitionBuilder col0 = SchemaBuilders.column(
+ IgniteObjectName.quote(col.name()),
+ typeFactory.columnType(col.type())
+ )
.asNullable(col.nullable())
.withDefaultValueExpression(col.defaultValue());
@@ -127,7 +132,10 @@ public class DdlCommandHandler {
}
Consumer<TableChange> tblChanger = tblCh -> {
- TableChange conv = convert(SchemaBuilders.tableBuilder(cmd.schemaName(), cmd.tableName())
+ TableChange conv = convert(SchemaBuilders.tableBuilder(
+ IgniteObjectName.quote(cmd.schemaName()),
+ IgniteObjectName.quote(cmd.tableName())
+ )
.columns(colsInner)
.withPrimaryKey(pkeyDef.build()).build(), tblCh);
@@ -140,7 +148,10 @@ public class DdlCommandHandler {
}
};
- String fullName = TableDefinitionImpl.canonicalName(cmd.schemaName(), cmd.tableName());
+ String fullName = TableDefinitionImpl.canonicalName(
+ IgniteObjectName.quote(cmd.schemaName()),
+ IgniteObjectName.quote(cmd.tableName())
+ );
try {
tableManager.createTable(fullName, tblChanger);
@@ -153,8 +164,10 @@ public class DdlCommandHandler {
/** Handles drop table command. */
private void handleDropTable(DropTableCommand cmd) {
- String fullName = TableDefinitionImpl.canonicalName(cmd.schemaName(), cmd.tableName());
-
+ String fullName = TableDefinitionImpl.canonicalName(
+ IgniteObjectName.quote(cmd.schemaName()),
+ IgniteObjectName.quote(cmd.tableName())
+ );
try {
tableManager.dropTable(fullName);
} catch (TableNotFoundException ex) {
@@ -170,7 +183,10 @@ public class DdlCommandHandler {
return;
}
- String fullName = TableDefinitionImpl.canonicalName(cmd.schemaName(), cmd.tableName());
+ String fullName = TableDefinitionImpl.canonicalName(
+ IgniteObjectName.quote(cmd.schemaName()),
+ IgniteObjectName.quote(cmd.tableName())
+ );
try {
addColumnInternal(fullName, cmd.columns(), cmd.ifColumnNotExists());
@@ -187,7 +203,10 @@ public class DdlCommandHandler {
return;
}
- String fullName = TableDefinitionImpl.canonicalName(cmd.schemaName(), cmd.tableName());
+ String fullName = TableDefinitionImpl.canonicalName(
+ IgniteObjectName.quote(cmd.schemaName()),
+ IgniteObjectName.quote(cmd.tableName())
+ );
try {
dropColumnInternal(fullName, cmd.columns(), cmd.ifColumnExists());
@@ -213,7 +232,10 @@ public class DdlCommandHandler {
idx0.done();
}
- String fullName = TableDefinitionImpl.canonicalName(cmd.schemaName(), cmd.tableName());
+ String fullName = TableDefinitionImpl.canonicalName(
+ IgniteObjectName.quote(cmd.schemaName()),
+ IgniteObjectName.quote(cmd.tableName())
+ );
tableManager.alterTable(fullName, chng -> chng.changeIndices(idxes -> {
if (idxes.get(cmd.indexName()) != null) {
@@ -262,7 +284,10 @@ public class DdlCommandHandler {
final IgniteTypeFactory typeFactory = pctx.typeFactory();
for (ColumnDefinition col : colsDef0) {
- ColumnDefinitionBuilder col0 = SchemaBuilders.column(col.name(), typeFactory.columnType(col.type()))
+ ColumnDefinitionBuilder col0 = SchemaBuilders.column(
+ IgniteObjectName.quote(col.name()),
+ typeFactory.columnType(col.type())
+ )
.asNullable(col.nullable())
.withDefaultValueExpression(col.defaultValue());
@@ -275,7 +300,7 @@ public class DdlCommandHandler {
* Drops a column(s) exceptional behavior depends on {@code colExist} flag.
*
* @param fullName Table with schema name.
- * @param colNames Columns defenitions.
+ * @param colNames Columns definitions.
* @param colExist Flag indicates exceptionally behavior in case of already existing column.
*/
private void dropColumnInternal(String fullName, Set<String> colNames, boolean colExist) {
@@ -309,7 +334,7 @@ public class DdlCommandHandler {
}));
}
- /** Map column names to orders. */
+ /** Map column name to order. */
private static Map<String, String> columnOrdersToNames(NamedListView<? extends ColumnView> cols) {
Map<String, String> colNames = new HashMap<>(cols.size());
diff --git a/modules/storage-rocksdb/src/test/java/org/apache/ignite/internal/storage/rocksdb/index/RocksDbSortedIndexStorageTest.java b/modules/storage-rocksdb/src/test/java/org/apache/ignite/internal/storage/rocksdb/index/RocksDbSortedIndexStorageTest.java
index 570b5c1..140c3df 100644
--- a/modules/storage-rocksdb/src/test/java/org/apache/ignite/internal/storage/rocksdb/index/RocksDbSortedIndexStorageTest.java
+++ b/modules/storage-rocksdb/src/test/java/org/apache/ignite/internal/storage/rocksdb/index/RocksDbSortedIndexStorageTest.java
@@ -326,7 +326,7 @@ public class RocksDbSortedIndexStorageTest {
StorageException ex = assertThrows(StorageException.class, () -> createIndex(definition));
- assertThat(ex.getMessage(), is(equalTo("Index \"wrong type\" is not configured as a Sorted Index. Actual type: HASH")));
+ assertThat(ex.getMessage(), is(equalTo("Index \"WRONG TYPE\" is not configured as a Sorted Index. Actual type: HASH")));
}
/**
diff --git a/modules/table/src/main/java/org/apache/ignite/internal/table/AbstractRowTupleAdapter.java b/modules/table/src/main/java/org/apache/ignite/internal/table/AbstractRowTupleAdapter.java
index 6b5e9e7..a640975 100644
--- a/modules/table/src/main/java/org/apache/ignite/internal/table/AbstractRowTupleAdapter.java
+++ b/modules/table/src/main/java/org/apache/ignite/internal/table/AbstractRowTupleAdapter.java
@@ -31,6 +31,7 @@ import org.apache.ignite.internal.schema.Column;
import org.apache.ignite.internal.schema.SchemaAware;
import org.apache.ignite.internal.schema.SchemaDescriptor;
import org.apache.ignite.internal.schema.row.Row;
+import org.apache.ignite.internal.util.IgniteObjectName;
import org.apache.ignite.table.Tuple;
import org.jetbrains.annotations.NotNull;
@@ -75,7 +76,7 @@ public abstract class AbstractRowTupleAdapter implements Tuple, SchemaAware {
public int columnIndex(@NotNull String columnName) {
Objects.requireNonNull(columnName);
- var col = row.schema().column(columnName);
+ var col = row.schema().column(IgniteObjectName.parse(columnName));
return col == null ? -1 : col.schemaIndex();
}
@@ -85,7 +86,7 @@ public abstract class AbstractRowTupleAdapter implements Tuple, SchemaAware {
public <T> T valueOrDefault(@NotNull String columnName, T defaultValue) {
Objects.requireNonNull(columnName);
- final Column col = row.schema().column(columnName);
+ final Column col = row.schema().column(IgniteObjectName.parse(columnName));
return col == null ? defaultValue : (T) col.type().spec().objectValue(row, col.schemaIndex());
}
@@ -381,7 +382,7 @@ public abstract class AbstractRowTupleAdapter implements Tuple, SchemaAware {
protected Column rowColumnByName(@NotNull String columnName) {
Objects.requireNonNull(columnName);
- final Column col = row.schema().column(columnName);
+ final Column col = row.schema().column(IgniteObjectName.parse(columnName));
if (col == null) {
throw new IllegalArgumentException("Invalid column name: columnName=" + columnName);
diff --git a/modules/table/src/main/java/org/apache/ignite/internal/table/distributed/TableManager.java b/modules/table/src/main/java/org/apache/ignite/internal/table/distributed/TableManager.java
index b8659cd..a6dff63 100644
--- a/modules/table/src/main/java/org/apache/ignite/internal/table/distributed/TableManager.java
+++ b/modules/table/src/main/java/org/apache/ignite/internal/table/distributed/TableManager.java
@@ -80,6 +80,7 @@ import org.apache.ignite.internal.table.event.TableEvent;
import org.apache.ignite.internal.table.event.TableEventParameters;
import org.apache.ignite.internal.tx.TxManager;
import org.apache.ignite.internal.util.ByteUtils;
+import org.apache.ignite.internal.util.IgniteObjectName;
import org.apache.ignite.internal.util.IgniteSpinBusyLock;
import org.apache.ignite.lang.IgniteException;
import org.apache.ignite.lang.IgniteInternalException;
@@ -687,7 +688,7 @@ public class TableManager extends Producer<TableEvent, TableEventParameters> imp
throw new IgniteException(new NodeStoppingException());
}
try {
- return createTableAsyncInternal(name, tableInitChange);
+ return createTableAsyncInternal(IgniteObjectName.parseCanonicalName(name), tableInitChange);
} finally {
busyLock.leaveBusy();
}
@@ -787,7 +788,7 @@ public class TableManager extends Producer<TableEvent, TableEventParameters> imp
throw new IgniteException(new NodeStoppingException());
}
try {
- return alterTableAsyncInternal(name, tableChange);
+ return alterTableAsyncInternal(IgniteObjectName.parseCanonicalName(name), tableChange);
} finally {
busyLock.leaveBusy();
}
@@ -916,7 +917,7 @@ public class TableManager extends Producer<TableEvent, TableEventParameters> imp
throw new IgniteException(new NodeStoppingException());
}
try {
- return dropTableAsyncInternal(name);
+ return dropTableAsyncInternal(IgniteObjectName.parseCanonicalName(name));
} finally {
busyLock.leaveBusy();
}
@@ -1129,7 +1130,7 @@ public class TableManager extends Producer<TableEvent, TableEventParameters> imp
throw new IgniteException(new NodeStoppingException());
}
try {
- IgniteUuid tableId = directTableId(name);
+ IgniteUuid tableId = directTableId(IgniteObjectName.parseCanonicalName(name));
if (tableId == null) {
return CompletableFuture.completedFuture(null);
diff --git a/modules/table/src/test/java/org/apache/ignite/internal/table/InteropOperationsTest.java b/modules/table/src/test/java/org/apache/ignite/internal/table/InteropOperationsTest.java
index 8ebf98e..241f567 100644
--- a/modules/table/src/test/java/org/apache/ignite/internal/table/InteropOperationsTest.java
+++ b/modules/table/src/test/java/org/apache/ignite/internal/table/InteropOperationsTest.java
@@ -99,14 +99,14 @@ public class InteropOperationsTest {
List<Column> valueCols = new ArrayList<>(types.length * 2);
for (NativeType type : types) {
- String colName = "f" + type.spec().name().toLowerCase();
+ String colName = "F" + type.spec().name().toUpperCase();
valueCols.add(new Column(colName, type, false));
valueCols.add(new Column(colName + "N", type, true));
}
SCHEMA = new SchemaDescriptor(1,
- new Column[]{new Column("id", NativeTypes.INT64, false)},
+ new Column[]{new Column("ID", NativeTypes.INT64, false)},
valueCols.toArray(Column[]::new)
);
diff --git a/modules/table/src/test/java/org/apache/ignite/internal/table/KeyValueBinaryViewOperationsTest.java b/modules/table/src/test/java/org/apache/ignite/internal/table/KeyValueBinaryViewOperationsTest.java
index bf15221..4b46c6b 100644
--- a/modules/table/src/test/java/org/apache/ignite/internal/table/KeyValueBinaryViewOperationsTest.java
+++ b/modules/table/src/test/java/org/apache/ignite/internal/table/KeyValueBinaryViewOperationsTest.java
@@ -53,11 +53,7 @@ import org.mockito.Mockito;
public class KeyValueBinaryViewOperationsTest {
@Test
public void put() {
- SchemaDescriptor schema = new SchemaDescriptor(
- 1,
- new Column[]{new Column("id", NativeTypes.INT64, false)},
- new Column[]{new Column("val", NativeTypes.INT64, false)}
- );
+ SchemaDescriptor schema = schemaDescriptor();
KeyValueView<Tuple, Tuple> tbl = createTable(schema).keyValueView();
@@ -92,11 +88,7 @@ public class KeyValueBinaryViewOperationsTest {
@Test
public void putIfAbsent() {
- SchemaDescriptor schema = new SchemaDescriptor(
- 1,
- new Column[]{new Column("id", NativeTypes.INT64, false)},
- new Column[]{new Column("val", NativeTypes.INT64, false)}
- );
+ SchemaDescriptor schema = schemaDescriptor();
KeyValueView<Tuple, Tuple> tbl = createTable(schema).keyValueView();
@@ -121,11 +113,7 @@ public class KeyValueBinaryViewOperationsTest {
@Test
public void getAndPut() {
- SchemaDescriptor schema = new SchemaDescriptor(
- 1,
- new Column[]{new Column("id", NativeTypes.INT64, false)},
- new Column[]{new Column("val", NativeTypes.INT64, false)}
- );
+ SchemaDescriptor schema = schemaDescriptor();
KeyValueView<Tuple, Tuple> tbl = createTable(schema).keyValueView();
@@ -186,11 +174,7 @@ public class KeyValueBinaryViewOperationsTest {
@Test
public void remove() {
- SchemaDescriptor schema = new SchemaDescriptor(
- 1,
- new Column[]{new Column("id", NativeTypes.INT64, false)},
- new Column[]{new Column("val", NativeTypes.INT64, false)}
- );
+ SchemaDescriptor schema = schemaDescriptor();
KeyValueView<Tuple, Tuple> tbl = createTable(schema).keyValueView();
@@ -225,11 +209,7 @@ public class KeyValueBinaryViewOperationsTest {
@Test
public void removeExact() {
- SchemaDescriptor schema = new SchemaDescriptor(
- 1,
- new Column[]{new Column("id", NativeTypes.INT64, false)},
- new Column[]{new Column("val", NativeTypes.INT64, false)}
- );
+ SchemaDescriptor schema = schemaDescriptor();
final KeyValueView<Tuple, Tuple> tbl = createTable(schema).keyValueView();
@@ -276,11 +256,7 @@ public class KeyValueBinaryViewOperationsTest {
@Test
public void replace() {
- SchemaDescriptor schema = new SchemaDescriptor(
- 1,
- new Column[]{new Column("id", NativeTypes.INT64, false)},
- new Column[]{new Column("val", NativeTypes.INT64, false)}
- );
+ SchemaDescriptor schema = schemaDescriptor();
KeyValueView<Tuple, Tuple> tbl = createTable(schema).keyValueView();
@@ -310,11 +286,7 @@ public class KeyValueBinaryViewOperationsTest {
@Test
public void replaceExact() {
- SchemaDescriptor schema = new SchemaDescriptor(
- 1,
- new Column[]{new Column("id", NativeTypes.INT64, false)},
- new Column[]{new Column("val", NativeTypes.INT64, false)}
- );
+ SchemaDescriptor schema = schemaDescriptor();
KeyValueView<Tuple, Tuple> tbl = createTable(schema).keyValueView();
@@ -336,11 +308,7 @@ public class KeyValueBinaryViewOperationsTest {
@Test
public void getAll() {
- SchemaDescriptor schema = new SchemaDescriptor(
- 1,
- new Column[]{new Column("id", NativeTypes.INT64, false)},
- new Column[]{new Column("val", NativeTypes.INT64, false)}
- );
+ SchemaDescriptor schema = schemaDescriptor();
KeyValueView<Tuple, Tuple> tbl = createTable(schema).keyValueView();
@@ -364,6 +332,15 @@ public class KeyValueBinaryViewOperationsTest {
}
@NotNull
+ private SchemaDescriptor schemaDescriptor() {
+ return new SchemaDescriptor(
+ 1,
+ new Column[]{new Column("ID", NativeTypes.INT64, false)},
+ new Column[]{new Column("VAL", NativeTypes.INT64, false)}
+ );
+ }
+
+ @NotNull
private TableImpl createTable(SchemaDescriptor schema) {
ClusterService clusterService = Mockito.mock(ClusterService.class, RETURNS_DEEP_STUBS);
Mockito.when(clusterService.topologyService().localMember().address()).thenReturn(DummyInternalTableImpl.ADDR);
diff --git a/modules/table/src/test/java/org/apache/ignite/internal/table/KeyValueViewOperationsSimpleSchemaTest.java b/modules/table/src/test/java/org/apache/ignite/internal/table/KeyValueViewOperationsSimpleSchemaTest.java
index d8f483c..49d234f 100644
--- a/modules/table/src/test/java/org/apache/ignite/internal/table/KeyValueViewOperationsSimpleSchemaTest.java
+++ b/modules/table/src/test/java/org/apache/ignite/internal/table/KeyValueViewOperationsSimpleSchemaTest.java
@@ -370,8 +370,8 @@ public class KeyValueViewOperationsSimpleSchemaTest {
SchemaDescriptor schema = new SchemaDescriptor(
1,
- new Column[]{new Column("id", NativeTypes.INT64, false)},
- new Column[]{new Column("val", type, true)}
+ new Column[]{new Column("ID", NativeTypes.INT64, false)},
+ new Column[]{new Column("VAL", type, true)}
);
return new KeyValueViewImpl<>(
diff --git a/modules/table/src/test/java/org/apache/ignite/internal/table/KeyValueViewOperationsTest.java b/modules/table/src/test/java/org/apache/ignite/internal/table/KeyValueViewOperationsTest.java
index aeb1706..4460fd9 100644
--- a/modules/table/src/test/java/org/apache/ignite/internal/table/KeyValueViewOperationsTest.java
+++ b/modules/table/src/test/java/org/apache/ignite/internal/table/KeyValueViewOperationsTest.java
@@ -361,38 +361,38 @@ public class KeyValueViewOperationsTest {
Mapper<TestObjectWithAllTypes> valMapper = Mapper.of(TestObjectWithAllTypes.class);
Column[] valCols = {
- new Column("primitiveByteCol", INT8, false),
- new Column("primitiveShortCol", INT16, false),
- new Column("primitiveIntCol", INT32, false),
- new Column("primitiveLongCol", INT64, false),
- new Column("primitiveFloatCol", FLOAT, false),
- new Column("primitiveDoubleCol", DOUBLE, false),
-
- new Column("byteCol", INT8, true),
- new Column("shortCol", INT16, true),
- new Column("intCol", INT32, true),
- new Column("longCol", INT64, true),
- new Column("nullLongCol", INT64, true),
- new Column("floatCol", FLOAT, true),
- new Column("doubleCol", DOUBLE, true),
-
- new Column("dateCol", DATE, true),
- new Column("timeCol", time(), true),
- new Column("dateTimeCol", datetime(), true),
- new Column("timestampCol", timestamp(), true),
-
- new Column("uuidCol", NativeTypes.UUID, true),
- new Column("bitmaskCol", NativeTypes.bitmaskOf(42), true),
- new Column("stringCol", STRING, true),
- new Column("nullBytesCol", BYTES, true),
- new Column("bytesCol", BYTES, true),
- new Column("numberCol", NativeTypes.numberOf(12), true),
- new Column("decimalCol", NativeTypes.decimalOf(19, 3), true),
+ new Column("primitiveByteCol".toUpperCase(), INT8, false),
+ new Column("primitiveShortCol".toUpperCase(), INT16, false),
+ new Column("primitiveIntCol".toUpperCase(), INT32, false),
+ new Column("primitiveLongCol".toUpperCase(), INT64, false),
+ new Column("primitiveFloatCol".toUpperCase(), FLOAT, false),
+ new Column("primitiveDoubleCol".toUpperCase(), DOUBLE, false),
+
+ new Column("byteCol".toUpperCase(), INT8, true),
+ new Column("shortCol".toUpperCase(), INT16, true),
+ new Column("intCol".toUpperCase(), INT32, true),
+ new Column("longCol".toUpperCase(), INT64, true),
+ new Column("nullLongCol".toUpperCase(), INT64, true),
+ new Column("floatCol".toUpperCase(), FLOAT, true),
+ new Column("doubleCol".toUpperCase(), DOUBLE, true),
+
+ new Column("dateCol".toUpperCase(), DATE, true),
+ new Column("timeCol".toUpperCase(), time(), true),
+ new Column("dateTimeCol".toUpperCase(), datetime(), true),
+ new Column("timestampCol".toUpperCase(), timestamp(), true),
+
+ new Column("uuidCol".toUpperCase(), NativeTypes.UUID, true),
+ new Column("bitmaskCol".toUpperCase(), NativeTypes.bitmaskOf(42), true),
+ new Column("stringCol".toUpperCase(), STRING, true),
+ new Column("nullBytesCol".toUpperCase(), BYTES, true),
+ new Column("bytesCol".toUpperCase(), BYTES, true),
+ new Column("numberCol".toUpperCase(), NativeTypes.numberOf(12), true),
+ new Column("decimalCol".toUpperCase(), NativeTypes.decimalOf(19, 3), true),
};
SchemaDescriptor schema = new SchemaDescriptor(
1,
- new Column[]{new Column("id", NativeTypes.INT64, false)},
+ new Column[]{new Column("id".toUpperCase(), NativeTypes.INT64, false)},
valCols
);
diff --git a/modules/table/src/test/java/org/apache/ignite/internal/table/MutableRowTupleAdapterTest.java b/modules/table/src/test/java/org/apache/ignite/internal/table/MutableRowTupleAdapterTest.java
index bc2eba8..e01b9cd 100644
--- a/modules/table/src/test/java/org/apache/ignite/internal/table/MutableRowTupleAdapterTest.java
+++ b/modules/table/src/test/java/org/apache/ignite/internal/table/MutableRowTupleAdapterTest.java
@@ -73,29 +73,29 @@ public class MutableRowTupleAdapterTest {
/** Schema descriptor. */
private SchemaDescriptor schema = new SchemaDescriptor(
42,
- new Column[]{new Column("id", NativeTypes.INT64, false)},
- new Column[]{new Column("name", NativeTypes.STRING, true)}
+ new Column[]{new Column("id".toUpperCase(), NativeTypes.INT64, false)},
+ new Column[]{new Column("name".toUpperCase(), NativeTypes.STRING, true)}
);
/** Schema descriptor. */
private SchemaDescriptor fullSchema = new SchemaDescriptor(42,
- new Column[]{new Column("keyUuidCol", NativeTypes.UUID, true)},
+ new Column[]{new Column("keyUuidCol".toUpperCase(), NativeTypes.UUID, true)},
new Column[]{
- new Column("valByteCol", INT8, true),
- new Column("valShortCol", INT16, true),
- new Column("valIntCol", INT32, true),
- new Column("valLongCol", INT64, true),
- new Column("valFloatCol", FLOAT, true),
- new Column("valDoubleCol", DOUBLE, true),
- new Column("valDateCol", DATE, true),
- new Column("valTimeCol", time(), true),
- new Column("valDateTimeCol", datetime(), true),
- new Column("valTimeStampCol", timestamp(), true),
- new Column("valBitmask1Col", NativeTypes.bitmaskOf(22), true),
- new Column("valBytesCol", BYTES, false),
- new Column("valStringCol", STRING, false),
- new Column("valNumberCol", NativeTypes.numberOf(20), false),
- new Column("valDecimalCol", NativeTypes.decimalOf(25, 5), false),
+ new Column("valByteCol".toUpperCase(), INT8, true),
+ new Column("valShortCol".toUpperCase(), INT16, true),
+ new Column("valIntCol".toUpperCase(), INT32, true),
+ new Column("valLongCol".toUpperCase(), INT64, true),
+ new Column("valFloatCol".toUpperCase(), FLOAT, true),
+ new Column("valDoubleCol".toUpperCase(), DOUBLE, true),
+ new Column("valDateCol".toUpperCase(), DATE, true),
+ new Column("valTimeCol".toUpperCase(), time(), true),
+ new Column("valDateTimeCol".toUpperCase(), datetime(), true),
+ new Column("valTimeStampCol".toUpperCase(), timestamp(), true),
+ new Column("valBitmask1Col".toUpperCase(), NativeTypes.bitmaskOf(22), true),
+ new Column("valBytesCol".toUpperCase(), BYTES, false),
+ new Column("valStringCol".toUpperCase(), STRING, false),
+ new Column("valNumberCol".toUpperCase(), NativeTypes.numberOf(20), false),
+ new Column("valDecimalCol".toUpperCase(), NativeTypes.decimalOf(25, 5), false),
}
);
@@ -171,8 +171,8 @@ public class MutableRowTupleAdapterTest {
@Test
public void testColumnNameReturnsNameByIndex() {
- assertEquals("id", getTuple().columnName(0));
- assertEquals("name", getTuple().columnName(1));
+ assertEquals("ID", getTuple().columnName(0));
+ assertEquals("NAME", getTuple().columnName(1));
}
@Test
@@ -199,10 +199,10 @@ public class MutableRowTupleAdapterTest {
public void testKeyValueChunks() throws TupleMarshallerException {
SchemaDescriptor schema = new SchemaDescriptor(
42,
- new Column[]{new Column("id", NativeTypes.INT64, false)},
+ new Column[]{new Column("id".toUpperCase(), NativeTypes.INT64, false)},
new Column[]{
- new Column("name", NativeTypes.STRING, true),
- new Column("price", NativeTypes.DOUBLE, true)
+ new Column("name".toUpperCase(), NativeTypes.STRING, true),
+ new Column("price".toUpperCase(), NativeTypes.DOUBLE, true)
}
);
@@ -345,7 +345,7 @@ public class MutableRowTupleAdapterTest {
TupleMarshaller marshaller = new TupleMarshallerImpl(new DummySchemaManagerImpl(fullSchema));
- Tuple tuple = Tuple.create()
+ Tuple tuple = Tuple.create()
.set("valByteCol", (byte) 1)
.set("valShortCol", (short) 2)
.set("valIntCol", 3)
diff --git a/modules/table/src/test/java/org/apache/ignite/internal/table/RecordBinaryViewOperationsTest.java b/modules/table/src/test/java/org/apache/ignite/internal/table/RecordBinaryViewOperationsTest.java
index 831c9a2..13d8a33 100644
--- a/modules/table/src/test/java/org/apache/ignite/internal/table/RecordBinaryViewOperationsTest.java
+++ b/modules/table/src/test/java/org/apache/ignite/internal/table/RecordBinaryViewOperationsTest.java
@@ -61,8 +61,8 @@ public class RecordBinaryViewOperationsTest {
public void insert() {
SchemaDescriptor schema = new SchemaDescriptor(
1,
- new Column[]{new Column("id", NativeTypes.INT64, false)},
- new Column[]{new Column("val", NativeTypes.INT64, false)}
+ new Column[]{new Column("id".toUpperCase(), NativeTypes.INT64, false)},
+ new Column[]{new Column("val".toUpperCase(), NativeTypes.INT64, false)}
);
RecordView<Tuple> tbl = createTableImpl(schema).recordView();
@@ -90,8 +90,8 @@ public class RecordBinaryViewOperationsTest {
public void upsert() {
SchemaDescriptor schema = new SchemaDescriptor(
1,
- new Column[]{new Column("id", NativeTypes.INT64, false)},
- new Column[]{new Column("val", NativeTypes.INT64, false)}
+ new Column[]{new Column("id".toUpperCase(), NativeTypes.INT64, false)},
+ new Column[]{new Column("val".toUpperCase(), NativeTypes.INT64, false)}
);
RecordView<Tuple> tbl = createTableImpl(schema).recordView();
@@ -119,8 +119,8 @@ public class RecordBinaryViewOperationsTest {
public void getAndUpsert() {
SchemaDescriptor schema = new SchemaDescriptor(
1,
- new Column[]{new Column("id", NativeTypes.INT64, false)},
- new Column[]{new Column("val", NativeTypes.INT64, false)}
+ new Column[]{new Column("id".toUpperCase(), NativeTypes.INT64, false)},
+ new Column[]{new Column("val".toUpperCase(), NativeTypes.INT64, false)}
);
RecordView<Tuple> tbl = createTableImpl(schema).recordView();
@@ -145,8 +145,8 @@ public class RecordBinaryViewOperationsTest {
public void remove() {
SchemaDescriptor schema = new SchemaDescriptor(
1,
- new Column[]{new Column("id", NativeTypes.INT64, false)},
- new Column[]{new Column("val", NativeTypes.INT64, false)}
+ new Column[]{new Column("id".toUpperCase(), NativeTypes.INT64, false)},
+ new Column[]{new Column("val".toUpperCase(), NativeTypes.INT64, false)}
);
RecordView<Tuple> tbl = createTableImpl(schema).recordView();
@@ -170,8 +170,8 @@ public class RecordBinaryViewOperationsTest {
public void removeExact() {
SchemaDescriptor schema = new SchemaDescriptor(
1,
- new Column[]{new Column("id", NativeTypes.INT64, false)},
- new Column[]{new Column("val", NativeTypes.INT64, false)}
+ new Column[]{new Column("id".toUpperCase(), NativeTypes.INT64, false)},
+ new Column[]{new Column("val".toUpperCase(), NativeTypes.INT64, false)}
);
RecordView<Tuple> tbl = createTableImpl(schema).recordView();
@@ -218,8 +218,8 @@ public class RecordBinaryViewOperationsTest {
public void replace() {
SchemaDescriptor schema = new SchemaDescriptor(
1,
- new Column[]{new Column("id", NativeTypes.INT64, false)},
- new Column[]{new Column("val", NativeTypes.INT64, false)}
+ new Column[]{new Column("id".toUpperCase(), NativeTypes.INT64, false)},
+ new Column[]{new Column("val".toUpperCase(), NativeTypes.INT64, false)}
);
RecordView<Tuple> tbl = createTableImpl(schema).recordView();
@@ -248,8 +248,8 @@ public class RecordBinaryViewOperationsTest {
public void replaceExact() {
SchemaDescriptor schema = new SchemaDescriptor(
1,
- new Column[]{new Column("id", NativeTypes.INT64, false)},
- new Column[]{new Column("val", NativeTypes.INT64, false)}
+ new Column[]{new Column("id".toUpperCase(), NativeTypes.INT64, false)},
+ new Column[]{new Column("val".toUpperCase(), NativeTypes.INT64, false)}
);
RecordView<Tuple> tbl = createTableImpl(schema).recordView();
@@ -279,11 +279,11 @@ public class RecordBinaryViewOperationsTest {
public void validateSchema() {
SchemaDescriptor schema = new SchemaDescriptor(
1,
- new Column[]{new Column("id", NativeTypes.INT64, false)},
+ new Column[]{new Column("id".toUpperCase(), NativeTypes.INT64, false)},
new Column[]{
- new Column("val", NativeTypes.INT64, true),
- new Column("str", NativeTypes.stringOf(3), true),
- new Column("blob", NativeTypes.blobOf(3), true)
+ new Column("val".toUpperCase(), NativeTypes.INT64, true),
+ new Column("str".toUpperCase(), NativeTypes.stringOf(3), true),
+ new Column("blob".toUpperCase(), NativeTypes.blobOf(3), true)
}
);
@@ -311,11 +311,11 @@ public class RecordBinaryViewOperationsTest {
public void defaultValues() {
SchemaDescriptor schema = new SchemaDescriptor(
1,
- new Column[]{new Column("id", NativeTypes.INT64, false)},
+ new Column[]{new Column("id".toUpperCase(), NativeTypes.INT64, false)},
new Column[]{
- new Column("val", NativeTypes.INT64, true, () -> 28L),
- new Column("str", NativeTypes.stringOf(3), true, () -> "ABC"),
- new Column("blob", NativeTypes.blobOf(3), true, () -> new byte[]{0, 1, 2})
+ new Column("val".toUpperCase(), NativeTypes.INT64, true, () -> 28L),
+ new Column("str".toUpperCase(), NativeTypes.stringOf(3), true, () -> "ABC"),
+ new Column("blob".toUpperCase(), NativeTypes.blobOf(3), true, () -> new byte[]{0, 1, 2})
}
);
@@ -339,8 +339,8 @@ public class RecordBinaryViewOperationsTest {
public void getAll() {
SchemaDescriptor schema = new SchemaDescriptor(
1,
- new Column[]{new Column("id", NativeTypes.INT64, false)},
- new Column[]{new Column("val", NativeTypes.INT64, false)}
+ new Column[]{new Column("id".toUpperCase(), NativeTypes.INT64, false)},
+ new Column[]{new Column("val".toUpperCase(), NativeTypes.INT64, false)}
);
RecordView<Tuple> tbl = createTableImpl(schema).recordView();
diff --git a/modules/table/src/test/java/org/apache/ignite/internal/table/RecordViewOperationsTest.java b/modules/table/src/test/java/org/apache/ignite/internal/table/RecordViewOperationsTest.java
index 89933b0..39668fa 100644
--- a/modules/table/src/test/java/org/apache/ignite/internal/table/RecordViewOperationsTest.java
+++ b/modules/table/src/test/java/org/apache/ignite/internal/table/RecordViewOperationsTest.java
@@ -308,37 +308,37 @@ public class RecordViewOperationsTest {
Mapper<TestObjectWithAllTypes> recMapper = Mapper.of(TestObjectWithAllTypes.class);
Column[] valCols = {
- new Column("primitiveByteCol", INT8, false),
- new Column("primitiveShortCol", INT16, false),
- new Column("primitiveIntCol", INT32, false),
- new Column("primitiveFloatCol", FLOAT, false),
- new Column("primitiveDoubleCol", DOUBLE, false),
-
- new Column("byteCol", INT8, true),
- new Column("shortCol", INT16, true),
- new Column("intCol", INT32, true),
- new Column("longCol", INT64, true),
- new Column("nullLongCol", INT64, true),
- new Column("floatCol", FLOAT, true),
- new Column("doubleCol", DOUBLE, true),
-
- new Column("dateCol", DATE, true),
- new Column("timeCol", time(), true),
- new Column("dateTimeCol", datetime(), true),
- new Column("timestampCol", timestamp(), true),
-
- new Column("uuidCol", NativeTypes.UUID, true),
- new Column("bitmaskCol", NativeTypes.bitmaskOf(42), true),
- new Column("stringCol", STRING, true),
- new Column("nullBytesCol", BYTES, true),
- new Column("bytesCol", BYTES, true),
- new Column("numberCol", NativeTypes.numberOf(12), true),
- new Column("decimalCol", NativeTypes.decimalOf(19, 3), true),
+ new Column("primitiveByteCol".toUpperCase(), INT8, false),
+ new Column("primitiveShortCol".toUpperCase(), INT16, false),
+ new Column("primitiveIntCol".toUpperCase(), INT32, false),
+ new Column("primitiveFloatCol".toUpperCase(), FLOAT, false),
+ new Column("primitiveDoubleCol".toUpperCase(), DOUBLE, false),
+
+ new Column("byteCol".toUpperCase(), INT8, true),
+ new Column("shortCol".toUpperCase(), INT16, true),
+ new Column("intCol".toUpperCase(), INT32, true),
+ new Column("longCol".toUpperCase(), INT64, true),
+ new Column("nullLongCol".toUpperCase(), INT64, true),
+ new Column("floatCol".toUpperCase(), FLOAT, true),
+ new Column("doubleCol".toUpperCase(), DOUBLE, true),
+
+ new Column("dateCol".toUpperCase(), DATE, true),
+ new Column("timeCol".toUpperCase(), time(), true),
+ new Column("dateTimeCol".toUpperCase(), datetime(), true),
+ new Column("timestampCol".toUpperCase(), timestamp(), true),
+
+ new Column("uuidCol".toUpperCase(), NativeTypes.UUID, true),
+ new Column("bitmaskCol".toUpperCase(), NativeTypes.bitmaskOf(42), true),
+ new Column("stringCol".toUpperCase(), STRING, true),
+ new Column("nullBytesCol".toUpperCase(), BYTES, true),
+ new Column("bytesCol".toUpperCase(), BYTES, true),
+ new Column("numberCol".toUpperCase(), NativeTypes.numberOf(12), true),
+ new Column("decimalCol".toUpperCase(), NativeTypes.decimalOf(19, 3), true),
};
SchemaDescriptor schema = new SchemaDescriptor(
1,
- new Column[]{new Column("primitiveLongCol", NativeTypes.INT64, false)},
+ new Column[]{new Column("primitiveLongCol".toUpperCase(), NativeTypes.INT64, false)},
valCols
);
diff --git a/modules/table/src/test/java/org/apache/ignite/internal/table/TxAbstractTest.java b/modules/table/src/test/java/org/apache/ignite/internal/table/TxAbstractTest.java
index b1c5809..8f5858c 100644
--- a/modules/table/src/test/java/org/apache/ignite/internal/table/TxAbstractTest.java
+++ b/modules/table/src/test/java/org/apache/ignite/internal/table/TxAbstractTest.java
@@ -83,8 +83,8 @@ import org.mockito.quality.Strictness;
public abstract class TxAbstractTest extends IgniteAbstractTest {
protected static SchemaDescriptor ACCOUNTS_SCHEMA = new SchemaDescriptor(
1,
- new Column[]{new Column("accountNumber", NativeTypes.INT64, false)},
- new Column[]{new Column("balance", NativeTypes.DOUBLE, false)}
+ new Column[]{new Column("accountNumber".toUpperCase(), NativeTypes.INT64, false)},
+ new Column[]{new Column("balance".toUpperCase(), NativeTypes.DOUBLE, false)}
);
/** Table ID test value. */
@@ -92,8 +92,8 @@ public abstract class TxAbstractTest extends IgniteAbstractTest {
protected static SchemaDescriptor CUSTOMERS_SCHEMA = new SchemaDescriptor(
1,
- new Column[]{new Column("accountNumber", NativeTypes.INT64, false)},
- new Column[]{new Column("name", NativeTypes.STRING, false)}
+ new Column[]{new Column("accountNumber".toUpperCase(), NativeTypes.INT64, false)},
+ new Column[]{new Column("name".toUpperCase(), NativeTypes.STRING, false)}
);
/** Accounts table id -> balance. */
diff --git a/modules/table/src/test/java/org/apache/ignite/internal/table/impl/TestTupleBuilder.java b/modules/table/src/test/java/org/apache/ignite/internal/table/impl/TestTupleBuilder.java
index 1add0d1..34172d2 100644
--- a/modules/table/src/test/java/org/apache/ignite/internal/table/impl/TestTupleBuilder.java
+++ b/modules/table/src/test/java/org/apache/ignite/internal/table/impl/TestTupleBuilder.java
@@ -28,6 +28,7 @@ import java.util.Map;
import java.util.UUID;
import org.apache.ignite.binary.BinaryObject;
import org.apache.ignite.binary.BinaryObjects;
+import org.apache.ignite.internal.util.IgniteObjectName;
import org.apache.ignite.table.Tuple;
import org.jetbrains.annotations.NotNull;
@@ -41,7 +42,7 @@ public class TestTupleBuilder implements Tuple {
/** {@inheritDoc} */
@Override
public TestTupleBuilder set(@NotNull String columnName, Object value) {
- map.put(columnName, value);
+ map.put(IgniteObjectName.parse(columnName), value);
return this;
}
@@ -49,13 +50,13 @@ public class TestTupleBuilder implements Tuple {
/** {@inheritDoc} */
@Override
public <T> T valueOrDefault(@NotNull String columnName, T def) {
- return (T) map.getOrDefault(columnName, def);
+ return (T) map.getOrDefault(IgniteObjectName.parse(columnName), def);
}
/** {@inheritDoc} */
@Override
public <T> T value(@NotNull String columnName) {
- return (T) map.get(columnName);
+ return (T) map.get(IgniteObjectName.parse(columnName));
}
/** {@inheritDoc} */
diff --git a/modules/table/src/test/java/org/apache/ignite/table/TupleImplTest.java b/modules/table/src/test/java/org/apache/ignite/table/TupleImplTest.java
index 39016bd..498b8d4 100644
--- a/modules/table/src/test/java/org/apache/ignite/table/TupleImplTest.java
+++ b/modules/table/src/test/java/org/apache/ignite/table/TupleImplTest.java
@@ -124,8 +124,8 @@ public class TupleImplTest {
@Test
public void testColumnNameReturnsNameByIndex() {
- assertEquals("id", getTuple().columnName(0));
- assertEquals("name", getTuple().columnName(1));
+ assertEquals("ID", getTuple().columnName(0));
+ assertEquals("NAME", getTuple().columnName(1));
}
@Test