Skip to content

Commit

Permalink
[HUDI-4427] Add a computed column IT test (apache#6150)
Browse files Browse the repository at this point in the history
  • Loading branch information
danny0405 authored and fengjian committed Apr 5, 2023
1 parent 3bb67a0 commit be2d874
Showing 1 changed file with 28 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1362,6 +1362,34 @@ void testBuiltinFunctionWithHMSCatalog() {
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
// -------------------------------------------------------------------------
Expand Down

0 comments on commit be2d874

Please sign in to comment.