shuiqiangchen commented on a change in pull request #12902:
URL: https://github.com/apache/flink/pull/12902#discussion_r505124256
##########
File path:
flink-python/src/main/java/org/apache/flink/api/common/python/PythonBridgeUtils.java
##########
@@ -162,7 +171,42 @@
return objs;
}
+ private static List<byte[]> getPickledBytesFromRow(Row row,
LogicalType[] dataTypes) throws IOException {
+ List<byte[]> pickledRowBytes = new ArrayList<>(row.getArity());
+ Pickler pickler = new Pickler();
+ for (int i = 0; i < row.getArity(); i++) {
+ Object fieldData = row.getField(i);
+ if (fieldData == null) {
+ pickledRowBytes.add(new byte[0]);
+ } else {
+ if (dataTypes[i] instanceof DateType) {
+ long time = ((Date)
fieldData).toLocalDate().toEpochDay();
+
pickledRowBytes.add(pickler.dumps(time));
+ } else if (dataTypes[i] instanceof TimeType) {
+ long time = ((Time)
fieldData).toLocalTime().toNanoOfDay();
+ time = time / 1000;
+
pickledRowBytes.add(pickler.dumps(time));
+ } else if (dataTypes[i] instanceof RowType) {
+ Row tmpRow = (Row) fieldData;
+ LogicalType[] tmpRowFieldTypes = new
LogicalType[tmpRow.getArity()];
+ ((RowType)
dataTypes[i]).getChildren().toArray(tmpRowFieldTypes);
+ List<byte[]> rowFieldBytes =
getPickledBytesFromRow(tmpRow, tmpRowFieldTypes);
+
pickledRowBytes.add(pickler.dumps(rowFieldBytes));
+ } else {
+
pickledRowBytes.add(pickler.dumps(row.getField(i)));
Review comment:
These types are supported and could be directly serialized by pickled
without any special processing, unlike Row/SQL_TIME/SQL_DATE,etc. types
----------------------------------------------------------------
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.
For queries about this service, please contact Infrastructure at:
[email protected]