Github user aljoscha commented on a diff in the pull request:

    https://github.com/apache/flink/pull/1127#discussion_r40534596
  
    --- Diff: 
flink-staging/flink-table/src/main/scala/org/apache/flink/api/java/table/JavaBatchTranslator.scala
 ---
    @@ -54,6 +56,26 @@ class JavaBatchTranslator extends PlanTranslator {
         Table(Root(rowDataSet, resultFields))
       }
     
    +  override def createTable(tableSource: TableSource): Table = {
    +    // a TableSource requires an ExecutionEnvironment
    +    if (env == null) {
    +      throw new InvalidProgramException("This operation requires an 
ExecutionEnvironment.")
    +    }
    +    if (tableSource.isInstanceOf[AdaptiveTableSource]) {
    +      val adaptiveTs = tableSource.asInstanceOf[AdaptiveTableSource]
    +      if (adaptiveTs.supportsResolvedFieldPushdown || 
adaptiveTs.supportsPredicatePushdown) {
    +        Table(Root(adaptiveTs, adaptiveTs.getOutputFields()))
    +      }
    +      else {
    +        Table(Root(adaptiveTs.createAdaptiveDataSet(env), 
adaptiveTs.getOutputFields()))
    +      }
    +    }
    +    else {
    +      val staticTs = tableSource.asInstanceOf[StaticTableSource]
    +      createTable(staticTs.createStaticDataSet(env), 
staticTs.getOutputFieldNames().mkString(","))
    +    }
    --- End diff --
    
    You can replace the if/else by:
    
    ```scala
    tableSource match {
      case adaptive: AdaptiveTableSource if 
adaptive.supportsResolvedFieldPushdown && ... => ...
    
      case adaptive: AdaptiveTableSource => ...
      
      case static: StaticTableSource => ...
    
      case _ => throw new Exception("something unexpected")
    }
    ```
    
    if I'm not mistaken, this is just of the top of my head.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---

Reply via email to