mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-12-15 02:41:59 +00:00
5678d1ed98
* StorageSystemContributors clean * Fix * ARM fixes * Fix arm compile * fix * Fix macos? * Fix includes * fix * fix * Try fix apple build part 1 * Fix identation * Fix static libc++ in clang * fix arm build * better * fix * fix * better check-include
48 lines
1.6 KiB
C++
48 lines
1.6 KiB
C++
#pragma once
|
|
|
|
#include <memory>
|
|
#include <optional>
|
|
#include <Core/Types.h>
|
|
#include <Parsers/ASTSelectQuery.h>
|
|
|
|
namespace DB
|
|
{
|
|
|
|
class IAST;
|
|
using ASTPtr = std::shared_ptr<IAST>;
|
|
|
|
class ASTSelectQuery;
|
|
class ASTIdentifier;
|
|
struct ASTTableExpression;
|
|
|
|
|
|
/// Extracts database name (and/or alias) from table expression or identifier
|
|
struct DatabaseAndTableWithAlias
|
|
{
|
|
String database;
|
|
String table;
|
|
String alias;
|
|
|
|
DatabaseAndTableWithAlias(const ASTIdentifier & identifier, const String & current_database = "");
|
|
DatabaseAndTableWithAlias(const ASTTableExpression & table_expression, const String & current_database);
|
|
|
|
/// "alias." or "database.table." if alias is empty
|
|
String getQualifiedNamePrefix() const;
|
|
|
|
/// If ast is ASTIdentifier, prepend getQualifiedNamePrefix() to it's name.
|
|
void makeQualifiedName(const ASTPtr & ast) const;
|
|
};
|
|
|
|
void stripIdentifier(DB::ASTPtr & ast, size_t num_qualifiers_to_strip);
|
|
|
|
size_t getNumComponentsToStripInOrderToTranslateQualifiedName(const ASTIdentifier & identifier,
|
|
const DatabaseAndTableWithAlias & names);
|
|
|
|
std::vector<DatabaseAndTableWithAlias> getDatabaseAndTables(const ASTSelectQuery & select_query, const String & current_database);
|
|
std::optional<DatabaseAndTableWithAlias> getDatabaseAndTable(const ASTSelectQuery & select, size_t table_number);
|
|
|
|
std::vector<const ASTTableExpression *> getSelectTablesExpression(const ASTSelectQuery & select_query);
|
|
ASTPtr getTableFunctionOrSubquery(const ASTSelectQuery & select, size_t table_number);
|
|
|
|
}
|