Search in sources :

Example 41 with TableConfig

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

the class CodeSplitTest method runTest.

private void runTest(Consumer<TableConfig> consumer) {
    TableConfig splitTableConfig = new TableConfig();
    splitTableConfig.set(TableConfigOptions.MAX_LENGTH_GENERATED_CODE, 4000);
    splitTableConfig.set(TableConfigOptions.MAX_MEMBERS_GENERATED_CODE, 10000);
    consumer.accept(splitTableConfig);
    TableConfig noSplitTableConfig = new TableConfig();
    noSplitTableConfig.set(TableConfigOptions.MAX_LENGTH_GENERATED_CODE, Integer.MAX_VALUE);
    noSplitTableConfig.set(TableConfigOptions.MAX_MEMBERS_GENERATED_CODE, Integer.MAX_VALUE);
    PrintStream originalStdOut = System.out;
    try {
        // redirect stdout to a null output stream to silence compile error in CompileUtils
        System.setOut(new PrintStream(new OutputStream() {

            @Override
            public void write(int b) throws IOException {
            }
        }));
        consumer.accept(noSplitTableConfig);
        Assert.fail("Expecting compiler exception");
    } catch (Exception e) {
        MatcherAssert.assertThat(e, FlinkMatchers.containsMessage("grows beyond 64 KB"));
    } finally {
        // set stdout back
        System.setOut(originalStdOut);
    }
}
Also used : PrintStream(java.io.PrintStream) OutputStream(java.io.OutputStream) TableConfig(org.apache.flink.table.api.TableConfig) IOException(java.io.IOException)

Aggregations

TableConfig (org.apache.flink.table.api.TableConfig)41 RowType (org.apache.flink.table.types.logical.RowType)19 Test (org.junit.Test)10 ArrayList (java.util.ArrayList)6 RexNode (org.apache.calcite.rex.RexNode)6 CatalogManager (org.apache.flink.table.catalog.CatalogManager)6 IOException (java.io.IOException)5 OutputStream (java.io.OutputStream)5 PrintStream (java.io.PrintStream)5 Arrays (java.util.Arrays)5 Collections (java.util.Collections)5 List (java.util.List)5 RexBuilder (org.apache.calcite.rex.RexBuilder)5 RexInputRef (org.apache.calcite.rex.RexInputRef)5 Table (org.apache.flink.table.api.Table)5 FlinkTypeFactory (org.apache.flink.table.planner.calcite.FlinkTypeFactory)5 IntType (org.apache.flink.table.types.logical.IntType)5 Row (org.apache.flink.types.Row)5 Random (java.util.Random)4 Consumer (java.util.function.Consumer)4