[ 
https://issues.apache.org/jira/browse/FLINK-2167?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14933094#comment-14933094
 ] 

ASF GitHub Bot commented on FLINK-2167:
---------------------------------------

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.


> Add fromHCat() to TableEnvironment
> ----------------------------------
>
>                 Key: FLINK-2167
>                 URL: https://issues.apache.org/jira/browse/FLINK-2167
>             Project: Flink
>          Issue Type: New Feature
>          Components: Table API
>    Affects Versions: 0.9
>            Reporter: Fabian Hueske
>            Assignee: Timo Walther
>            Priority: Minor
>              Labels: starter
>
> Add a {{fromHCat()}} method to the {{TableEnvironment}} to read a {{Table}} 
> from an HCatalog table.
> The implementation could reuse Flink's HCatInputFormat.



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Reply via email to