|
21 | 21 | import org.apache.flink.table.data.DecimalData;
|
22 | 22 | import org.apache.flink.table.data.GenericArrayData;
|
23 | 23 | import org.apache.flink.table.data.GenericMapData;
|
| 24 | +import org.apache.flink.table.data.GenericRowData; |
24 | 25 | import org.apache.flink.table.data.MapData;
|
| 26 | +import org.apache.flink.table.data.RowData; |
25 | 27 | import org.apache.flink.table.data.StringData;
|
26 | 28 | import org.apache.flink.table.data.TimestampData;
|
27 | 29 | import org.apache.flink.table.types.logical.ArrayType;
|
28 | 30 | import org.apache.flink.table.types.logical.DecimalType;
|
29 | 31 | import org.apache.flink.table.types.logical.LogicalType;
|
30 | 32 | import org.apache.flink.table.types.logical.MapType;
|
| 33 | +import org.apache.flink.table.types.logical.RowType; |
31 | 34 |
|
32 | 35 | import com.clickhouse.data.value.UnsignedByte;
|
33 | 36 | import com.clickhouse.data.value.UnsignedInteger;
|
|
46 | 49 | import java.time.LocalDateTime;
|
47 | 50 | import java.time.LocalTime;
|
48 | 51 | import java.time.OffsetDateTime;
|
| 52 | +import java.util.ArrayList; |
49 | 53 | import java.util.HashMap;
|
| 54 | +import java.util.List; |
50 | 55 | import java.util.Map;
|
51 | 56 | import java.util.UUID;
|
52 | 57 |
|
@@ -119,9 +124,18 @@ public static Object toExternal(Object value, LogicalType type) {
|
119 | 124 | toExternal(valueGetter.getElementOrNull(valueArrayData, i), valueType));
|
120 | 125 | }
|
121 | 126 | return objectMap;
|
122 |
| - case MULTISET: |
123 | 127 | case ROW:
|
| 128 | + List<Object> result = new ArrayList<>(); |
| 129 | + for (int i = 0; i < ((RowData) value).getArity(); i++) { |
| 130 | + result.add( |
| 131 | + toExternal( |
| 132 | + RowData.createFieldGetter(((RowType) type).getTypeAt(i), i) |
| 133 | + .getFieldOrNull((RowData) value), |
| 134 | + ((RowType) type).getTypeAt(i))); |
| 135 | + } |
| 136 | + return result; |
124 | 137 | case RAW:
|
| 138 | + case MULTISET: |
125 | 139 | default:
|
126 | 140 | throw new UnsupportedOperationException("Unsupported type:" + type);
|
127 | 141 | }
|
@@ -209,6 +223,12 @@ public static Object toInternal(Object value, LogicalType type) throws SQLExcept
|
209 | 223 | }
|
210 | 224 | return new GenericMapData(internalMap);
|
211 | 225 | case ROW:
|
| 226 | + List<Object> row = (List<Object>) value; |
| 227 | + GenericRowData rowData = new GenericRowData(row.size()); |
| 228 | + for (int i = 0; i < row.size(); i++) { |
| 229 | + rowData.setField(i, toInternal(row.get(i), type.getChildren().get(i))); |
| 230 | + } |
| 231 | + return rowData; |
212 | 232 | case MULTISET:
|
213 | 233 | case RAW:
|
214 | 234 | default:
|
|
0 commit comments