From 322638512418eb454d3dc78f0866399f466825eb Mon Sep 17 00:00:00 2001 From: Yukihiro Okada Date: Thu, 26 Sep 2024 18:54:12 +0900 Subject: [PATCH] Make a snowflake role optional in test --- .../java/io/trino/plugin/snowflake/SnowflakeQueryRunner.java | 5 +++-- .../io/trino/plugin/snowflake/TestingSnowflakeServer.java | 5 +++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/plugin/trino-snowflake/src/test/java/io/trino/plugin/snowflake/SnowflakeQueryRunner.java b/plugin/trino-snowflake/src/test/java/io/trino/plugin/snowflake/SnowflakeQueryRunner.java index 97bca10337d4f..d9155bfc80c21 100644 --- a/plugin/trino-snowflake/src/test/java/io/trino/plugin/snowflake/SnowflakeQueryRunner.java +++ b/plugin/trino-snowflake/src/test/java/io/trino/plugin/snowflake/SnowflakeQueryRunner.java @@ -38,13 +38,14 @@ private SnowflakeQueryRunner() {} public static Builder builder() { - return new Builder() + Builder builder = new Builder() .addConnectorProperty("connection-url", TestingSnowflakeServer.TEST_URL) .addConnectorProperty("connection-user", TestingSnowflakeServer.TEST_USER) .addConnectorProperty("connection-password", TestingSnowflakeServer.TEST_PASSWORD) .addConnectorProperty("snowflake.database", TestingSnowflakeServer.TEST_DATABASE) - .addConnectorProperty("snowflake.role", TestingSnowflakeServer.TEST_ROLE) .addConnectorProperty("snowflake.warehouse", TestingSnowflakeServer.TEST_WAREHOUSE); + TestingSnowflakeServer.TEST_ROLE.ifPresent(role -> builder.addConnectorProperty("snowflake.role", role)); + return builder; } public static final class Builder diff --git a/plugin/trino-snowflake/src/test/java/io/trino/plugin/snowflake/TestingSnowflakeServer.java b/plugin/trino-snowflake/src/test/java/io/trino/plugin/snowflake/TestingSnowflakeServer.java index 07c5acabb2614..c67174c83c082 100644 --- a/plugin/trino-snowflake/src/test/java/io/trino/plugin/snowflake/TestingSnowflakeServer.java +++ b/plugin/trino-snowflake/src/test/java/io/trino/plugin/snowflake/TestingSnowflakeServer.java @@ -19,6 +19,7 @@ import java.sql.DriverManager; import java.sql.SQLException; import java.sql.Statement; +import java.util.Optional; import java.util.Properties; import static io.trino.plugin.snowflake.SnowflakeClientModule.setOutputProperties; @@ -33,7 +34,7 @@ private TestingSnowflakeServer() {} public static final String TEST_PASSWORD = requiredNonEmptySystemProperty("snowflake.test.server.password"); public static final String TEST_DATABASE = requiredNonEmptySystemProperty("snowflake.test.server.database"); public static final String TEST_WAREHOUSE = requiredNonEmptySystemProperty("snowflake.test.server.warehouse"); - public static final String TEST_ROLE = requiredNonEmptySystemProperty("snowflake.test.server.role"); + public static final Optional TEST_ROLE = Optional.ofNullable(System.getProperty("snowflake.test.server.role")); public static final String TEST_SCHEMA = "tpch"; public static void execute(@Language("SQL") String sql) @@ -60,7 +61,7 @@ private static Properties getProperties() properties.setProperty("db", TEST_DATABASE); properties.setProperty("schema", TEST_SCHEMA); properties.setProperty("warehouse", TEST_WAREHOUSE); - properties.setProperty("role", TEST_ROLE); + TEST_ROLE.ifPresent(role -> properties.setProperty("role", role)); setOutputProperties(properties); return properties; }