Search in sources :

Example 1 with HiveParser

use of org.apache.flink.table.planner.delegation.hive.HiveParser in project flink by apache.

the class HiveDialectITCase method testParseCommand.

@Test
public void testParseCommand() {
    TableEnvironmentInternal tableEnvInternal = (TableEnvironmentInternal) tableEnv;
    Parser parser = tableEnvInternal.getParser();
    // hive dialect should use HiveParser
    assertTrue(parser instanceof HiveParser);
    assertThat(parser.parse("HELP").get(0), instanceOf(HelpOperation.class));
    assertThat(parser.parse("clear").get(0), instanceOf(ClearOperation.class));
    assertThat(parser.parse("SET").get(0), instanceOf(SetOperation.class));
    assertThat(parser.parse("ResET").get(0), instanceOf(ResetOperation.class));
    assertThat(parser.parse("Exit").get(0), instanceOf(QuitOperation.class));
}
Also used : ResetOperation(org.apache.flink.table.operations.command.ResetOperation) SetOperation(org.apache.flink.table.operations.command.SetOperation) TableEnvironmentInternal(org.apache.flink.table.api.internal.TableEnvironmentInternal) HiveParser(org.apache.flink.table.planner.delegation.hive.HiveParser) ClearOperation(org.apache.flink.table.operations.command.ClearOperation) HiveParser(org.apache.flink.table.planner.delegation.hive.HiveParser) Parser(org.apache.flink.table.delegation.Parser) HelpOperation(org.apache.flink.table.operations.command.HelpOperation) QuitOperation(org.apache.flink.table.operations.command.QuitOperation) Test(org.junit.Test)

Example 2 with HiveParser

use of org.apache.flink.table.planner.delegation.hive.HiveParser in project flink by apache.

the class HiveDialectITCase method testPluggableParser.

@Test
public void testPluggableParser() {
    TableEnvironmentInternal tableEnvInternal = (TableEnvironmentInternal) tableEnv;
    Parser parser = tableEnvInternal.getParser();
    // hive dialect should use HiveParser
    assertTrue(parser instanceof HiveParser);
    // execute some sql and verify the parser instance is reused
    tableEnvInternal.executeSql("show databases");
    assertSame(parser, tableEnvInternal.getParser());
    // switching dialect will result in a new parser
    tableEnvInternal.getConfig().setSqlDialect(SqlDialect.DEFAULT);
    assertNotEquals(parser.getClass().getName(), tableEnvInternal.getParser().getClass().getName());
}
Also used : TableEnvironmentInternal(org.apache.flink.table.api.internal.TableEnvironmentInternal) HiveParser(org.apache.flink.table.planner.delegation.hive.HiveParser) HiveParser(org.apache.flink.table.planner.delegation.hive.HiveParser) Parser(org.apache.flink.table.delegation.Parser) Test(org.junit.Test)

Aggregations

TableEnvironmentInternal (org.apache.flink.table.api.internal.TableEnvironmentInternal)2 Parser (org.apache.flink.table.delegation.Parser)2 HiveParser (org.apache.flink.table.planner.delegation.hive.HiveParser)2 Test (org.junit.Test)2 ClearOperation (org.apache.flink.table.operations.command.ClearOperation)1 HelpOperation (org.apache.flink.table.operations.command.HelpOperation)1 QuitOperation (org.apache.flink.table.operations.command.QuitOperation)1 ResetOperation (org.apache.flink.table.operations.command.ResetOperation)1 SetOperation (org.apache.flink.table.operations.command.SetOperation)1