You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@flink.apache.org by sn...@apache.org on 2023/08/24 06:53:13 UTC
[flink] branch release-1.18 updated: [FLINK-32296][table] Support cast of collections with row element types
This is an automated email from the ASF dual-hosted git repository.
snuyanzin pushed a commit to branch release-1.18
in repository https://gitbox.apache.org/repos/asf/flink.git
The following commit(s) were added to refs/heads/release-1.18 by this push:
new 8715f0a1e8c [FLINK-32296][table] Support cast of collections with row element types
8715f0a1e8c is described below
commit 8715f0a1e8c3bb6595d26c69ef4ef246486d187d
Author: Sergey Nuyanzin <sn...@gmail.com>
AuthorDate: Thu Aug 24 08:53:05 2023 +0200
[FLINK-32296][table] Support cast of collections with row element types
---
.../table/planner/functions/casting/RowToRowCastRule.java | 3 ++-
.../flink/table/planner/functions/CastFunctionITCase.java | 12 ++++++++++++
2 files changed, 14 insertions(+), 1 deletion(-)
diff --git a/flink-table/flink-table-planner/src/main/java/org/apache/flink/table/planner/functions/casting/RowToRowCastRule.java b/flink-table/flink-table-planner/src/main/java/org/apache/flink/table/planner/functions/casting/RowToRowCastRule.java
index 323bd7a4712..a4682529404 100644
--- a/flink-table/flink-table-planner/src/main/java/org/apache/flink/table/planner/functions/casting/RowToRowCastRule.java
+++ b/flink-table/flink-table-planner/src/main/java/org/apache/flink/table/planner/functions/casting/RowToRowCastRule.java
@@ -221,7 +221,8 @@ class RowToRowCastRule extends AbstractNullAwareCodeGeneratorCastRule<RowData, R
elseBodyWriter.stmt(writeNull));
}
- writer.stmt(methodCall(writerTerm, "complete")).assignStmt(returnVariable, rowTerm);
+ writer.stmt(methodCall(writerTerm, "complete"))
+ .assignStmt(returnVariable, methodCall(rowTerm, "copy"));
return writer.toString();
}
diff --git a/flink-table/flink-table-planner/src/test/java/org/apache/flink/table/planner/functions/CastFunctionITCase.java b/flink-table/flink-table-planner/src/test/java/org/apache/flink/table/planner/functions/CastFunctionITCase.java
index 897b6feff9b..048890ece7f 100644
--- a/flink-table/flink-table-planner/src/test/java/org/apache/flink/table/planner/functions/CastFunctionITCase.java
+++ b/flink-table/flink-table-planner/src/test/java/org/apache/flink/table/planner/functions/CastFunctionITCase.java
@@ -1212,6 +1212,18 @@ public class CastFunctionITCase extends BuiltInFunctionTestBase {
CastTestSpecBuilder.testCastTo(ARRAY(BIGINT().notNull()))
.fromCase(ARRAY(INT().notNull()), new Integer[] {1, 2}, new long[] {1L, 2L})
.build(),
+ CastTestSpecBuilder.testCastTo(ARRAY(ROW(INT(), STRING()).notNull()))
+ .fromCase(
+ ARRAY(ROW(INT(), VARCHAR(4)).notNull()),
+ new Row[] {Row.of(1, "two"), Row.of(3, "four")},
+ new Row[] {Row.of(1, "two"), Row.of(3, "four")})
+ .build(),
+ CastTestSpecBuilder.testCastTo(MAP(ROW(INT()), STRING()))
+ .fromCase(
+ MAP(ROW(INT()), VARCHAR(4)),
+ map(entry(Row.of(1), "two"), entry(Row.of(3), "four")),
+ map(entry(Row.of(1), "two"), entry(Row.of(3), "four")))
+ .build(),
CastTestSpecBuilder.testCastTo(ROW(BIGINT(), BIGINT(), STRING(), ARRAY(STRING())))
.fromCase(
ROW(INT(), INT(), TIME(), ARRAY(CHAR(1))),