Skip to content

Commit 2b394c4

Browse files
committedSep 7, 2023
Output '*' in union_relations when no columns are found in compile mode
This is to handle the scenario where the upstream relations haven't been run, and you run SQLFluff against a model using union_relations, with source_column_name=None.
1 parent 6ba7b66 commit 2b394c4

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed
 

‎macros/sql/union.sql

+6
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,12 @@
103103
cast({{ dbt.string_literal(relation) }} as {{ dbt.type_string() }}) as {{ source_column_name }},
104104
{%- endif %}
105105

106+
/* No columns from any of the relations.
107+
This star is only output during dbt compile, and exists to keep SQLFluff happy. */
108+
{% if dbt_command == 'compile' and ordered_column_names|length == 0 %}
109+
*
110+
{% endif %}
111+
106112
{% for col_name in ordered_column_names -%}
107113

108114
{%- set col = column_superset[col_name] %}

0 commit comments

Comments
 (0)