use of org.apache.spark.sql.execution.command.mutation.merge.UpdateAction in project carbondata by apache.
the class CarbonAntlrSqlVisitor method visitCarbonAssignmentList.
public MergeAction visitCarbonAssignmentList(CarbonSqlBaseParser.AssignmentListContext ctx) throws MalformedCarbonCommandException {
// UPDATE SET assignmentList
Map<Column, Column> map = new HashMap<>();
for (int currIdx = 0; currIdx < ctx.getChildCount(); currIdx++) {
if (ctx.getChild(currIdx) instanceof CarbonSqlBaseParser.AssignmentContext) {
// Assume the actions are all use to pass value
String left = ctx.getChild(currIdx).getChild(0).getText();
if (left.split("\\.").length > 1) {
left = left.split("\\.")[1];
}
String right = ctx.getChild(currIdx).getChild(2).getText();
Column rightColumn = null;
try {
Expression expression = sparkParser.parseExpression(right);
rightColumn = new Column(expression);
} catch (Exception e) {
throw new MalformedCarbonCommandException("Parse failed: " + e.getMessage());
}
map.put(new Column(left), rightColumn);
}
}
return new UpdateAction(SparkUtil.convertMap(map), false);
}
Aggregations