Search in sources :

Example 91 with TableException

use of org.apache.flink.table.api.TableException in project flink by apache.

the class PythonConfigUtil method getMergedConfig.

@SuppressWarnings("unchecked")
public static Configuration getMergedConfig(ExecutionEnvironment env, TableConfig tableConfig) {
    try {
        Field field = ExecutionEnvironment.class.getDeclaredField("cacheFile");
        field.setAccessible(true);
        Configuration config = new Configuration(env.getConfiguration());
        PythonDependencyUtils.merge(config, tableConfig.getConfiguration());
        Configuration mergedConfig = PythonDependencyUtils.configurePythonDependencies((List<Tuple2<String, DistributedCache.DistributedCacheEntry>>) field.get(env), config);
        mergedConfig.setString("table.exec.timezone", tableConfig.getLocalTimeZone().getId());
        return mergedConfig;
    } catch (NoSuchFieldException | IllegalAccessException e) {
        throw new TableException("Method getMergedConfig failed.", e);
    }
}
Also used : Field(java.lang.reflect.Field) TableException(org.apache.flink.table.api.TableException) Configuration(org.apache.flink.configuration.Configuration) DistributedCache(org.apache.flink.api.common.cache.DistributedCache) Tuple2(org.apache.flink.api.java.tuple.Tuple2)

Example 92 with TableException

use of org.apache.flink.table.api.TableException in project zeppelin by apache.

the class Flink113Shims method lookupExecutor.

private Object lookupExecutor(ClassLoader classLoader, Object settings, Object sEnv) {
    try {
        Map<String, String> executorProperties = ((EnvironmentSettings) settings).toExecutorProperties();
        ExecutorFactory executorFactory = ComponentFactoryService.find(ExecutorFactory.class, executorProperties);
        Method createMethod = executorFactory.getClass().getMethod("create", Map.class, StreamExecutionEnvironment.class);
        return createMethod.invoke(executorFactory, executorProperties, sEnv);
    } catch (Exception e) {
        throw new TableException("Could not instantiate the executor. Make sure a planner module is on the classpath", e);
    }
}
Also used : EnvironmentSettings(org.apache.flink.table.api.EnvironmentSettings) TableException(org.apache.flink.table.api.TableException) ExecutorFactory(org.apache.flink.table.delegation.ExecutorFactory) AttributedString(org.jline.utils.AttributedString) Method(java.lang.reflect.Method) FlinkException(org.apache.flink.util.FlinkException) TableException(org.apache.flink.table.api.TableException) IOException(java.io.IOException)

Example 93 with TableException

use of org.apache.flink.table.api.TableException in project zeppelin by apache.

the class Flink114Shims method lookupExecutor.

private Object lookupExecutor(ClassLoader classLoader, Object settings, Object sEnv) {
    try {
        final ExecutorFactory executorFactory = FactoryUtil.discoverFactory(classLoader, ExecutorFactory.class, ((EnvironmentSettings) settings).getExecutor());
        final Method createMethod = executorFactory.getClass().getMethod("create", StreamExecutionEnvironment.class);
        return createMethod.invoke(executorFactory, sEnv);
    } catch (Exception e) {
        throw new TableException("Could not instantiate the executor. Make sure a planner module is on the classpath", e);
    }
}
Also used : TableException(org.apache.flink.table.api.TableException) ExecutorFactory(org.apache.flink.table.delegation.ExecutorFactory) Method(java.lang.reflect.Method) FlinkException(org.apache.flink.util.FlinkException) TableException(org.apache.flink.table.api.TableException) IOException(java.io.IOException)

Example 94 with TableException

use of org.apache.flink.table.api.TableException in project zeppelin by apache.

the class Flink112Shims method lookupExecutor.

private Object lookupExecutor(ClassLoader classLoader, Object settings, Object sEnv) {
    try {
        Map<String, String> executorProperties = ((EnvironmentSettings) settings).toExecutorProperties();
        ExecutorFactory executorFactory = ComponentFactoryService.find(ExecutorFactory.class, executorProperties);
        Method createMethod = executorFactory.getClass().getMethod("create", Map.class, StreamExecutionEnvironment.class);
        return (Executor) createMethod.invoke(executorFactory, executorProperties, (StreamExecutionEnvironment) sEnv);
    } catch (Exception e) {
        throw new TableException("Could not instantiate the executor. Make sure a planner module is on the classpath", e);
    }
}
Also used : EnvironmentSettings(org.apache.flink.table.api.EnvironmentSettings) TableException(org.apache.flink.table.api.TableException) Executor(org.apache.flink.table.delegation.Executor) ExecutorFactory(org.apache.flink.table.delegation.ExecutorFactory) StreamExecutionEnvironment(org.apache.flink.streaming.api.environment.StreamExecutionEnvironment) AttributedString(org.jline.utils.AttributedString) Method(java.lang.reflect.Method) FlinkException(org.apache.flink.util.FlinkException) TableException(org.apache.flink.table.api.TableException) IOException(java.io.IOException)

Example 95 with TableException

use of org.apache.flink.table.api.TableException in project zeppelin by apache.

the class TableEnvFactory method createJavaFlinkBatchTableEnvironment.

public TableEnvironment createJavaFlinkBatchTableEnvironment() {
    try {
        Class<?> clazz = Class.forName("org.apache.flink.table.api.bridge.java.internal.BatchTableEnvironmentImpl");
        Constructor con = clazz.getConstructor(ExecutionEnvironment.class, TableConfig.class, CatalogManager.class, ModuleManager.class);
        return (TableEnvironment) con.newInstance(benv.getJavaEnv(), oldPlannerBatchTableConfig, oldPlannerCatalogManager, moduleManager);
    } catch (Throwable t) {
        throw new TableException("Create BatchTableEnvironment failed.", t);
    }
}
Also used : TableException(org.apache.flink.table.api.TableException) Constructor(java.lang.reflect.Constructor) TableEnvironment(org.apache.flink.table.api.TableEnvironment)

Aggregations

TableException (org.apache.flink.table.api.TableException)163 RowData (org.apache.flink.table.data.RowData)35 RowType (org.apache.flink.table.types.logical.RowType)35 Transformation (org.apache.flink.api.dag.Transformation)28 ArrayList (java.util.ArrayList)27 ExecEdge (org.apache.flink.table.planner.plan.nodes.exec.ExecEdge)24 LogicalType (org.apache.flink.table.types.logical.LogicalType)24 List (java.util.List)22 DataType (org.apache.flink.table.types.DataType)19 OneInputTransformation (org.apache.flink.streaming.api.transformations.OneInputTransformation)18 ValidationException (org.apache.flink.table.api.ValidationException)17 IOException (java.io.IOException)13 AggregateCall (org.apache.calcite.rel.core.AggregateCall)13 ValueLiteralExpression (org.apache.flink.table.expressions.ValueLiteralExpression)13 RowDataKeySelector (org.apache.flink.table.runtime.keyselector.RowDataKeySelector)13 Optional (java.util.Optional)11 Configuration (org.apache.flink.configuration.Configuration)11 StreamExecutionEnvironment (org.apache.flink.streaming.api.environment.StreamExecutionEnvironment)11 Constructor (java.lang.reflect.Constructor)10 Arrays (java.util.Arrays)9