You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hudi.apache.org by da...@apache.org on 2022/07/21 01:38:32 UTC
[hudi] branch master updated: [HUDI-4427] Add a computed column IT test (#6150)
This is an automated email from the ASF dual-hosted git repository.
danny0405 pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/hudi.git
The following commit(s) were added to refs/heads/master by this push:
new 348519f3cd [HUDI-4427] Add a computed column IT test (#6150)
348519f3cd is described below
commit 348519f3cde1fba7a3c22f259f19ac6563f4db03
Author: Danny Chan <yu...@gmail.com>
AuthorDate: Thu Jul 21 09:38:26 2022 +0800
[HUDI-4427] Add a computed column IT test (#6150)
---
.../apache/hudi/table/ITTestHoodieDataSource.java | 28 ++++++++++++++++++++++
1 file changed, 28 insertions(+)
diff --git a/hudi-flink-datasource/hudi-flink/src/test/java/org/apache/hudi/table/ITTestHoodieDataSource.java b/hudi-flink-datasource/hudi-flink/src/test/java/org/apache/hudi/table/ITTestHoodieDataSource.java
index 44d300f555..fb9f55986d 100644
--- a/hudi-flink-datasource/hudi-flink/src/test/java/org/apache/hudi/table/ITTestHoodieDataSource.java
+++ b/hudi-flink-datasource/hudi-flink/src/test/java/org/apache/hudi/table/ITTestHoodieDataSource.java
@@ -1362,6 +1362,34 @@ public class ITTestHoodieDataSource extends AbstractTestBase {
assertRowsEquals(partitionResult, "[+I[1, 2022-02-02, 1]]");
}
+ @Test
+ void testWriteReadWithComputedColumns() {
+ TableEnvironment tableEnv = batchTableEnv;
+ String createTable = sql("t1")
+ .field("f0 int")
+ .field("f1 varchar(10)")
+ .field("f2 bigint")
+ .field("f3 as f0 + f2")
+ .option(FlinkOptions.PATH, tempFile.getAbsolutePath())
+ .option(FlinkOptions.PRECOMBINE_FIELD, "f1")
+ .pkField("f0")
+ .noPartition()
+ .end();
+ tableEnv.executeSql(createTable);
+
+ String insertInto = "insert into t1 values\n"
+ + "(1, 'abc', 2)";
+ execInsertSql(tableEnv, insertInto);
+
+ List<Row> result1 = CollectionUtil.iterableToList(
+ () -> tableEnv.sqlQuery("select * from t1").execute().collect());
+ assertRowsEquals(result1, "[+I[1, abc, 2, 3]]");
+
+ List<Row> result2 = CollectionUtil.iterableToList(
+ () -> tableEnv.sqlQuery("select f3 from t1").execute().collect());
+ assertRowsEquals(result2, "[+I[3]]");
+ }
+
// -------------------------------------------------------------------------
// Utilities
// -------------------------------------------------------------------------