Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[SEDONA-541] Allow concurrent snowflake testers: PR 2/2 #1358

Merged
merged 6 commits into from
Apr 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,6 @@ public static SnowClient newFromEnv() throws SQLException {
prop.put("user", System.getenv("SNOWFLAKE_USER"));
prop.put("password", System.getenv("SNOWFLAKE_PASSWORD"));
}
prop.put("db", System.getenv("SNOWFLAKE_DB"));
prop.put("schema", System.getenv("SNOWFLAKE_SCHEMA"));
prop.put("warehouse", System.getenv("SNOWFLAKE_WAREHOUSE"));
prop.put("role", System.getenv("SNOWFLAKE_ROLE"));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,15 +54,14 @@ public class TestBase extends TestCase {

private static boolean jarUploaded = false;

String snowflake_db_name = generateRandomString(8);
private static String snowflake_db_name = null;

public void registerUDF(String functionName, Class<?> ... paramTypes) {
try {
String ddl = UDFDDLGenerator.buildUDFDDL(UDFs.class.getMethod(
functionName,
paramTypes
), buildDDLConfigs, "@ApacheSedona", false, "");
System.out.println(ddl);
ResultSet res = snowClient.executeQuery(ddl);
res.next();
assert res.getString(1).contains("successfully created");
Expand All @@ -77,7 +76,6 @@ public void registerUDFV2(String functionName, Class<?> ... paramTypes) {
functionName,
paramTypes
), buildDDLConfigs, "@ApacheSedona", false, "");
System.out.println(ddl);
ResultSet res = snowClient.executeQuery(ddl);
res.next();
assert res.getString(1).contains("successfully created");
Expand All @@ -89,7 +87,6 @@ public void registerUDFV2(String functionName, Class<?> ... paramTypes) {
public void registerUDTF(Class<?> clz) {
try {
String ddl = UDTFDDLGenerator.buildUDTFDDL(clz, buildDDLConfigs, "@ApacheSedona", false, "");
System.out.println(ddl);
ResultSet res = snowClient.executeQuery(ddl);
res.next();
assert res.getString(1).contains("successfully created");
Expand All @@ -109,6 +106,8 @@ public void init() throws SQLException {
System.out.println("Using Snowflake DB: " + snowflake_db_name);
// upload libraries
if (!jarUploaded) {
snowflake_db_name = "TMP_TESTDB_" + generateRandomString(8);
System.out.println("Creating Snowflake DB: " + snowflake_db_name);
// drop then create db to make sure test env fresh
snowClient.executeQuery("drop database if exists " + snowflake_db_name);
snowClient.executeQuery("create database " + snowflake_db_name);
Expand All @@ -120,6 +119,11 @@ public void init() throws SQLException {
snowClient.uploadFile(String.format("tmp/geotools-wrapper-%s.jar", geotoolsVersion), "ApacheSedona");
jarUploaded = true;
}
else {
System.out.println("Using Snowflake DB: " + snowflake_db_name);
snowClient.executeQuery("use database " + snowflake_db_name);
snowClient.executeQuery("use schema " + System.getenv("SNOWFLAKE_SCHEMA"));
}
registerDependantUDFs();
}

Expand All @@ -128,6 +132,7 @@ public void tearDown()
try {
System.out.println("Dropping Snowflake DB: " + snowflake_db_name);
snowClient.executeQuery("drop database if exists " + snowflake_db_name);
jarUploaded = false;
}
catch (SQLException e) {
throw new RuntimeException(e);
Expand Down
Loading