Skip to content

Commit

Permalink
Address Szehon feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
dramaticlly committed Jan 23, 2025
1 parent 1a156e2 commit d43a28f
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ public void testRewriteTablePathWithPositionalArgument() {
.as("Should return correct latest version")
.isEqualTo(RewriteTablePathUtil.fileName(metadataJson));
assertThat(result.get(0)[1])
.as("Should return files_list_location")
.as("Should return file_list_location")
.asString()
.startsWith(table.location())
.endsWith("file-list");
Expand All @@ -88,8 +88,8 @@ public void testRewriteTablePathWithNamedArgument() {
sql(
"CALL %s.system.rewrite_table_path("
+ "table => '%s', "
+ "target_location_prefix => '%s', "
+ "source_location_prefix => '%s', "
+ "target_prefix => '%s', "
+ "source_prefix => '%s', "
+ "end_version => '%s', "
+ "start_version => '%s', "
+ "staging_location => '%s')",
Expand All @@ -103,7 +103,7 @@ public void testRewriteTablePathWithNamedArgument() {
assertThat(result).hasSize(1);
assertThat(result.get(0)[0]).as("Should return correct latest version").isEqualTo(v1Metadata);
assertThat(result.get(0)[1])
.as("Should return correct files_list_location")
.as("Should return correct file_list_location")
.isEqualTo(expectedFileListLocation);
checkFileListLocationCount((String) result.get(0)[1], 4);
}
Expand All @@ -115,15 +115,14 @@ public void testProcedureWithInvalidInput() {
assertThatThrownBy(
() -> sql("CALL %s.system.rewrite_table_path('%s')", catalogName, tableIdent))
.isInstanceOf(AnalysisException.class)
.hasMessageContaining(
"Missing required parameters: [source_location_prefix,target_location_prefix]");
.hasMessageContaining("Missing required parameters: [source_prefix,target_prefix]");
assertThatThrownBy(
() ->
sql(
"CALL %s.system.rewrite_table_path('%s','%s')",
catalogName, tableIdent, targetLocation))
.isInstanceOf(AnalysisException.class)
.hasMessageContaining("Missing required parameters: [target_location_prefix]");
.hasMessageContaining("Missing required parameters: [target_prefix]");
assertThatThrownBy(
() ->
sql(
Expand All @@ -141,8 +140,8 @@ public void testProcedureWithInvalidInput() {
sql(
"CALL %s.system.rewrite_table_path("
+ "table => '%s', "
+ "source_location_prefix => '%s', "
+ "target_location_prefix => '%s', "
+ "source_prefix => '%s', "
+ "target_prefix => '%s', "
+ "start_version => '%s')",
catalogName, tableIdent, table.location(), targetLocation, "v20.metadata.json"))
.isInstanceOf(IllegalArgumentException.class)
Expand All @@ -153,8 +152,8 @@ public void testProcedureWithInvalidInput() {
sql(
"CALL %s.system.rewrite_table_path("
+ "table => '%s', "
+ "source_location_prefix => '%s', "
+ "target_location_prefix => '%s', "
+ "source_prefix => '%s', "
+ "target_prefix => '%s', "
+ "start_version => '%s',"
+ "end_version => '%s')",
catalogName,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,10 @@ public class RewriteTablePathProcedure extends BaseProcedure {

private static final ProcedureParameter TABLE_PARAM =
ProcedureParameter.required("table", DataTypes.StringType);
private static final ProcedureParameter SOURCE_LOCATION_PARAM =
ProcedureParameter.required("source_location_prefix", DataTypes.StringType);
private static final ProcedureParameter TARGET_LOCATION_PARAM =
ProcedureParameter.required("target_location_prefix", DataTypes.StringType);
private static final ProcedureParameter SOURCE_PREFIX_PARAM =
ProcedureParameter.required("source_prefix", DataTypes.StringType);
private static final ProcedureParameter TARGET_PREFIX_PARAM =
ProcedureParameter.required("target_prefix", DataTypes.StringType);
private static final ProcedureParameter START_VERSION_PARAM =
ProcedureParameter.optional("start_version", DataTypes.StringType);
private static final ProcedureParameter END_VERSION_PARM =
Expand All @@ -49,8 +49,8 @@ public class RewriteTablePathProcedure extends BaseProcedure {
private static final ProcedureParameter[] PARAMETERS =
new ProcedureParameter[] {
TABLE_PARAM,
SOURCE_LOCATION_PARAM,
TARGET_LOCATION_PARAM,
SOURCE_PREFIX_PARAM,
TARGET_PREFIX_PARAM,
START_VERSION_PARAM,
END_VERSION_PARM,
STAGING_LOCATION_PARAM
Expand All @@ -60,7 +60,7 @@ public class RewriteTablePathProcedure extends BaseProcedure {
new StructType(
new StructField[] {
new StructField("latest_version", DataTypes.StringType, true, Metadata.empty()),
new StructField("files_list_location", DataTypes.StringType, true, Metadata.empty())
new StructField("file_list_location", DataTypes.StringType, true, Metadata.empty())
});

public static SparkProcedures.ProcedureBuilder builder() {
Expand Down Expand Up @@ -90,8 +90,8 @@ public StructType outputType() {
public InternalRow[] call(InternalRow args) {
ProcedureInput input = new ProcedureInput(spark(), tableCatalog(), PARAMETERS, args);
Identifier tableIdent = input.ident(TABLE_PARAM);
String sourcePrefix = input.asString(SOURCE_LOCATION_PARAM);
String targetPrefix = input.asString(TARGET_LOCATION_PARAM);
String sourcePrefix = input.asString(SOURCE_PREFIX_PARAM);
String targetPrefix = input.asString(TARGET_PREFIX_PARAM);
String startVersion = input.asString(START_VERSION_PARAM, null);
String endVersion = input.asString(END_VERSION_PARM, null);
String stagingLocation = input.asString(STAGING_LOCATION_PARAM, null);
Expand Down

0 comments on commit d43a28f

Please sign in to comment.