Skip to content

Commit

Permalink
use column name in group by in get_column_values (#407)
Browse files Browse the repository at this point in the history
Most database engines (e.g. all SQL Server versions) don't support grouping by the position of the column.
  • Loading branch information
sdebruyn authored Sep 15, 2021
1 parent 869a6c9 commit fc18046
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion macros/sql/get_column_values.sql
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
{{ column }} as value

from {{ target_relation }}
group by 1
group by {{ column }}
order by {{ order_by }}

{% if max_records is not none %}
Expand Down

1 comment on commit fc18046

@LewisatLondon
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hello,

This seems a reasonable change, but it has limited the way I can use this method. One of method that I have used is to concat(field_1, "_", field_2), so I can use field_1 as a condition and then assign field_2 value.

You may suggest that I can use get_query_as_dict method. that's correct. I then hit another problem - SQLfluff doesn't like get_query_as_dict that much... tough call right..

Please sign in to comment.