flink-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From wuchong <...@git.apache.org>
Subject [GitHub] flink pull request #2810: [FLINK-3848] Add ProjectableTableSource interface ...
Date Sat, 26 Nov 2016 13:37:40 GMT
Github user wuchong commented on a diff in the pull request:

    https://github.com/apache/flink/pull/2810#discussion_r89671128
  
    --- Diff: flink-libraries/flink-table/src/main/scala/org/apache/flink/api/table/sources/CsvTableSource.scala
---
    @@ -102,11 +107,43 @@ class CsvTableSource(
         *       Do not use it in Table API programs.
         */
       override def getDataStream(streamExecEnv: StreamExecutionEnvironment): DataStream[Row]
= {
    -    streamExecEnv.createInput(createCsvInput(), returnType)
    +    streamExecEnv.createInput(createCsvInput(), projectionReturnTypeWithOrder.getOrElse(returnType))
    +  }
    +
    +  /** Returns a [[TableSource]] with ability to project fields */
    +  override def setProjection(fields: Array[Int]): CsvTableSource = {
    +    val mask = new Array[Boolean](fieldNames.length)
    +    fields.foreach(mask(_) = true)
    +    val orderedReturnType = fields.map(fieldTypes(_))
    +    val indexDiff = fieldNames.length - fields.length
    +    val order = fields.map(f => f - indexDiff).zipWithIndex.sortBy(_._1).map(_._2)
    +    val source = copy
    --- End diff --
    
    I would like use the `newFieldNames` and `newFieldTypes` to create a new `CsvTableSource`
instead of a same copy, so that we do not need `orderedReturnType`. What do you think ? 


---
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