1
0
mirror of https://github.com/mariadb-corporation/mariadb-columnstore-engine.git synced 2025-07-29 08:21:15 +03:00

MCOL-5357 Fix TPC-DS query error "MCS-3009: Unknown column '.<colname>'".

For the following query:

select item from (
select item from (select a as item from t1) tt
union all
select item from (select a as item from t1) tt
) ttt;

There is an if predicate in buildSimpleColFromDerivedTable() that compares
the outermost query field name (ttt.item) to the returned column list of
the inner query (tt.item) when building the returned column list of the
outer most query. In the above query example, the inner query field name
is an alias set in the inner most query and is set to "`tt`.`item`",
while the outermost query field name is set to "item". The use of
backticks "`" in the inner query alias is causing the execution to
not enter the if block which creates the SimpleColumn for the outermost
query field name. As a fix, we strip off the backticks from the inner
query alias.
This commit is contained in:
Gagan Goel
2023-05-02 15:10:41 -04:00
parent 5278865430
commit 982db10f10
3 changed files with 56 additions and 0 deletions

View File

@ -2454,6 +2454,20 @@ SimpleColumn* buildSimpleColFromDerivedTable(gp_walk_info& gwi, Item_field* ifp)
SimpleColumn* col = dynamic_cast<SimpleColumn*>(cols[j].get());
string alias = cols[j]->alias();
// MCOL-5357 For the following query:
// select item from (
// select item from (select a as item from t1) tt
// union all
// select item from (select a as item from t1) tt
// ) ttt;
// When the execution reaches the outermost item (ttt.item),
// alias = "`tt`.`item`" and ifp->field_name.str = "item".
// To make the execution enter the if block below, we strip off
// the backticks from alias.
boost::erase_all(alias, "`");
if (strcasecmp(ifp->field_name.str, alias.c_str()) == 0 ||
(col && alias.find(".") != string::npos &&
(strcasecmp(ifp->field_name.str, col->columnName().c_str()) == 0 ||