create macro m1(arg1 boolean := false) as
(select arg1);
create macro m2(arg1) as
(select m1(arg1 = arg1));
select macro m2(false);
-- result is TRUE because in the definition of m2,
-- the result of comparing the argument with itself (arg1 = arg1 ) is passed into m1
-- rather than assigning the value of m2's arg1 to m1's arg1
Suggesting some points of improvement:
param-nameandparam-name := default-valueappear as if in a required succession, while they really should be alternativesAS-clause can be repeteated. This repetition should apply to the parameter declarations:=. This is the only correct way to assign values to macro parameters, while built-in functions with named parameters may also support plain '='. This can be a real gotcha, especially when passing parameters from one macro to the next, because an expression likea = ais still valid - it's just that it evaluates toTRUErather than assigning the value of theaparameter from the outer macro to theaparameter of the macro being called. For example:Page URL: https://duckdb.org/docs/current/sql/statements/create_macro.html