org.apache.flink.table.client.cli.SqlCommandParser.SqlCommand Java Examples
The following examples show how to use
org.apache.flink.table.client.cli.SqlCommandParser.SqlCommand.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: CliStrings.java From Flink-CEPplus with Apache License 2.0 | 5 votes |
private static AttributedString formatCommand(SqlCommand cmd, String description) { return new AttributedStringBuilder() .style(AttributedStyle.DEFAULT.bold()) .append(cmd.toString()) .append("\t\t") .style(AttributedStyle.DEFAULT) .append(description) .append('\n') .toAttributedString(); }
Example #2
Source File: CliStrings.java From flink with Apache License 2.0 | 5 votes |
private static AttributedString formatCommand(SqlCommand cmd, String description) { return new AttributedStringBuilder() .style(AttributedStyle.DEFAULT.bold()) .append(cmd.toString()) .append("\t\t") .style(AttributedStyle.DEFAULT) .append(description) .append('\n') .toAttributedString(); }
Example #3
Source File: CliStrings.java From flink with Apache License 2.0 | 5 votes |
private static AttributedString formatCommand(SqlCommand cmd, String description) { return new AttributedStringBuilder() .style(AttributedStyle.DEFAULT.bold()) .append(cmd.toString()) .append("\t\t") .style(AttributedStyle.DEFAULT) .append(description) .append('\n') .toAttributedString(); }
Example #4
Source File: SqlCommandParserTest.java From flink with Apache License 2.0 | 5 votes |
public static TestItem validSql( String sql, SqlCommand expectedCmd, String... expectedOperands) { TestItem testItem = new TestItem(sql); testItem.expectedCmd = expectedCmd; testItem.expectedOperands = expectedOperands; testItem.cannotParseComment = false; // default is false return testItem; }
Example #5
Source File: SqlCommandParserTest.java From flink with Apache License 2.0 | 5 votes |
public static TestItem validSql( SqlDialect sqlDialect, String sql, SqlCommand expectedCmd, String... expectedOperands) { TestItem testItem = new TestItem(sql); testItem.expectedCmd = expectedCmd; testItem.expectedOperands = expectedOperands; testItem.cannotParseComment = false; // default is false testItem.sqlDialect = sqlDialect; return testItem; }
Example #6
Source File: SqlCommandParserTest.java From Flink-CEPplus with Apache License 2.0 | 4 votes |
@Test public void testCommands() { testValidSqlCommand("QUIT;", new SqlCommandCall(SqlCommand.QUIT)); testValidSqlCommand("eXiT", new SqlCommandCall(SqlCommand.QUIT)); testValidSqlCommand("CLEAR", new SqlCommandCall(SqlCommand.CLEAR)); testValidSqlCommand("SHOW TABLES", new SqlCommandCall(SqlCommand.SHOW_TABLES)); testValidSqlCommand(" SHOW TABLES ", new SqlCommandCall(SqlCommand.SHOW_TABLES)); testValidSqlCommand("SHOW FUNCTIONS", new SqlCommandCall(SqlCommand.SHOW_FUNCTIONS)); testValidSqlCommand(" SHOW FUNCTIONS ", new SqlCommandCall(SqlCommand.SHOW_FUNCTIONS)); testValidSqlCommand("DESCRIBE MyTable", new SqlCommandCall(SqlCommand.DESCRIBE, new String[]{"MyTable"})); testValidSqlCommand("DESCRIBE MyTable ", new SqlCommandCall(SqlCommand.DESCRIBE, new String[]{"MyTable"})); testInvalidSqlCommand("DESCRIBE "); // no table name testValidSqlCommand( "EXPLAIN SELECT complicated FROM table", new SqlCommandCall(SqlCommand.EXPLAIN, new String[]{"SELECT complicated FROM table"})); testInvalidSqlCommand("EXPLAIN "); // no query testValidSqlCommand( "SELECT complicated FROM table", new SqlCommandCall(SqlCommand.SELECT, new String[]{"SELECT complicated FROM table"})); testValidSqlCommand( " SELECT complicated FROM table ", new SqlCommandCall(SqlCommand.SELECT, new String[]{"SELECT complicated FROM table"})); testValidSqlCommand( "INSERT INTO other SELECT 1+1", new SqlCommandCall(SqlCommand.INSERT_INTO, new String[]{"INSERT INTO other SELECT 1+1"})); testValidSqlCommand( "CREATE VIEW x AS SELECT 1+1", new SqlCommandCall(SqlCommand.CREATE_VIEW, new String[]{"x", "SELECT 1+1"})); testValidSqlCommand( "CREATE VIEW MyTable AS SELECT 1+1 FROM y", new SqlCommandCall(SqlCommand.CREATE_VIEW, new String[]{"MyTable", "SELECT 1+1 FROM y"})); testInvalidSqlCommand("CREATE VIEW x SELECT 1+1"); // missing AS testValidSqlCommand("DROP VIEW MyTable", new SqlCommandCall(SqlCommand.DROP_VIEW, new String[]{"MyTable"})); testValidSqlCommand("DROP VIEW MyTable", new SqlCommandCall(SqlCommand.DROP_VIEW, new String[]{"MyTable"})); testInvalidSqlCommand("DROP VIEW"); testValidSqlCommand("SET", new SqlCommandCall(SqlCommand.SET)); testValidSqlCommand("SET x=y", new SqlCommandCall(SqlCommand.SET, new String[] {"x", "y"})); testValidSqlCommand("SET x = y", new SqlCommandCall(SqlCommand.SET, new String[] {"x", " y"})); testValidSqlCommand("reset;", new SqlCommandCall(SqlCommand.RESET)); testValidSqlCommand("source /my/file", new SqlCommandCall(SqlCommand.SOURCE, new String[] {"/my/file"})); testInvalidSqlCommand("source"); // missing path }
Example #7
Source File: SqlCommandParserTest.java From flink with Apache License 2.0 | 4 votes |
@Test public void testCommands() { testValidSqlCommand("QUIT;", new SqlCommandCall(SqlCommand.QUIT)); testValidSqlCommand("eXiT", new SqlCommandCall(SqlCommand.QUIT)); testValidSqlCommand("CLEAR", new SqlCommandCall(SqlCommand.CLEAR)); testValidSqlCommand("SHOW TABLES", new SqlCommandCall(SqlCommand.SHOW_TABLES)); testValidSqlCommand(" SHOW TABLES ", new SqlCommandCall(SqlCommand.SHOW_TABLES)); testValidSqlCommand("SHOW FUNCTIONS", new SqlCommandCall(SqlCommand.SHOW_FUNCTIONS)); testValidSqlCommand(" SHOW FUNCTIONS ", new SqlCommandCall(SqlCommand.SHOW_FUNCTIONS)); testValidSqlCommand("DESCRIBE MyTable", new SqlCommandCall(SqlCommand.DESCRIBE, new String[]{"MyTable"})); testValidSqlCommand("DESCRIBE MyTable ", new SqlCommandCall(SqlCommand.DESCRIBE, new String[]{"MyTable"})); testInvalidSqlCommand("DESCRIBE "); // no table name testValidSqlCommand( "EXPLAIN SELECT complicated FROM table", new SqlCommandCall(SqlCommand.EXPLAIN, new String[]{"SELECT complicated FROM table"})); testInvalidSqlCommand("EXPLAIN "); // no query testValidSqlCommand( "SELECT complicated FROM table", new SqlCommandCall(SqlCommand.SELECT, new String[]{"SELECT complicated FROM table"})); testValidSqlCommand( " SELECT complicated FROM table ", new SqlCommandCall(SqlCommand.SELECT, new String[]{"SELECT complicated FROM table"})); testValidSqlCommand( "INSERT INTO other SELECT 1+1", new SqlCommandCall(SqlCommand.INSERT_INTO, new String[]{"INSERT INTO other SELECT 1+1"})); testValidSqlCommand( "CREATE VIEW x AS SELECT 1+1", new SqlCommandCall(SqlCommand.CREATE_VIEW, new String[]{"x", "SELECT 1+1"})); testValidSqlCommand( "CREATE VIEW MyTable AS SELECT 1+1 FROM y", new SqlCommandCall(SqlCommand.CREATE_VIEW, new String[]{"MyTable", "SELECT 1+1 FROM y"})); testInvalidSqlCommand("CREATE VIEW x SELECT 1+1"); // missing AS testValidSqlCommand("DROP VIEW MyTable", new SqlCommandCall(SqlCommand.DROP_VIEW, new String[]{"MyTable"})); testValidSqlCommand("DROP VIEW MyTable", new SqlCommandCall(SqlCommand.DROP_VIEW, new String[]{"MyTable"})); testInvalidSqlCommand("DROP VIEW"); testValidSqlCommand("SET", new SqlCommandCall(SqlCommand.SET)); testValidSqlCommand("SET x=y", new SqlCommandCall(SqlCommand.SET, new String[] {"x", "y"})); testValidSqlCommand("SET x = y", new SqlCommandCall(SqlCommand.SET, new String[] {"x", " y"})); testValidSqlCommand("reset;", new SqlCommandCall(SqlCommand.RESET)); testValidSqlCommand("source /my/file", new SqlCommandCall(SqlCommand.SOURCE, new String[] {"/my/file"})); testInvalidSqlCommand("source"); // missing path testValidSqlCommand("USE CATALOG default", new SqlCommandCall(SqlCommand.USE_CATALOG, new String[]{"default"})); testValidSqlCommand("use default", new SqlCommandCall(SqlCommand.USE, new String[] {"default"})); testInvalidSqlCommand("use catalog"); }