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

VerifyBlocking PR #1001

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
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
20 changes: 20 additions & 0 deletions common/client/src/main/java/zingg/common/client/util/PathUtil.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
package zingg.common.client.util;

public class PathUtil {

Check warning

Code scanning / PMD

This utility class has a non-private constructor Warning

This utility class has a non-private constructor

public static String getSparkLocationFromPath(String name){
Copy link
Member

Choose a reason for hiding this comment

The 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));
}

}
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package zingg.spark.core.executor;

import org.apache.spark.internal.config.R;
import org.apache.spark.sql.Column;
import org.apache.spark.sql.Dataset;
import org.apache.spark.sql.Row;
Expand All @@ -10,6 +9,7 @@
import zingg.common.client.pipe.FilePipe;
import zingg.common.client.pipe.Pipe;
import zingg.common.client.util.IModelHelper;
import zingg.common.client.util.PathUtil;
import zingg.common.client.util.PipeUtilBase;
import zingg.common.core.executor.blockingverifier.VerifyBlockingPipes;
import zingg.spark.client.pipe.SparkPipe;
Expand All @@ -24,7 +24,8 @@ public SparkVerifyBlockingPipes(PipeUtilBase<SparkSession,Dataset<Row>,Row,Colum
public Pipe<Dataset<Row>,Row,Column> getPipeForVerifyBlockingLocation(IArguments args, String type){
SparkPipe p = new SparkPipe();
p.setFormat(Pipe.FORMAT_PARQUET);
p.setProp(FilePipe.LOCATION, getName(args,timestamp,type));
String name = getName(args,timestamp,type);
p.setProp(FilePipe.LOCATION, PathUtil.getSparkLocationFromPath(name));
p.setOverwriteMode();
return p;
}
Expand Down
Loading