From cdadef78471b47d05d6d1c437a823b17f8867991 Mon Sep 17 00:00:00 2001 From: Vitaly Baranov Date: Thu, 18 Jul 2024 21:26:33 +0200 Subject: [PATCH] Add more comments. --- src/Parsers/ASTViewTargets.h | 21 +++++++++++++++++---- src/Parsers/ParserViewTargets.h | 7 ++++++- 2 files changed, 23 insertions(+), 5 deletions(-) diff --git a/src/Parsers/ASTViewTargets.h b/src/Parsers/ASTViewTargets.h index 33a7bc5fcb1..12182919f0e 100644 --- a/src/Parsers/ASTViewTargets.h +++ b/src/Parsers/ASTViewTargets.h @@ -9,15 +9,20 @@ namespace DB class ASTStorage; enum class Keyword : size_t; -/// Information about the target table for a materialized view or a window view. +/// Information about target tables (external or inner) of a materialized view or a window view. +/// See ASTViewTargets for more details. struct ViewTarget { enum Kind { - /// Target table for a materialized view or a window view. + /// If `kind == ViewTarget::To` then `ViewTarget` contains information about the "TO" table of a materialized view or a window view: + /// CREATE MATERIALIZED VIEW db.mv_name {TO [db.]to_target | ENGINE to_engine} AS SELECT ... + /// or + /// CREATE WINDOW VIEW db.wv_name {TO [db.]to_target | ENGINE to_engine} AS SELECT ... To, - /// Table with intermediate results for a window view. + /// If `kind == ViewTarget::Inner` then `ViewTarget` contains information about the "INNER" table of a window view: + /// CREATE WINDOW VIEW db.wv_name {INNER ENGINE inner_engine} AS SELECT ... Inner, }; @@ -42,7 +47,15 @@ std::string_view toString(ViewTarget::Kind kind); void parseFromString(ViewTarget::Kind & out, std::string_view str); -/// Information about all the target tables for a view. +/// Information about all target tables (external or inner) of a view. +/// +/// For example, for a materialized view: +/// CREATE MATERIALIZED VIEW db.mv_name [TO [db.]to_target | ENGINE to_engine] AS SELECT ... +/// this class contains information about the "TO" table: its name and database (if it's external), its UUID and engine (if it's inner). +/// +/// For a window view: +/// CREATE WINDOW VIEW db.wv_name [TO [db.]to_target | ENGINE to_engine] [INNER ENGINE inner_engine] AS SELECT ... +/// this class contains information about both the "TO" table and the "INNER" table. class ASTViewTargets : public IAST { public: diff --git a/src/Parsers/ParserViewTargets.h b/src/Parsers/ParserViewTargets.h index f5d1850e974..3af3c0b8df3 100644 --- a/src/Parsers/ParserViewTargets.h +++ b/src/Parsers/ParserViewTargets.h @@ -7,7 +7,12 @@ namespace DB { -/// Parses information about target views of a table. +/// Parses information about target tables (external or inner) of a materialized view or a window view. +/// The function parses one or multiple parts of a CREATE query looking like this: +/// TO db.table_name +/// TO INNER UUID 'XXX' +/// {ENGINE / INNER ENGINE} TableEngine(arguments) [ORDER BY ...] [SETTINGS ...] +/// Returns ASTViewTargets if succeeded. class ParserViewTargets : public IParserBase { public: