[GitHub] [flink] wuchong commented on a change in pull request #15005: [FLINK-21298][table] Support 'USE MODULES' syntax both in SQL parser, TableEnvironment and SQL CLI

2021-02-28 Thread GitBox


wuchong commented on a change in pull request #15005:
URL: https://github.com/apache/flink/pull/15005#discussion_r584435518



##
File path: 
flink-table/flink-table-planner-blink/src/test/scala/org/apache/flink/table/api/TableEnvironmentTest.scala
##
@@ -592,6 +593,66 @@ class TableEnvironmentTest {
 tableEnv.executeSql("UNLOAD MODULE dummy")
   }
 
+  @Test
+  def testExecuteSqlWithUseModules(): Unit = {
+tableEnv.executeSql("LOAD MODULE dummy")
+assert(tableEnv.listModules().sameElements(Array[String]("core", "dummy")))

Review comment:
   `assertArrayEquals` should work in Java, but yes it's hard to use in 
Scala. Comparing array's element one by one looks messing and not readable. I 
just checked `sameElements` takes order into account. Thus, I think it's fine 
to use `sameElements` here. 





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




[GitHub] [flink] wuchong commented on a change in pull request #15005: [FLINK-21298][table] Support 'USE MODULES' syntax both in SQL parser, TableEnvironment and SQL CLI

2021-02-28 Thread GitBox


wuchong commented on a change in pull request #15005:
URL: https://github.com/apache/flink/pull/15005#discussion_r584432452



##
File path: flink-table/flink-sql-parser-hive/src/main/codegen/data/Parser.tdd
##
@@ -129,6 +130,7 @@
 "LINES"
 "LOAD"
 "LOCATION"
+"MODULES"

Review comment:
   Thanks. Then we should warn users this is a reserved keyword now. I will 
add this information into release note once PR is merged. 
   
   `The term MODULES is a reserved keyword now. Use backticks to escape column 
names and other identifiers with this name.`





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




[GitHub] [flink] wuchong commented on a change in pull request #15005: [FLINK-21298][table] Support 'USE MODULES' syntax both in SQL parser, TableEnvironment and SQL CLI

2021-02-28 Thread GitBox


wuchong commented on a change in pull request #15005:
URL: https://github.com/apache/flink/pull/15005#discussion_r584428711



##
File path: 
flink-table/flink-sql-client/src/main/java/org/apache/flink/table/client/gateway/local/LocalExecutor.java
##
@@ -428,6 +429,13 @@ public ProgramTargetDescriptor executeUpdate(String 
sessionId, String statement)
 return executeUpdateInternal(sessionId, context, statement);
 }
 
+@VisibleForTesting
+List listFullModules(String sessionId) throws 
SqlExecutionException {

Review comment:
   Thanks for the explanation. 





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




[GitHub] [flink] wuchong commented on a change in pull request #15005: [FLINK-21298][table] Support 'USE MODULES' syntax both in SQL parser, TableEnvironment and SQL CLI

2021-02-24 Thread GitBox


wuchong commented on a change in pull request #15005:
URL: https://github.com/apache/flink/pull/15005#discussion_r582530305



##
File path: 
flink-table/flink-table-planner-blink/src/main/scala/org/apache/flink/table/planner/calcite/FlinkPlannerImpl.scala
##
@@ -36,11 +35,11 @@ import org.apache.calcite.sql.validate.SqlValidator
 import org.apache.calcite.sql.{SqlExplain, SqlKind, SqlNode, SqlOperatorTable}
 import org.apache.calcite.sql2rel.{SqlRexConvertletTable, SqlToRelConverter}
 import org.apache.calcite.tools.{FrameworkConfig, RelConversionException}
+import org.apache.flink.sql.parser.ddl.SqlUseModules

Review comment:
   Please reorder the imports. 

##
File path: 
flink-table/flink-table-planner-blink/src/test/scala/org/apache/flink/table/api/TableEnvironmentTest.scala
##
@@ -33,6 +33,7 @@ import org.apache.flink.types.Row
 import org.apache.calcite.plan.RelOptUtil
 import org.apache.calcite.sql.SqlExplainLevel
 import org.apache.flink.core.testutils.FlinkMatchers.containsMessage
+import org.apache.flink.table.module.ModuleEntry

Review comment:
   Please reorder the imports. 

##
File path: 
flink-table/flink-table-planner-blink/src/test/scala/org/apache/flink/table/api/TableEnvironmentTest.scala
##
@@ -592,6 +593,66 @@ class TableEnvironmentTest {
 tableEnv.executeSql("UNLOAD MODULE dummy")
   }
 
+  @Test
+  def testExecuteSqlWithUseModules(): Unit = {
+tableEnv.executeSql("LOAD MODULE dummy")
+assert(tableEnv.listModules().sameElements(Array[String]("core", "dummy")))

Review comment:
   Personally, I don't like Scala `assert` because it doesn't provide 
mismatch information when assertion failed. Besides, `sameElements` sounds like 
it doesn't care about the elements order, but the order is critical here. 
Therefore, it would be better to use `assertArrayEquals`. We may also need to 
update the tests added in previous PR. 

##
File path: 
flink-table/flink-sql-client/src/main/java/org/apache/flink/table/client/gateway/local/LocalExecutor.java
##
@@ -428,6 +429,13 @@ public ProgramTargetDescriptor executeUpdate(String 
sessionId, String statement)
 return executeUpdateInternal(sessionId, context, statement);
 }
 
+@VisibleForTesting
+List listFullModules(String sessionId) throws 
SqlExecutionException {

Review comment:
   I think we will need this interface in the next `SHOW FULL MODULES` PR, 
we can add this method into base interface and implement it beside 
`listModules`.

##
File path: flink-table/flink-sql-parser-hive/src/main/codegen/data/Parser.tdd
##
@@ -129,6 +130,7 @@
 "LINES"
 "LOAD"
 "LOCATION"
+"MODULES"

Review comment:
   We should also add `MODULES` into non-reserved-keywords, otherwise it 
will break user jobs which uses `modules` as column name. For example, `select 
a, b, modules from T` will parse failed. 





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