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);
}
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);
}
}
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);
}
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());
}
Aggregations