-
Notifications
You must be signed in to change notification settings - Fork 56
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
Partially supported directives #655
base: relational-directives
Are you sure you want to change the base?
Conversation
@@ -105,4 +109,19 @@ public static String getColumnTypeExp(String toType, String column, @Nullable In | |||
return column; | |||
} | |||
} | |||
|
|||
public static List<String> generateListCols(RelationalTranformContext relationalTranformContext) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can rename to generateColumnList or generateColumnNameList
IntStream.range(0, Math.min(columnNames.size(), columns.size())) | ||
.forEach(i -> columnExpMap.put(columns.get(i), expressionFactory.get().compile(columnNames.get(i)))); | ||
|
||
if (columnNames.size() > columns.size()) { | ||
IntStream.range(columns.size(), columnNames.size()) | ||
.forEach(i -> columnExpMap.put(columnNames.get(i), expressionFactory.get().compile(columnNames.get(i)))); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can move to a function with a simple for loop
return relation.select(colmap); | ||
} | ||
|
||
public static Map<String, Expression> generateCleanseColumnMap(Collection columns, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
make private
if (!expressionFactory.isPresent()) { | ||
return new InvalidRelation("Cannot find an Expression Factory"); | ||
} | ||
List<String> columnNames = SqlExpressionGenerator.generateListCols(relationalTranformContext); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So this method gets the list of input columns from the transform context, which is not really related to "generating a SQL expression". I would either suggest keeping this in a different util class or you can just rename the method to getColumnList
} | ||
|
||
return relation.setColumn("tempColumn", expressionFactory.get().compile( | ||
String.format("if(%s, raise_error(\"Condition '%s' evaluated to true. " + |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can move this to a variable
wrangler-core/src/main/java/io/cdap/directives/row/RecordConditionFilter.java
Show resolved
Hide resolved
wrangler-core/src/main/java/io/cdap/directives/transformation/Decode.java
Show resolved
Hide resolved
if (!expressionFactory.isPresent()) { | ||
return new InvalidRelation("Cannot find an Expression Factory"); | ||
} | ||
if (method.toString().equalsIgnoreCase("base64")) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same as decode changes
Implements relational transform for the following directives: