You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
If there are no columns returned in the macro it returns as commented out block but the issue is if the star macro isn't the last selected field in a select statement, it will place a comma on the outside of the comment block.
-- example
with
final as (
select
{{ dbt_utils.star( ref("foo")) }},
{{ dbt_utils.star( ref("bar")) }}
from ...
)
select*from final
-- In this example let say the table foo doesn't return any columns. The compiled code looking like
with
final as (
select/* no columns returned from star() macro */,
bar_column1,
bar_column2...
from ...
)
select*from final
-- The above will fail to execute due to the comma outside of the comment block.
Simple fix would be to change the method being used to comment to simple double dash. Also believe this change will still comply with SQLFluff.
The addition of , will help the user remind that something is missing otherwise, one might totally miss the issue that the first Ref isn't returning any column
If there are no columns returned in the macro it returns as commented out block but the issue is if the star macro isn't the last selected field in a select statement, it will place a comma on the outside of the comment block.
Simple fix would be to change the method being used to comment to simple double dash. Also believe this change will still comply with SQLFluff.
Reference source line
dbt-utils/macros/sql/star.sql
Line 26 in fc98e4e
The text was updated successfully, but these errors were encountered: