This is an automated email from the ASF dual-hosted git repository. twalthr pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/flink.git
commit 549079c0b565d10faf07272bdbe046a9b451b086 Author: Timo Walther <twal...@apache.org> AuthorDate: Tue Jul 30 11:13:06 2019 +0200 [hotfix][sql-client] Add USE CATALOG/USE to CLI help --- .../org/apache/flink/table/client/cli/CliClient.java | 2 +- .../apache/flink/table/client/cli/CliStrings.java | 20 +++++++++++--------- .../flink/table/client/cli/SqlCommandParser.java | 2 +- .../flink/table/client/cli/SqlCommandParserTest.java | 2 +- 4 files changed, 14 insertions(+), 12 deletions(-) diff --git a/flink-table/flink-sql-client/src/main/java/org/apache/flink/table/client/cli/CliClient.java b/flink-table/flink-sql-client/src/main/java/org/apache/flink/table/client/cli/CliClient.java index eec69bc..d1fed89 100644 --- a/flink-table/flink-sql-client/src/main/java/org/apache/flink/table/client/cli/CliClient.java +++ b/flink-table/flink-sql-client/src/main/java/org/apache/flink/table/client/cli/CliClient.java @@ -278,7 +278,7 @@ public class CliClient { case USE_CATALOG: callUseCatalog(cmdCall); break; - case USE_DATABASE: + case USE: callUseDatabase(cmdCall); break; case DESCRIBE: diff --git a/flink-table/flink-sql-client/src/main/java/org/apache/flink/table/client/cli/CliStrings.java b/flink-table/flink-sql-client/src/main/java/org/apache/flink/table/client/cli/CliStrings.java index d68f56b..930ebbc 100644 --- a/flink-table/flink-sql-client/src/main/java/org/apache/flink/table/client/cli/CliStrings.java +++ b/flink-table/flink-sql-client/src/main/java/org/apache/flink/table/client/cli/CliStrings.java @@ -41,20 +41,22 @@ public final class CliStrings { public static final AttributedString MESSAGE_HELP = new AttributedStringBuilder() .append("The following commands are available:\n\n") - .append(formatCommand(SqlCommand.QUIT, "Quits the SQL CLI client.")) .append(formatCommand(SqlCommand.CLEAR, "Clears the current terminal.")) - .append(formatCommand(SqlCommand.HELP, "Prints the available commands.")) - .append(formatCommand(SqlCommand.SHOW_TABLES, "Shows all registered tables.")) - .append(formatCommand(SqlCommand.SHOW_FUNCTIONS, "Shows all registered user-defined functions.")) + .append(formatCommand(SqlCommand.CREATE_VIEW, "Creates a virtual table from a SQL query. Syntax: 'CREATE VIEW <name> AS <query>;'")) .append(formatCommand(SqlCommand.DESCRIBE, "Describes the schema of a table with the given name.")) + .append(formatCommand(SqlCommand.DROP_VIEW, "Deletes a previously created virtual table. Syntax: 'DROP VIEW <name>;'")) .append(formatCommand(SqlCommand.EXPLAIN, "Describes the execution plan of a query or table with the given name.")) - .append(formatCommand(SqlCommand.SELECT, "Executes a SQL SELECT query on the Flink cluster.")) + .append(formatCommand(SqlCommand.HELP, "Prints the available commands.")) .append(formatCommand(SqlCommand.INSERT_INTO, "Inserts the results of a SQL SELECT query into a declared table sink.")) - .append(formatCommand(SqlCommand.CREATE_VIEW, "Creates a virtual table from a SQL query. Syntax: 'CREATE VIEW <name> AS <query>;'")) - .append(formatCommand(SqlCommand.DROP_VIEW, "Deletes a previously created virtual table. Syntax: 'DROP VIEW <name>;'")) - .append(formatCommand(SqlCommand.SOURCE, "Reads a SQL SELECT query from a file and executes it on the Flink cluster.")) - .append(formatCommand(SqlCommand.SET, "Sets a session configuration property. Syntax: 'SET <key>=<value>;'. Use 'SET;' for listing all properties.")) + .append(formatCommand(SqlCommand.QUIT, "Quits the SQL CLI client.")) .append(formatCommand(SqlCommand.RESET, "Resets all session configuration properties.")) + .append(formatCommand(SqlCommand.SELECT, "Executes a SQL SELECT query on the Flink cluster.")) + .append(formatCommand(SqlCommand.SET, "Sets a session configuration property. Syntax: 'SET <key>=<value>;'. Use 'SET;' for listing all properties.")) + .append(formatCommand(SqlCommand.SHOW_FUNCTIONS, "Shows all registered user-defined functions.")) + .append(formatCommand(SqlCommand.SHOW_TABLES, "Shows all registered tables.")) + .append(formatCommand(SqlCommand.SOURCE, "Reads a SQL SELECT query from a file and executes it on the Flink cluster.")) + .append(formatCommand(SqlCommand.USE_CATALOG, "Sets the current catalog. The current database is set to the catalog's default one. Experimental! Syntax: 'USE CATALOG <name>;'")) + .append(formatCommand(SqlCommand.USE, "Sets the current default database. Experimental! Syntax: 'USE <name>;'")) .style(AttributedStyle.DEFAULT.underline()) .append("\nHint") .style(AttributedStyle.DEFAULT) diff --git a/flink-table/flink-sql-client/src/main/java/org/apache/flink/table/client/cli/SqlCommandParser.java b/flink-table/flink-sql-client/src/main/java/org/apache/flink/table/client/cli/SqlCommandParser.java index 049390a..d4026d7 100644 --- a/flink-table/flink-sql-client/src/main/java/org/apache/flink/table/client/cli/SqlCommandParser.java +++ b/flink-table/flink-sql-client/src/main/java/org/apache/flink/table/client/cli/SqlCommandParser.java @@ -103,7 +103,7 @@ public final class SqlCommandParser { "USE\\s+CATALOG\\s+(.*)", SINGLE_OPERAND), - USE_DATABASE( + USE( "USE\\s+(?!CATALOG)(.*)", SINGLE_OPERAND), diff --git a/flink-table/flink-sql-client/src/test/java/org/apache/flink/table/client/cli/SqlCommandParserTest.java b/flink-table/flink-sql-client/src/test/java/org/apache/flink/table/client/cli/SqlCommandParserTest.java index 4f903ee..fc5b8b3 100644 --- a/flink-table/flink-sql-client/src/test/java/org/apache/flink/table/client/cli/SqlCommandParserTest.java +++ b/flink-table/flink-sql-client/src/test/java/org/apache/flink/table/client/cli/SqlCommandParserTest.java @@ -75,7 +75,7 @@ public class SqlCommandParserTest { 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_DATABASE, new String[] {"default"})); + testValidSqlCommand("use default", new SqlCommandCall(SqlCommand.USE, new String[] {"default"})); testInvalidSqlCommand("use catalog"); }