You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@sedona.apache.org by ji...@apache.org on 2024/04/25 03:23:45 UTC

(sedona) branch master updated: [SEDONA-541] Allow concurrent snowflake testers: PR 2/2 (#1358)

This is an automated email from the ASF dual-hosted git repository.

jiayu pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/sedona.git


The following commit(s) were added to refs/heads/master by this push:
     new 0b083d011 [SEDONA-541] Allow concurrent snowflake testers: PR 2/2 (#1358)
0b083d011 is described below

commit 0b083d011d17818bd6f7b0b3d0dec00b215c4220
Author: Jia Yu <ji...@apache.org>
AuthorDate: Wed Apr 24 20:23:39 2024 -0700

    [SEDONA-541] Allow concurrent snowflake testers: PR 2/2 (#1358)
    
    * Use random db name
    
    * Fix the silly bug
    
    * Make sure the same database is shared among all test cases
    
    * Fix
    
    * Fix again
---
 .../org/apache/sedona/snowflake/snowsql/SnowClient.java     |  1 -
 .../java/org/apache/sedona/snowflake/snowsql/TestBase.java  | 13 +++++++++----
 2 files changed, 9 insertions(+), 5 deletions(-)

diff --git a/snowflake-tester/src/test/java/org/apache/sedona/snowflake/snowsql/SnowClient.java b/snowflake-tester/src/test/java/org/apache/sedona/snowflake/snowsql/SnowClient.java
index e0b792cef..df5f6a7f3 100644
--- a/snowflake-tester/src/test/java/org/apache/sedona/snowflake/snowsql/SnowClient.java
+++ b/snowflake-tester/src/test/java/org/apache/sedona/snowflake/snowsql/SnowClient.java
@@ -96,7 +96,6 @@ public class SnowClient {
             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"));
diff --git a/snowflake-tester/src/test/java/org/apache/sedona/snowflake/snowsql/TestBase.java b/snowflake-tester/src/test/java/org/apache/sedona/snowflake/snowsql/TestBase.java
index 53c87b879..5c830c4d6 100644
--- a/snowflake-tester/src/test/java/org/apache/sedona/snowflake/snowsql/TestBase.java
+++ b/snowflake-tester/src/test/java/org/apache/sedona/snowflake/snowsql/TestBase.java
@@ -54,7 +54,7 @@ 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 {
@@ -62,7 +62,6 @@ public class TestBase extends TestCase {
                     functionName,
                     paramTypes
             ), buildDDLConfigs, "@ApacheSedona", false, "");
-            System.out.println(ddl);
             ResultSet res = snowClient.executeQuery(ddl);
             res.next();
             assert res.getString(1).contains("successfully created");
@@ -77,7 +76,6 @@ public class TestBase extends TestCase {
                     functionName,
                     paramTypes
             ), buildDDLConfigs, "@ApacheSedona", false, "");
-            System.out.println(ddl);
             ResultSet res = snowClient.executeQuery(ddl);
             res.next();
             assert res.getString(1).contains("successfully created");
@@ -89,7 +87,6 @@ public class TestBase extends TestCase {
     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");
@@ -109,6 +106,8 @@ public class TestBase extends TestCase {
         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);
@@ -120,6 +119,11 @@ public class TestBase extends TestCase {
             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();
     }
 
@@ -128,6 +132,7 @@ public class TestBase extends TestCase {
         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);