Merge pull request #43910 from FArthur-cmd/add_full_modifier

Add support for SHOW FULL
This commit is contained in:
Nikolay Degterinsky 2022-12-05 17:47:42 +01:00 committed by GitHub
commit 53b1b0fdc9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 37 additions and 2 deletions

View File

@ -111,7 +111,15 @@ String InterpreterShowTablesQuery::getRewrittenQuery()
DatabaseCatalog::instance().assertDatabaseExists(database);
WriteBufferFromOwnString rewritten_query;
rewritten_query << "SELECT name FROM system.";
if (query.full)
{
rewritten_query << "SELECT name, engine FROM system.";
}
else
{
rewritten_query << "SELECT name FROM system.";
}
if (query.dictionaries)
rewritten_query << "dictionaries ";

View File

@ -22,6 +22,7 @@ public:
bool changed{false};
bool temporary{false};
bool caches{false};
bool full{false};
String cluster_str;
String from;

View File

@ -18,6 +18,7 @@ namespace DB
bool ParserShowTablesQuery::parseImpl(Pos & pos, ASTPtr & node, Expected & expected)
{
ParserKeyword s_show("SHOW");
ParserKeyword s_full("FULL");
ParserKeyword s_temporary("TEMPORARY");
ParserKeyword s_tables("TABLES");
ParserKeyword s_databases("DATABASES");
@ -46,6 +47,11 @@ bool ParserShowTablesQuery::parseImpl(Pos & pos, ASTPtr & node, Expected & expec
if (!s_show.ignore(pos, expected))
return false;
if (s_full.ignore(pos, expected))
{
query->full = true;
}
if (s_databases.ignore(pos, expected))
{
query->databases = true;

View File

@ -14,7 +14,7 @@ namespace DB
class ParserShowTablesQuery : public IParserBase
{
protected:
const char * getName() const override { return "SHOW [TEMPORARY] TABLES|DATABASES|CLUSTERS|CLUSTER 'name' [[NOT] [I]LIKE 'str'] [LIMIT expr]"; }
const char * getName() const override { return "SHOW [FULL] [TEMPORARY] TABLES|DATABASES|CLUSTERS|CLUSTER 'name' [[NOT] [I]LIKE 'str'] [LIMIT expr]"; }
bool parseImpl(Pos & pos, ASTPtr & node, Expected & expected) override;
};

View File

@ -0,0 +1,2 @@
test_02480_table MergeTree
test_02480_view View

View File

@ -0,0 +1,18 @@
#!/usr/bin/env bash
CURDIR=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)
# shellcheck source=../shell_config.sh
. "$CURDIR"/../shell_config.sh
database=$($CLICKHOUSE_CLIENT -q 'SELECT currentDatabase()')
$CLICKHOUSE_CLIENT -nm -q "
DROP TABLE IF EXISTS test_02480_table;
DROP VIEW IF EXISTS test_02480_view;
CREATE TABLE test_02480_table (id Int64) ENGINE=MergeTree ORDER BY id;
CREATE VIEW test_02480_view AS SELECT * FROM test_02480_table;
SHOW FULL TABLES FROM $database LIKE '%';
DROP TABLE IF EXISTS test_02480_table;
DROP VIEW IF EXISTS test_02480_view;
"