Skip to content

Commit

Permalink
Make a snowflake role optional in test
Browse files Browse the repository at this point in the history
  • Loading branch information
yuokada authored and ebyhr committed Sep 27, 2024
1 parent f1a8feb commit 60a6529
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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<String> 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)
Expand All @@ -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;
}
Expand Down

0 comments on commit 60a6529

Please sign in to comment.