2020-08-28 14:07:14 +00:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include <TableFunctions/ITableFunction.h>
|
2020-10-14 12:19:29 +00:00
|
|
|
#include <Parsers/ASTCreateQuery.h>
|
2021-10-02 07:13:14 +00:00
|
|
|
#include <base/types.h>
|
2020-08-28 14:07:14 +00:00
|
|
|
|
|
|
|
namespace DB
|
|
|
|
{
|
|
|
|
|
|
|
|
/* view(query)
|
|
|
|
* Turning subquery into a table.
|
|
|
|
* Useful for passing subquery around.
|
|
|
|
*/
|
|
|
|
class TableFunctionView : public ITableFunction
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
static constexpr auto name = "view";
|
2023-01-26 10:52:40 +00:00
|
|
|
|
2020-08-28 14:07:14 +00:00
|
|
|
std::string getName() const override { return name; }
|
2022-02-18 14:42:32 +00:00
|
|
|
|
|
|
|
const ASTSelectWithUnionQuery & getSelectQuery() const;
|
|
|
|
|
2020-08-28 14:07:14 +00:00
|
|
|
private:
|
2023-07-06 08:56:07 +00:00
|
|
|
StoragePtr executeImpl(const ASTPtr & ast_function, ContextPtr context, const String & table_name, ColumnsDescription cached_columns, bool is_insert_query) const override;
|
2023-01-26 10:52:40 +00:00
|
|
|
|
2020-08-28 14:07:14 +00:00
|
|
|
const char * getStorageTypeName() const override { return "View"; }
|
|
|
|
|
2023-01-26 10:52:40 +00:00
|
|
|
std::vector<size_t> skipAnalysisForArguments(const QueryTreeNodePtr & query_node_table_function, ContextPtr context) const override;
|
|
|
|
|
2021-04-10 23:33:54 +00:00
|
|
|
void parseArguments(const ASTPtr & ast_function, ContextPtr context) override;
|
2023-01-26 10:52:40 +00:00
|
|
|
|
2023-07-06 08:56:07 +00:00
|
|
|
ColumnsDescription getActualTableStructure(ContextPtr context, bool is_insert_query) const override;
|
2020-10-14 12:19:29 +00:00
|
|
|
|
|
|
|
ASTCreateQuery create;
|
2020-08-28 14:07:14 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
}
|