Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Store unqualified macro parameters, qualify before binding #10266

Merged
merged 2 commits into from
Jan 18, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
qualify macro parameters right before binding
  • Loading branch information
lnkuiper committed Jan 18, 2024
commit d3ff14cb6abe662531d8fe216ed602cebf3cb1cc
5 changes: 5 additions & 0 deletions src/planner/binder/expression/bind_macro_expression.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,11 @@ BindResult ExpressionBinder::BindMacro(FunctionExpression &function, ScalarMacro
// replace current expression with stored macro expression
expr = macro_def.expression->Copy();

// qualify only the macro parameters with a new empty binder that only knows the macro binding
auto dummy_binder = Binder::CreateBinder(context);
dummy_binder->macro_binding = new_macro_binding.get();
ExpressionBinder::QualifyColumnNames(*dummy_binder, expr);

// now replace the parameters
vector<unordered_set<string>> lambda_params;
ReplaceMacroParameters(expr, lambda_params);
Expand Down
6 changes: 3 additions & 3 deletions test/sql/catalog/function/test_simple_macro.test
Original file line number Diff line number Diff line change
Expand Up @@ -334,13 +334,13 @@ create macro zz2(x) as 20+x;
query II
select zz1(1),zz2(2);
----
a
11 22

# should not return any results
# should not return any results (because we shouldn't display "macro_parameters"
query III
select function_name, parameters, macro_definition
from duckdb_functions()
where function_name like 'zz%'
and macro_definition not like '%macro_parameters%';
and macro_definition like '%macro_parameters%';
----

Loading