mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-17 21:24:28 +00:00
48 lines
1.0 KiB
C++
48 lines
1.0 KiB
C++
|
#pragma once
|
||
|
|
||
|
#include <DB/Parsers/IAST.h>
|
||
|
#include <DB/Analyzers/CollectTables.h>
|
||
|
#include <unordered_map>
|
||
|
|
||
|
|
||
|
namespace DB
|
||
|
{
|
||
|
|
||
|
class WriteBuffer;
|
||
|
class CollectAliases;
|
||
|
class CollectTables;
|
||
|
|
||
|
|
||
|
/** For every identifier, that is not an alias,
|
||
|
* determine from what table it comes,
|
||
|
* its original name in table,
|
||
|
* and its data type.
|
||
|
*
|
||
|
* Also:
|
||
|
* - expand asterisks (such as *, t.*, db.table.* and (TODO) even db.table.nested.*) to corresponding list of columns;
|
||
|
* - translate count(*) to count();
|
||
|
* - expand alias columns that come from table definition.
|
||
|
*
|
||
|
* If column is not found or in case of ambiguity, throw an exception.
|
||
|
*/
|
||
|
struct AnalyzeColumns
|
||
|
{
|
||
|
void process(ASTPtr & ast, const CollectAliases & aliases, const CollectTables & tables);
|
||
|
|
||
|
struct ColumnInfo
|
||
|
{
|
||
|
ASTPtr node;
|
||
|
CollectTables::TableInfo table;
|
||
|
String name_in_table;
|
||
|
DataTypePtr data_type;
|
||
|
};
|
||
|
|
||
|
using Columns = std::unordered_map<String, ColumnInfo>;
|
||
|
Columns columns;
|
||
|
|
||
|
/// Debug output
|
||
|
void dump(WriteBuffer & out) const;
|
||
|
};
|
||
|
|
||
|
}
|