sunjincheng121 commented on a change in pull request #8057: [FLINK-12028][table] Add `addColumns`,`renameColumns`, `dropColumns` … URL: https://github.com/apache/flink/pull/8057#discussion_r269872958
########## File path: flink-table/flink-table-planner/src/test/scala/org/apache/flink/table/api/stream/table/validation/CalcValidationTest.scala ########## @@ -46,4 +47,88 @@ class CalcValidationTest extends TableTestBase { .groupBy('w) .select('w.end.rowtime, 'int.count as 'int) // no rowtime on non-window reference } + + @Test + def testAddColumns(): Unit = { + val util = streamTestUtil() + val tab = util.addTable[(Int, Long, String)]("Table3",'a, 'b, 'c) + + // Test aggregates + try { + tab.addColumns('a.sum) + fail("TableException expected") + } catch { + case _: TableException => //ignore + } + + // Test replace the existing column, but do not with the alias. + try { + tab.addColumns(true, concat('c, "Sunny")) + fail("TableException expected") + } catch { + case _: TableException => //ignore + } + + } + + @Test + def testRenameColumns(): Unit = { + val util = streamTestUtil() + val tab = util.addTable[(Int, Long, String)]("Table3",'a, 'b, 'c) + + // Test aggregates + try { + tab.renameColumns('a.sum) + fail("TableException expected") + } catch { + case _: TableException => //ignore + } + + // Test without alias case. + try { + tab.renameColumns('a) + fail("TableException expected") + } catch { + case _: TableException => //ignore + } + + // Test for fields that do not exist + try { + tab.renameColumns('e) Review comment: I think line 97 has test the field which not exist case. but i should add the alias. what do you think? ---------------------------------------------------------------- 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: us...@infra.apache.org With regards, Apache Git Services