Skip to content
Draft
Changes from all commits
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
Original file line number Diff line number Diff line change
Expand Up @@ -9,26 +9,7 @@
{%- set comment = streaming_table.config["comment"].comment -%}
{%- set refresh = streaming_table.config["refresh"] -%}

{%- set analysis_sql = sql | replace('STREAM ', '') | replace('stream ', '') -%}

{#
TODO: When DESCRIBE QUERY EXTENDED is supported, this implementation should be simplified
to use that instead. For now, we work around this limitation by writing results to a
temporary view and using DESCRIBE TABLE EXTENDED on the temporary view.
#}
{%- set temp_relation = make_temp_relation(relation) -%}
{% call statement('create_temp_view') -%}
{%- set view_sql = analysis_sql.rstrip('; \n\t') -%}
{{ create_temporary_view(temp_relation, view_sql) }}
{%- endcall %}

{%- set columns = adapter.get_columns_in_relation(temp_relation) -%}
{%- set model_columns = model.get('columns', {}) -%}
{%- set columns_and_constraints = adapter.parse_columns_and_constraints(columns, model_columns, []) -%}

{#-- We don't enrich the relation with model constraints because they are not supported for streaming tables --#}
CREATE STREAMING TABLE {{ relation.render() }}
{{ get_column_and_constraints_sql(relation, columns_and_constraints[0]) }}
{{ get_create_sql_partition_by(partition_by) }}
{{ liquid_clustered_cols() }}
{{ get_create_sql_comment(comment) }}
Expand Down