[Feature] dbt Materialized views support more configuration parameters (#30324)
* Materialized views support more configuration parameters Signed-off-by: Astralidea <astralidea@163.com>
This commit is contained in:
parent
9f71078d07
commit
f72495f00c
|
|
@ -85,16 +85,20 @@ models:
|
|||
partition_by: ['some_date']
|
||||
partition_by_init: ["PARTITION p1 VALUES [('1971-01-01 00:00:00'), ('1991-01-01 00:00:00')),PARTITION p1972 VALUES [('1991-01-01 00:00:00'), ('1999-01-01 00:00:00'))"]
|
||||
properties: [{"replication_num":"1", "in_memory": "true"}]
|
||||
refresh_method: 'async' // only for materialized view default manual
|
||||
```
|
||||
|
||||
### dbt run config:
|
||||
#### Example configuration:
|
||||
```
|
||||
{{ config(materialized='view') }}
|
||||
{{ config(materialized='materialized_view') }}
|
||||
{{ config(materialized='table', engine='OLAP', buckets=32, distributed_by=['id']) }}
|
||||
{{ config(materialized='incremental', table_type='PRIMARY', engine='OLAP', buckets=32, distributed_by=['id']) }}
|
||||
{{ config(materialized='materialized_view') }}
|
||||
{{ config(materialized='materialized_view', properties={"storage_medium":"SSD"}) }}
|
||||
{{ config(materialized='materialized_view', refresh_method="ASYNC START('2022-09-01 10:00:00') EVERY (interval 1 day)") }}
|
||||
```
|
||||
For materialized view only support partition_by、buckets、distributed_by、properties、refresh_method configuration.
|
||||
|
||||
## Test Adapter
|
||||
consult [the project](https://github.com/dbt-labs/dbt-adapter-tests)
|
||||
|
|
|
|||
|
|
@ -13,4 +13,4 @@
|
|||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
version = "1.3.0"
|
||||
version = "1.3.1"
|
||||
|
|
|
|||
|
|
@ -8,9 +8,48 @@
|
|||
{%- endmacro %}
|
||||
|
||||
{% macro starrocks__get_create_materialized_view_as_sql(relation, sql) %}
|
||||
create materialized view {{ relation }} refresh manual
|
||||
|
||||
{%- set partition_by = config.get('partition_by') -%}
|
||||
{%- set buckets = config.get('buckets') -%}
|
||||
{%- set distributed_by = config.get('distributed_by') -%}
|
||||
{%- set properties = config.get('properties') -%}
|
||||
{%- set refresh_method = config.get('refresh_method', 'manual') -%}
|
||||
|
||||
create materialized view {{ relation }}
|
||||
|
||||
{%- if partition_by is not none -%}
|
||||
PARTITION BY (
|
||||
{%- for col in partition_by -%}
|
||||
{{ col }} {%- if not loop.last -%}, {%- endif -%}
|
||||
{%- endfor -%}
|
||||
)
|
||||
{%- endif -%}
|
||||
|
||||
{%- if distributed_by is not none %}
|
||||
DISTRIBUTED BY HASH (
|
||||
{%- for item in distributed_by -%}
|
||||
{{ item }} {%- if not loop.last -%}, {%- endif -%}
|
||||
{%- endfor -%} )
|
||||
{%- if buckets is not none %}
|
||||
BUCKETS {{ buckets }}
|
||||
{% endif -%}
|
||||
{%- elif adapter.is_before_version("3.1.0") -%}
|
||||
{%- set msg -%}
|
||||
[distributed_by] must set before version 3.1, current version is {{ adapter.current_version() }}
|
||||
{%- endset -%}
|
||||
{{ exceptions.raise_compiler_error(msg) }}
|
||||
{% endif -%}
|
||||
refresh {{ refresh_method }}
|
||||
{% if properties is not none %}
|
||||
PROPERTIES (
|
||||
{% for key, value in properties.items() %}
|
||||
"{{ key }}" = "{{ value }}"{% if not loop.last %},{% endif %}
|
||||
{% endfor %}
|
||||
)
|
||||
{% endif %}
|
||||
as
|
||||
{{ sql }};
|
||||
|
||||
{% endmacro %}
|
||||
|
||||
{% macro starrocks__get_drop_relation_sql(relation) %}
|
||||
|
|
|
|||
|
|
@ -41,7 +41,7 @@ with open(os.path.join(this_directory, "README.md")) as f:
|
|||
|
||||
package_name = "dbt-starrocks"
|
||||
# make sure this always matches dbt/adapters/starrocks/__version__.py
|
||||
package_version = "1.3.0"
|
||||
package_version = "1.3.1"
|
||||
description = """The Starrocks adapter plugin for dbt"""
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue