From 93d28ef5c9c0d425c74c674db485597c418cbdb0 Mon Sep 17 00:00:00 2001 From: hexiaoting Date: Tue, 22 Dec 2020 21:48:40 +0800 Subject: [PATCH] Implement untuple field access (#18309) --- src/Interpreters/TreeRewriter.cpp | 11 +++++++++++ .../0_stateless/01616_untuple_access_field.reference | 1 + .../0_stateless/01616_untuple_access_field.sql | 1 + 3 files changed, 13 insertions(+) create mode 100644 tests/queries/0_stateless/01616_untuple_access_field.reference create mode 100644 tests/queries/0_stateless/01616_untuple_access_field.sql diff --git a/src/Interpreters/TreeRewriter.cpp b/src/Interpreters/TreeRewriter.cpp index 1ad22efc3fc..92ff4e69817 100644 --- a/src/Interpreters/TreeRewriter.cpp +++ b/src/Interpreters/TreeRewriter.cpp @@ -286,6 +286,17 @@ void removeUnneededColumnsFromSelectClause(const ASTSelectQuery * select_query, { new_elements.push_back(elem); } + else + { + ASTFunction * func = elem->as(); + if (func && func->name == "untuple") + for (const auto & col : required_result_columns) + if (col.rfind("_ut_", 0) == 0) + { + new_elements.push_back(elem); + break; + } + } } elements = std::move(new_elements); diff --git a/tests/queries/0_stateless/01616_untuple_access_field.reference b/tests/queries/0_stateless/01616_untuple_access_field.reference new file mode 100644 index 00000000000..d00491fd7e5 --- /dev/null +++ b/tests/queries/0_stateless/01616_untuple_access_field.reference @@ -0,0 +1 @@ +1 diff --git a/tests/queries/0_stateless/01616_untuple_access_field.sql b/tests/queries/0_stateless/01616_untuple_access_field.sql new file mode 100644 index 00000000000..569efca5349 --- /dev/null +++ b/tests/queries/0_stateless/01616_untuple_access_field.sql @@ -0,0 +1 @@ +select _ut_1 from (select untuple((1,2)));