hailin0 commented on code in PR #6484:
URL: https://github.com/apache/seatunnel/pull/6484#discussion_r1524897155
##########
seatunnel-transforms-v2/src/main/java/org/apache/seatunnel/transform/sql/zeta/ZetaSQLFunction.java:
##########
@@ -199,8 +202,33 @@ public Object computeForValue(Expression expression,
Object[] inputFields) {
return ((StringValue) expression).getValue();
}
if (expression instanceof Column) {
- int idx = inputRowType.indexOf(((Column)
expression).getColumnName());
- return inputFields[idx];
+ Column columnExp = (Column) expression;
+ String columnName = columnExp.getColumnName();
+ int index = inputRowType.indexOf(columnName, false);
+ if (index != -1) {
+ return inputFields[index];
+ } else {
+ String fullyQualifiedName = columnExp.getFullyQualifiedName();
+ String[] columnNames = fullyQualifiedName.split("\\.");
+ int deep = columnNames.length;
+ SeaTunnelDataType parDataType = inputRowType;
+ SeaTunnelRow parRowValues = new SeaTunnelRow(inputFields);
+ Object res = parRowValues;
+ for (int i = 0; i < deep; i++) {
+ if (parDataType instanceof MapType) {
+ return ((Map) res).get(columnNames[i]);
+ }
+ parRowValues = (SeaTunnelRow) res;
+ int idx = ((SeaTunnelRowType)
parDataType).indexOf(columnNames[i], false);
+ if (idx == -1) {
+ throw new IllegalArgumentException(
+ String.format("can't find field [%s]",
fullyQualifiedName));
+ }
+ parDataType = ((SeaTunnelRowType)
parDataType).getFieldType(idx);
+ res = parRowValues.getFields()[idx];
Review Comment:
i agree with @Hisoka-X
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]