Skip to content

Commit

Permalink
Merge pull request #9904 from Mytherin/issue9867
Browse files Browse the repository at this point in the history
Fix #9867 - correctly propagate relation name in COLUMNS expression
  • Loading branch information
Mytherin committed Dec 6, 2023
2 parents 3cadd21 + 84d0880 commit 6867e58
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/parser/transform/expression/transform_columnref.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ unique_ptr<ParsedExpression> Transformer::TransformStarExpression(duckdb_libpgqu
result->expr = TransformExpression(star.expr);
if (result->expr->type == ExpressionType::STAR) {
auto &child_star = result->expr->Cast<StarExpression>();
result->relation_name = child_star.relation_name;
result->exclude_list = std::move(child_star.exclude_list);
result->replace_list = std::move(child_star.replace_list);
result->expr.reset();
Expand Down
31 changes: 31 additions & 0 deletions test/sql/parser/columns_issue9867.test
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# name: test/sql/parser/columns_issue9867.test
# description: Issue #9867 - COLUMNS(table_name.*) is broken when there are joins
# group: [parser]

statement ok
PRAGMA enable_verification

statement ok
CREATE TABLE df1 AS
SELECT
UNNEST(['K0', 'K1', 'K2', 'K3', 'K4', 'K5']) AS key,
UNNEST([11, 12, 13, 14, 15, 16]) AS A,
UNNEST([21, 22, 23, 24, 25, 26]) AS B

statement ok
CREATE TABLE df2 AS
SELECT
UNNEST(['K0', 'K2', 'K5']) AS key,
UNNEST([2, 3, 5]) AS C

query II
select sin(columns(df1.* exclude (key))) from df1 join df2 using(key)
----
-0.9999902065507035 0.836655638536056
0.4201670368266409 -0.8462204041751706
-0.2879033166650653 0.7625584504796027

statement error
select sin(columns(dfxx.* exclude (key))) from df1 join df2 using(key)
----
Referenced table "dfxx" not found

0 comments on commit 6867e58

Please sign in to comment.