[
https://issues.apache.org/jira/browse/FLINK-3848?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15702035#comment-15702035
]
ASF GitHub Bot commented on FLINK-3848:
---------------------------------------
Github user fhueske commented on a diff in the pull request:
https://github.com/apache/flink/pull/2810#discussion_r89778399
--- Diff:
flink-libraries/flink-table/src/test/scala/org/apache/flink/api/scala/batch/TableSourceITCase.scala
---
@@ -131,6 +101,58 @@ class TableSourceITCase(
TestBaseUtils.compareResultAsText(results.asJava, expected)
}
+ @Test
+ def testCsvTableSourceWithProjection(): Unit = {
+
+ val csvTable = CommonTestData.getCsvTableSource
+
+ val env = ExecutionEnvironment.getExecutionEnvironment
+ val tEnv = TableEnvironment.getTableEnvironment(env, config)
+
+ tEnv.registerTableSource("csvTable", csvTable)
+
+ val results = tEnv
+ .scan("csvTable")
+ .select('last, 'id, 'score)
+ .collect()
+
+ val expected = Seq(
+ "Smith,1,12.3",
+ "Taylor,2,45.6",
+ "Miller,3,7.89",
+ "Smith,4,0.12",
+ "Williams,5,34.5",
+ "Miller,6,6.78",
+ "Smith,7,90.1",
+ "Williams,8,2.34").mkString("\n")
+ TestBaseUtils.compareResultAsText(results.sortBy(_.toString).asJava,
expected)
+ }
+
+ @Test
+ def testCsvProjecableTableSourceWithDiffRexs(): Unit = {
--- End diff --
I think this ITCase could be omitted.
Instead it would be good to add a few tests that extend the `TableTestBase`
and check that a correct plan is generated.
> Add ProjectableTableSource interface and translation rule
> ---------------------------------------------------------
>
> Key: FLINK-3848
> URL: https://issues.apache.org/jira/browse/FLINK-3848
> Project: Flink
> Issue Type: New Feature
> Components: Table API & SQL
> Reporter: Fabian Hueske
> Assignee: Anton Solovev
>
> Add a {{ProjectableTableSource}} interface for {{TableSource}} implementation
> that support projection push-down.
> The interface could look as follows
> {code}
> def trait ProjectableTableSource {
> def setProjection(fields: Array[String]): Unit
> }
> {code}
> In addition we need Calcite rules to push a projection into a TableScan that
> refers to a {{ProjectableTableSource}}. We might need to tweak the cost model
> as well to push the optimizer in the right direction.
> Moreover, the {{CsvTableSource}} could be extended to implement
> {{ProjectableTableSource}}.
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)