flink-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From fhueske <...@git.apache.org>
Subject [GitHub] flink pull request #3409: [flink-5570] [Table API & SQL]Support register ext...
Date Thu, 23 Mar 2017 10:20:10 GMT
Github user fhueske commented on a diff in the pull request:

    https://github.com/apache/flink/pull/3409#discussion_r107347170
  
    --- Diff: flink-libraries/flink-table/src/main/scala/org/apache/flink/table/api/java/BatchTableEnvironment.scala
---
    @@ -178,4 +178,32 @@ class BatchTableEnvironment(
     
         registerTableFunctionInternal[T](name, tf)
       }
    +
    +  /**
    +    * Scans a table from registered temporary tables and registered catalogs.
    +    *
    +    * The table to scan must be registered in the TableEnvironment or
    +    * must exist in registered catalog in the TableEnvironment.
    +    *
    +    * Example:
    +    *
    +    * to scan a registered temporary table
    +    * {{{
    +    *   val tab: Table = tableEnv.scan("tableName")
    +    * }}}
    +    *
    +    * to scan a table from a registered catalog
    +    * {{{
    +    *   val tab: Table = tableEnv.scan("catalogName.dbName.tableName")
    +    * }}}
    +    *
    +    * @param tablePath The path of the table to scan.
    +    * @throws TableException if no table is found using the given table path.
    +    * @return The resulting [[Table]].
    +    */
    +  @throws[TableException]
    +  def scan(tablePath: String): Table = {
    --- End diff --
    
    Alright, I found a solution to the problem.
    We can actually define a varargs method in Scala that can be used from Java with varargs.

    
    ```
    import _root_.scala.annotation.varargs
    
    @varargs def scan(tablePath: String*): Table = {
      scanInternal(tablePath.toArray)
    }
    ```
    
    This way we do not need to parse the string and have unified usage in Java and Scala.
    All TableEnvironments will only have a single varargs method.


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

Mime
View raw message