Search in sources :

Example 1 with OutputConversionModifyOperation

use of org.apache.flink.table.operations.OutputConversionModifyOperation in project flink by apache.

the class ArrowUtils method isAppendOnlyTable.

private static boolean isAppendOnlyTable(Table table) {
    if (isStreamingMode(table)) {
        TableEnvironmentImpl tableEnv = (TableEnvironmentImpl) ((TableImpl) table).getTableEnvironment();
        try {
            OutputConversionModifyOperation modifyOperation = new OutputConversionModifyOperation(table.getQueryOperation(), TypeConversions.fromLegacyInfoToDataType(TypeExtractor.createTypeInfo(Row.class)), OutputConversionModifyOperation.UpdateMode.APPEND);
            tableEnv.getPlanner().translate(Collections.singletonList(modifyOperation));
        } catch (Throwable t) {
            if (t.getMessage().contains("doesn't support consuming update") || t.getMessage().contains("Table is not an append-only table")) {
                return false;
            } else {
                throw new RuntimeException("Failed to determine whether the given table is append only.", t);
            }
        }
    }
    return true;
}
Also used : TableEnvironmentImpl(org.apache.flink.table.api.internal.TableEnvironmentImpl) OutputConversionModifyOperation(org.apache.flink.table.operations.OutputConversionModifyOperation)

Aggregations

TableEnvironmentImpl (org.apache.flink.table.api.internal.TableEnvironmentImpl)1 OutputConversionModifyOperation (org.apache.flink.table.operations.OutputConversionModifyOperation)1