Github user fhueske commented on a diff in the pull request:
https://github.com/apache/flink/pull/1559#discussion_r51245443
--- Diff:
flink-libraries/flink-table/src/main/scala/org/apache/flink/api/java/table/JavaBatchTranslator.scala
---
@@ -41,21 +44,13 @@ class JavaBatchTranslator extends PlanTranslator {
// create table representation from DataSet
val dataSetTable = new DataSetTable[A](
- repr.asInstanceOf[JavaDataSet[A]],
- fieldNames
+ repr.asInstanceOf[JavaDataSet[A]],
+ fieldNames
)
-
- // register table in Cascading schema
- val schema = Frameworks.createRootSchema(true)
val tableName = repr.hashCode().toString
- schema.add(tableName, dataSetTable)
- // initialize RelBuilder
- val frameworkConfig = Frameworks
- .newConfigBuilder
- .defaultSchema(schema)
- .build
- val relBuilder = RelBuilder.create(frameworkConfig)
+ TranslationContext.addDataSet(tableName, dataSetTable)
--- End diff --
I think we need to hold the table catalog and the RelBuilder in a
singleton. The Scala Table API does not require a TableEnvironment (and I think
this should stay like this for seamless integration), so there is no
othercentral place to register tables (and the RelBuilder must be the same for
all RelNodes of a query). You are right wrt. to the hashcode. I'll use an
AtomicCounter for the name.
---
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.
---