Search in sources :

Example 1 with Module

use of org.apache.flink.table.module.Module in project flink by apache.

the class CoreModuleFactoryTest method test.

@Test
public void test() {
    final CoreModule expectedModule = CoreModule.INSTANCE;
    final Module actualModule = FactoryUtil.createModule(CoreModuleFactory.IDENTIFIER, Collections.emptyMap(), new Configuration(), Thread.currentThread().getContextClassLoader());
    assertEquals(expectedModule, actualModule);
}
Also used : Configuration(org.apache.flink.configuration.Configuration) CoreModule(org.apache.flink.table.module.CoreModule) Module(org.apache.flink.table.module.Module) CoreModule(org.apache.flink.table.module.CoreModule) Test(org.junit.Test)

Example 2 with Module

use of org.apache.flink.table.module.Module in project flink by apache.

the class TableEnvironmentImpl method loadModule.

private TableResultInternal loadModule(LoadModuleOperation operation) {
    final String exMsg = getDDLOpExecuteErrorMsg(operation.asSummaryString());
    try {
        final Module module = FactoryUtil.createModule(operation.getModuleName(), operation.getOptions(), tableConfig.getConfiguration(), userClassLoader);
        moduleManager.loadModule(operation.getModuleName(), module);
        return TableResultImpl.TABLE_RESULT_OK;
    } catch (ValidationException e) {
        throw new ValidationException(String.format("%s. %s", exMsg, e.getMessage()), e);
    } catch (Exception e) {
        throw new TableException(String.format("%s. %s", exMsg, e.getMessage()), e);
    }
}
Also used : TableException(org.apache.flink.table.api.TableException) ValidationException(org.apache.flink.table.api.ValidationException) Module(org.apache.flink.table.module.Module) FunctionAlreadyExistException(org.apache.flink.table.catalog.exceptions.FunctionAlreadyExistException) DatabaseNotExistException(org.apache.flink.table.catalog.exceptions.DatabaseNotExistException) TableAlreadyExistException(org.apache.flink.table.catalog.exceptions.TableAlreadyExistException) TableException(org.apache.flink.table.api.TableException) IOException(java.io.IOException) ExecutionException(java.util.concurrent.ExecutionException) CatalogException(org.apache.flink.table.catalog.exceptions.CatalogException) FunctionNotExistException(org.apache.flink.table.catalog.exceptions.FunctionNotExistException) DatabaseNotEmptyException(org.apache.flink.table.catalog.exceptions.DatabaseNotEmptyException) DatabaseAlreadyExistException(org.apache.flink.table.catalog.exceptions.DatabaseAlreadyExistException) SqlParserException(org.apache.flink.table.api.SqlParserException) ValidationException(org.apache.flink.table.api.ValidationException) TableNotExistException(org.apache.flink.table.catalog.exceptions.TableNotExistException)

Example 3 with Module

use of org.apache.flink.table.module.Module in project flink by apache.

the class HiveModuleFactoryTest method test.

@Test
public void test() {
    final HiveModule expected = new HiveModule();
    final Module actualModule = FactoryUtil.createModule(HiveModuleFactory.IDENTIFIER, Collections.emptyMap(), new Configuration(), Thread.currentThread().getContextClassLoader());
    checkEquals(expected, (HiveModule) actualModule);
}
Also used : Configuration(org.apache.flink.configuration.Configuration) Module(org.apache.flink.table.module.Module) Test(org.junit.Test)

Example 4 with Module

use of org.apache.flink.table.module.Module in project flink by apache.

the class CatalogSourceTable method createDynamicTableSource.

private DynamicTableSource createDynamicTableSource(FlinkContext context, ResolvedCatalogTable catalogTable) {
    final ReadableConfig config = context.getTableConfig().getConfiguration();
    final Optional<DynamicTableSourceFactory> factoryFromCatalog = schemaTable.getContextResolvedTable().getCatalog().flatMap(Catalog::getFactory).map(f -> f instanceof DynamicTableSourceFactory ? (DynamicTableSourceFactory) f : null);
    final Optional<DynamicTableSourceFactory> factoryFromModule = context.getModuleManager().getFactory(Module::getTableSourceFactory);
    // Since the catalog is more specific, we give it precedence over a factory provided by any
    // modules.
    final DynamicTableSourceFactory factory = firstPresent(factoryFromCatalog, factoryFromModule).orElse(null);
    return FactoryUtil.createDynamicTableSource(factory, schemaTable.getContextResolvedTable().getIdentifier(), catalogTable, config, Thread.currentThread().getContextClassLoader(), schemaTable.isTemporary());
}
Also used : ReadableConfig(org.apache.flink.configuration.ReadableConfig) DynamicTableSourceFactory(org.apache.flink.table.factories.DynamicTableSourceFactory) Module(org.apache.flink.table.module.Module)

Aggregations

Module (org.apache.flink.table.module.Module)4 Configuration (org.apache.flink.configuration.Configuration)2 Test (org.junit.Test)2 IOException (java.io.IOException)1 ExecutionException (java.util.concurrent.ExecutionException)1 ReadableConfig (org.apache.flink.configuration.ReadableConfig)1 SqlParserException (org.apache.flink.table.api.SqlParserException)1 TableException (org.apache.flink.table.api.TableException)1 ValidationException (org.apache.flink.table.api.ValidationException)1 CatalogException (org.apache.flink.table.catalog.exceptions.CatalogException)1 DatabaseAlreadyExistException (org.apache.flink.table.catalog.exceptions.DatabaseAlreadyExistException)1 DatabaseNotEmptyException (org.apache.flink.table.catalog.exceptions.DatabaseNotEmptyException)1 DatabaseNotExistException (org.apache.flink.table.catalog.exceptions.DatabaseNotExistException)1 FunctionAlreadyExistException (org.apache.flink.table.catalog.exceptions.FunctionAlreadyExistException)1 FunctionNotExistException (org.apache.flink.table.catalog.exceptions.FunctionNotExistException)1 TableAlreadyExistException (org.apache.flink.table.catalog.exceptions.TableAlreadyExistException)1 TableNotExistException (org.apache.flink.table.catalog.exceptions.TableNotExistException)1 DynamicTableSourceFactory (org.apache.flink.table.factories.DynamicTableSourceFactory)1 CoreModule (org.apache.flink.table.module.CoreModule)1