From aa8f8399066475b1a2805ff06d70acb2b8716515 Mon Sep 17 00:00:00 2001 From: Sandeep Thandassery Date: Mon, 30 Dec 2024 21:42:37 -0600 Subject: [PATCH] Cast table properties based on its type in Faker connector --- .../main/java/io/trino/plugin/faker/FakerMetadata.java | 3 ++- .../java/io/trino/plugin/faker/TestFakerQueries.java | 10 ++++++++++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/plugin/trino-faker/src/main/java/io/trino/plugin/faker/FakerMetadata.java b/plugin/trino-faker/src/main/java/io/trino/plugin/faker/FakerMetadata.java index 46d246e9d8d0..8dbcacb58195 100644 --- a/plugin/trino-faker/src/main/java/io/trino/plugin/faker/FakerMetadata.java +++ b/plugin/trino-faker/src/main/java/io/trino/plugin/faker/FakerMetadata.java @@ -262,7 +262,8 @@ public synchronized void setTableProperties(ConnectorSession session, ConnectorT oldInfo.properties().entrySet().stream() .filter(entry -> !properties.containsKey(entry.getKey())), properties.entrySet().stream() - .filter(entry -> entry.getValue().isPresent())) + .filter(entry -> entry.getValue().isPresent()) + .map(entry -> Map.entry(entry.getKey(), entry.getValue().get()))) .collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue)); tables.put(tableName, oldInfo.withProperties(newProperties)); } diff --git a/plugin/trino-faker/src/test/java/io/trino/plugin/faker/TestFakerQueries.java b/plugin/trino-faker/src/test/java/io/trino/plugin/faker/TestFakerQueries.java index e20ab53af8f8..c35687e45c27 100644 --- a/plugin/trino-faker/src/test/java/io/trino/plugin/faker/TestFakerQueries.java +++ b/plugin/trino-faker/src/test/java/io/trino/plugin/faker/TestFakerQueries.java @@ -447,4 +447,14 @@ String columnSchema() return "%s %s NOT NULL%s".formatted(name, type, propertiesSchema.isEmpty() ? "" : " WITH (%s)".formatted(propertiesSchema)); } } + + @Test + void testSetTableProperties() + { + try (TestTable table = newTrinoTable("set_table_properties", "(id INTEGER, name VARCHAR)")) { + assertUpdate("ALTER TABLE " + table.getName() + " SET PROPERTIES default_limit = 100"); + assertThat((String) computeScalar("SHOW CREATE TABLE " + table.getName())) + .contains("default_limit = 100"); + } + } }