This is an automated email from the ASF dual-hosted git repository. ppa pushed a commit to branch main in repository https://gitbox.apache.org/repos/asf/ignite-3.git
The following commit(s) were added to refs/heads/main by this push: new 95fe95bae4 IGNITE-22148 Sql. Improved test coverage for the RAND_UUID functional default (#3814) 95fe95bae4 is described below commit 95fe95bae432e5a4eec229f1826f76d29462e91e Author: Max Zhuravkov <shh...@gmail.com> AuthorDate: Fri May 24 13:40:04 2024 +0300 IGNITE-22148 Sql. Improved test coverage for the RAND_UUID functional default (#3814) --- .../ignite/internal/catalog/CatalogTableTest.java | 20 ++++++++++++++++++++ .../internal/sql/engine/ItCreateTableDdlTest.java | 9 +++++++++ 2 files changed, 29 insertions(+) diff --git a/modules/catalog/src/test/java/org/apache/ignite/internal/catalog/CatalogTableTest.java b/modules/catalog/src/test/java/org/apache/ignite/internal/catalog/CatalogTableTest.java index 508645f849..78f91b81c9 100644 --- a/modules/catalog/src/test/java/org/apache/ignite/internal/catalog/CatalogTableTest.java +++ b/modules/catalog/src/test/java/org/apache/ignite/internal/catalog/CatalogTableTest.java @@ -31,6 +31,7 @@ import static org.apache.ignite.internal.catalog.commands.CatalogUtils.pkIndexNa import static org.apache.ignite.internal.catalog.commands.DefaultValue.constant; import static org.apache.ignite.internal.catalog.descriptors.CatalogIndexStatus.AVAILABLE; import static org.apache.ignite.internal.lang.IgniteStringFormatter.format; +import static org.apache.ignite.internal.testframework.IgniteTestUtils.assertThrows; import static org.apache.ignite.internal.testframework.IgniteTestUtils.assertThrowsWithCause; import static org.apache.ignite.internal.testframework.IgniteTestUtils.await; import static org.apache.ignite.internal.testframework.matchers.CompletableFutureExceptionMatcher.willThrow; @@ -75,6 +76,7 @@ import org.apache.ignite.internal.catalog.commands.CatalogUtils; import org.apache.ignite.internal.catalog.commands.ColumnParams; import org.apache.ignite.internal.catalog.commands.ColumnParams.Builder; import org.apache.ignite.internal.catalog.commands.CreateTableCommand; +import org.apache.ignite.internal.catalog.commands.CreateTableCommandBuilder; import org.apache.ignite.internal.catalog.commands.DefaultValue; import org.apache.ignite.internal.catalog.commands.RenameTableCommand; import org.apache.ignite.internal.catalog.commands.TableHashPrimaryKey; @@ -1104,6 +1106,24 @@ public class CatalogTableTest extends BaseCatalogManagerTest { assertEquals(versionBefore, versionAfter); } + @Test + public void testFunctionalDefaultTypeMismatch() { + ColumnParams key1 = ColumnParams.builder() + .name("key1") + .type(STRING) + .length(100) + .defaultValue(DefaultValue.functionCall("RAND_UUID")) + .build(); + + CreateTableCommandBuilder commandBuilder = CreateTableCommand.builder() + .tableName(TABLE_NAME) + .schemaName(SCHEMA_NAME) + .columns(List.of(key1, columnParams("key2", INT32))) + .primaryKey(TableHashPrimaryKey.builder().columns(List.of("key1")).build()); + + String error = "[col=key1, functionName=RAND_UUID, expectedType=UUID, actualType=STRING]"; + assertThrows(CatalogValidationException.class, commandBuilder::build, error); + } private CompletableFuture<?> changeColumn( String tab, diff --git a/modules/sql-engine/src/integrationTest/java/org/apache/ignite/internal/sql/engine/ItCreateTableDdlTest.java b/modules/sql-engine/src/integrationTest/java/org/apache/ignite/internal/sql/engine/ItCreateTableDdlTest.java index 3588e3b1ad..9ba18a8873 100644 --- a/modules/sql-engine/src/integrationTest/java/org/apache/ignite/internal/sql/engine/ItCreateTableDdlTest.java +++ b/modules/sql-engine/src/integrationTest/java/org/apache/ignite/internal/sql/engine/ItCreateTableDdlTest.java @@ -153,6 +153,15 @@ public class ItCreateTableDdlTest extends BaseSqlIntegrationTest { ); } + @Test + public void pkWithNotMatchingFunctionalDefault() { + assertThrowsSqlException( + STMT_VALIDATION_ERR, + "Functional default type mismatch: [col=ID, functionName=RAND_UUID, expectedType=UUID, actualType=STRING]", + () -> sql("create table tdd(id varchar default rand_uuid, val int, primary key (id) )") + ); + } + @Test public void undefinedColumnsInPrimaryKey() { assertThrowsSqlException(