hequn8128 commented on a change in pull request #7235: [FLINK-10976] [table] 
Add support for aggregate to table API
URL: https://github.com/apache/flink/pull/7235#discussion_r240877612
 
 

 ##########
 File path: 
flink-libraries/flink-table/src/main/scala/org/apache/flink/table/plan/ProjectionTranslator.scala
 ##########
 @@ -418,4 +419,34 @@ object ProjectionTranslator {
       case e: Expression => e
     }
   }
+
+  /**
+    * Unwrap a Call to ScalarFunctionCall, TableFunctionCall, AggFunctionCall 
or the built-in
+    * expression representation.
+    *
+    * @param field    the expression to unwrap
+    * @param tableEnv the TableEnvironment
+    * @return the unwrapped expression
+    */
+  def unwrap(
+      field: Expression,
+      tableEnv: TableEnvironment): Expression = {
+    field match {
+      case Alias(child, _, _) =>
+        unwrap(child, tableEnv)
+      // Functions calls
+      case c @ Call(name, args: Seq[Expression]) =>
+        val function = tableEnv.functionCatalog.lookupFunction(name, args)
+        unwrap(function, tableEnv)
+      // Other expressions
+      case e: Expression => e
+    }
+  }
+
+  def extractFieldNames(expr: Expression): Seq[String] = {
+    expr match {
+      case Alias(child, name, extraNames) => Seq(name) ++ extraNames
 
 Review comment:
   replace child with _

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on 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

Reply via email to