Search in sources :

Example 11 with FunctionCatalog

use of org.apache.flink.table.catalog.FunctionCatalog in project flink by apache.

the class LookupKeySerdeTest method testLookupKey.

@Test
public void testLookupKey() throws IOException {
    TableConfig tableConfig = TableConfig.getDefault();
    ModuleManager moduleManager = new ModuleManager();
    CatalogManager catalogManager = CatalogManager.newBuilder().classLoader(Thread.currentThread().getContextClassLoader()).config(tableConfig.getConfiguration()).defaultCatalog("default_catalog", new GenericInMemoryCatalog("default_db")).build();
    FlinkContext flinkContext = new FlinkContextImpl(false, tableConfig, moduleManager, new FunctionCatalog(tableConfig, catalogManager, moduleManager), catalogManager, null);
    SerdeContext serdeCtx = new SerdeContext(null, flinkContext, Thread.currentThread().getContextClassLoader(), FlinkTypeFactory.INSTANCE(), FlinkSqlOperatorTable.instance());
    ObjectReader objectReader = JsonSerdeUtil.createObjectReader(serdeCtx);
    ObjectWriter objectWriter = JsonSerdeUtil.createObjectWriter(serdeCtx);
    LookupJoinUtil.LookupKey[] lookupKeys = new LookupJoinUtil.LookupKey[] { new LookupJoinUtil.ConstantLookupKey(new BigIntType(), new RexBuilder(FlinkTypeFactory.INSTANCE()).makeLiteral("a")), new LookupJoinUtil.FieldRefLookupKey(3) };
    for (LookupJoinUtil.LookupKey lookupKey : lookupKeys) {
        LookupJoinUtil.LookupKey result = objectReader.readValue(objectWriter.writeValueAsString(lookupKey), LookupJoinUtil.LookupKey.class);
        assertEquals(lookupKey, result);
    }
}
Also used : FunctionCatalog(org.apache.flink.table.catalog.FunctionCatalog) ObjectWriter(org.apache.flink.shaded.jackson2.com.fasterxml.jackson.databind.ObjectWriter) BigIntType(org.apache.flink.table.types.logical.BigIntType) ModuleManager(org.apache.flink.table.module.ModuleManager) FlinkContext(org.apache.flink.table.planner.calcite.FlinkContext) CatalogManager(org.apache.flink.table.catalog.CatalogManager) GenericInMemoryCatalog(org.apache.flink.table.catalog.GenericInMemoryCatalog) LookupJoinUtil(org.apache.flink.table.planner.plan.utils.LookupJoinUtil) FlinkContextImpl(org.apache.flink.table.planner.calcite.FlinkContextImpl) TableConfig(org.apache.flink.table.api.TableConfig) RexBuilder(org.apache.calcite.rex.RexBuilder) ObjectReader(org.apache.flink.shaded.jackson2.com.fasterxml.jackson.databind.ObjectReader) Test(org.junit.Test)

Aggregations

FunctionCatalog (org.apache.flink.table.catalog.FunctionCatalog)11 ModuleManager (org.apache.flink.table.module.ModuleManager)11 CatalogManager (org.apache.flink.table.catalog.CatalogManager)10 TableConfig (org.apache.flink.table.api.TableConfig)8 Executor (org.apache.flink.table.delegation.Executor)7 Planner (org.apache.flink.table.delegation.Planner)7 Constructor (java.lang.reflect.Constructor)5 StreamExecutionEnvironment (org.apache.flink.streaming.api.environment.StreamExecutionEnvironment)5 TableEnvironment (org.apache.flink.table.api.TableEnvironment)5 TableException (org.apache.flink.table.api.TableException)5 GenericInMemoryCatalog (org.apache.flink.table.catalog.GenericInMemoryCatalog)4 URLClassLoader (java.net.URLClassLoader)1 RexBuilder (org.apache.calcite.rex.RexBuilder)1 Configuration (org.apache.flink.configuration.Configuration)1 ObjectReader (org.apache.flink.shaded.jackson2.com.fasterxml.jackson.databind.ObjectReader)1 ObjectWriter (org.apache.flink.shaded.jackson2.com.fasterxml.jackson.databind.ObjectWriter)1 EnvironmentSettings (org.apache.flink.table.api.EnvironmentSettings)1 AbstractStreamTableEnvironmentImpl (org.apache.flink.table.api.bridge.internal.AbstractStreamTableEnvironmentImpl)1 ExecutorFactory (org.apache.flink.table.delegation.ExecutorFactory)1 FlinkContext (org.apache.flink.table.planner.calcite.FlinkContext)1