-
Notifications
You must be signed in to change notification settings - Fork 123
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
VerifyBlocking PR #1001
base: main
Are you sure you want to change the base?
VerifyBlocking PR #1001
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
package zingg.common.client.util; | ||
|
||
public class PathUtil { | ||
|
||
public static String getSparkLocationFromPath(String name){ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. since these are spark and snow specific, it is better to move these methods to SnowPipe and SparkPipe. call them massageLocation/massageTableName. define method setLocation in spark and call the massageLocation in it. Use setLocation whever we are calling SparkPipe.setLocation. Similarly for Snow. |
||
name = name.replaceAll("-", ""); | ||
name = name.replaceAll("@",""); | ||
name = name.replaceAll(",",""); | ||
return name; | ||
} | ||
|
||
public static String getSnowTableFromPath(String name){ | ||
name = name.replaceAll("/", "_"); | ||
name = name.replaceAll("-", ""); | ||
name = name.replaceAll("@",""); | ||
name = name.replaceAll(",",""); | ||
return name; | ||
} | ||
|
||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
package zingg.common.client.util; | ||
|
||
import static org.junit.jupiter.api.Assertions.assertEquals; | ||
|
||
import org.junit.jupiter.api.Test; | ||
|
||
public class TestPathUtil { | ||
|
||
@Test | ||
public void testGetSparkLocationFromPath(){ | ||
String input1 = "zingg/spark/model/blocks/-1111"; | ||
String input2 = "zingg/spark/model/blocks/@11_1,1"; | ||
String exp1 = "zingg/spark/model/blocks/1111"; | ||
String exp2 = "zingg/spark/model/blocks/11_11"; | ||
assertEquals(exp1, PathUtil.getSparkLocationFromPath(input1)); | ||
assertEquals(exp2, PathUtil.getSparkLocationFromPath(input2)); | ||
} | ||
|
||
@Test | ||
public void testGetSnowTableFromPath(){ | ||
String input1 = "zingg_snowflake_model_blocks_-1111"; | ||
String input2 = "zingg/snowflake/model/blocks/-111,1"; | ||
String exp1 = "zingg_snowflake_model_blocks_1111"; | ||
String exp2 = "zingg_snowflake_model_blocks_1111"; | ||
assertEquals(exp1, PathUtil.getSnowTableFromPath(input1)); | ||
assertEquals(exp2, PathUtil.getSnowTableFromPath(input2)); | ||
} | ||
|
||
} |
Check warning
Code scanning / PMD
This utility class has a non-private constructor Warning