-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
317bd71
commit 4b2f057
Showing
2 changed files
with
78 additions
and
37 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,33 +1,42 @@ | ||
{% materialization sink, adapter='risingwave' %} | ||
{%- set identifier = model['alias'] -%} | ||
{%- set full_refresh_mode = should_full_refresh() -%} | ||
{%- set old_relation = adapter.get_relation(identifier=identifier, | ||
schema=schema, | ||
database=database) -%} | ||
{%- set target_relation = api.Relation.create(identifier=identifier, | ||
schema=schema, | ||
database=database, | ||
type='sink') -%} | ||
{% materialization sink, adapter = "risingwave" %} | ||
{%- set identifier = model["alias"] -%} | ||
{%- set full_refresh_mode = should_full_refresh() -%} | ||
{%- set old_relation = adapter.get_relation( | ||
identifier=identifier, | ||
schema=schema, | ||
database=database, | ||
) -%} | ||
{%- set target_relation = api.Relation.create( | ||
identifier=identifier, | ||
schema=schema, | ||
database=database, | ||
type="sink", | ||
) -%} | ||
|
||
{% if full_refresh_mode and old_relation %} | ||
{{ adapter.drop_relation(old_relation) }} | ||
{% endif %} | ||
{% if full_refresh_mode and old_relation %} | ||
{{ adapter.drop_relation(old_relation) }} | ||
{% endif %} | ||
|
||
{{ run_hooks(pre_hooks, inside_transaction=False) }} | ||
{{ run_hooks(pre_hooks, inside_transaction=True) }} | ||
{{ run_hooks(pre_hooks, inside_transaction=False) }} | ||
{{ run_hooks(pre_hooks, inside_transaction=True) }} | ||
|
||
{% if old_relation is none or (full_refresh_mode and old_relation) %} | ||
{% call statement('main') -%} | ||
{{ risingwave__run_sql(sql) }} | ||
{%- endcall %} | ||
{% else %} | ||
{{ risingwave__execute_no_op(target_relation) }} | ||
{% endif %} | ||
{% if old_relation is none or (full_refresh_mode and old_relation) %} | ||
{%- set connector = config.get("connector") -%} | ||
{% call statement("main") -%} | ||
{% if connector %} | ||
{{ rising_wave__create_sink(target_relation, sql) }} | ||
{% else %} | ||
{{ risingwave__run_sql(sql) }} | ||
{% endif %} | ||
{%- endcall %} | ||
{% else %} | ||
{{ risingwave__execute_no_op(target_relation) }} | ||
{% endif %} | ||
|
||
{% do persist_docs(target_relation, model) %} | ||
{% do persist_docs(target_relation, model) %} | ||
|
||
{{ run_hooks(post_hooks, inside_transaction=False) }} | ||
{{ run_hooks(post_hooks, inside_transaction=True) }} | ||
{{ run_hooks(post_hooks, inside_transaction=False) }} | ||
{{ run_hooks(post_hooks, inside_transaction=True) }} | ||
|
||
{{ return({'relations': [target_relation]}) }} | ||
{{ return({"relations": [target_relation]}) }} | ||
{% endmaterialization %} |