Skip to content

Commit

Permalink
Remove extra function
Browse files Browse the repository at this point in the history
  • Loading branch information
shrverma committed Aug 1, 2023
1 parent ed0e9a4 commit bec9679
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -115,11 +115,9 @@ public Relation transform(RelationalTranformContext relationalTranformContext,
if (!expressionFactory.isPresent()) {
return new InvalidRelation("Cannot find an Expression Factory");
}
String getColumnString = String.join(",", columns);
return relation.setColumn(targetColumn, expressionFactory.get().compile(String
.format("struct(%s)", getColumnString(columns))));
.format("struct(%s)", getColumnString)));
}

public String getColumnString(String[] columns) {
return String.join(",", columns);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -167,12 +167,13 @@ public Relation transform(RelationalTranformContext relationalTranformContext,
int columncounter = 1;

for (int width : widths) {
String fixedLengthParseExpression = String.format("replace(substr(%s, %d, %d), '%s', \"\")",
col, currentpos, width, padding);
String filterExcessLengthExpression = String.format("%d <= (length(%s) - %d + 1)", width, col, currentpos);

relation = relation.setColumn(String.format("%s_%d", col, columncounter),
expressionFactory.get().compile(String
.format("replace(substr(%s, %d, %d), '%s', \"\")"
, col, currentpos, width, padding)))
.filter(expressionFactory.get().compile(String.format("%d <= (length(%s) - %d + 1)",
width, col, currentpos)));
expressionFactory.get().compile(fixedLengthParseExpression))
.filter(expressionFactory.get().compile(filterExcessLengthExpression));

currentpos += width;
columncounter++;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -129,9 +129,9 @@ public Relation transform(RelationalTranformContext relationalTranformContext,
if (!expressionFactory.isPresent()) {
return new InvalidRelation("Cannot find an Expression Factory");
}
return relation.setColumn(
column, expressionFactory.get()
.compile(String.format("struct(%s)", String.join(",", columns))));
String getColumnString = String.join(",", columns);
return relation.setColumn(column, expressionFactory.get()
.compile(String.format("struct(%s)", getColumnString)));
}

}

0 comments on commit bec9679

Please sign in to comment.