wuchong commented on a change in pull request #11047: [FLINK-15912][table] Add 
Context to TableSourceFactory and TableSinkFactory
URL: https://github.com/apache/flink/pull/11047#discussion_r377454733
 
 

 ##########
 File path: 
flink-table/flink-table-planner-blink/src/test/scala/org/apache/flink/table/planner/plan/batch/sql/SinkTest.scala
 ##########
 @@ -70,24 +69,82 @@ class SinkTest extends TableTestBase {
   }
 
   @Test
-  def testCatalogTableSink(): Unit = {
-    val schemaBuilder = new TableSchema.Builder()
-    schemaBuilder.fields(Array("i"), Array(DataTypes.INT()))
-    val schema = schemaBuilder.build()
-    val sink = util.createCollectTableSink(schema.getFieldNames, Array(INT))
-    val catalog = Mockito.spy(new GenericInMemoryCatalog("dummy"))
-    val factory = Mockito.mock(classOf[TableSinkFactory[_]])
-    
Mockito.when[Optional[_]](catalog.getTableFactory).thenReturn(Optional.of(factory))
-    Mockito.when[TableSink[_]](factory.createTableSink(
-      ArgumentMatchers.any(), ArgumentMatchers.any())).thenReturn(sink)
-    util.tableEnv.registerCatalog(catalog.getName, catalog)
-    util.tableEnv.useCatalog(catalog.getName)
-    val catalogTable = new CatalogTableImpl(schema, Map[String, 
String]().asJava, "")
-    catalog.createTable(new ObjectPath("default", "tbl"), catalogTable, false)
-    util.tableEnv.sqlQuery("select 1").insertInto("tbl")
+  def testTableSourceSinkFactory(): Unit = {
+    val factory = new TestContextTableFactory
+    util.tableEnv.getConfig.getConfiguration.setBoolean(factory.needContain, 
true)
+    util.tableEnv.registerCatalog("cat", new GenericInMemoryCatalog("default") 
{
 
 Review comment:
   This only guarantees one of the paths, i.e. via 
`TableFactoryUtil#createTableSinkForCatalogTable`, which is only used by Hive. 
However, the another path is not covered, i.e. via 
`CatalogSourceTable#findAndCreateTableSource` which is used by most users.
   
   Maybe you can upgrade the existing `TestCollectionTableFactory` to use the 
new interface and expose a session configuration, e.g. `collection.is-bounded`, 
the flag will be accessed via `Context#getConfiguration` and pass to the 
created `CollectionTableSource`.

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services

Reply via email to