[Feature][dbt] add partition_type support (#9389)

This commit is contained in:
long2ice
2022-05-06 15:27:34 +08:00
committed by GitHub
parent 86b7717fe2
commit 7af79e1df5
3 changed files with 17 additions and 13 deletions

View File

@ -46,10 +46,16 @@ class Engine(str, Enum):
iceberg = "iceberg"
class PartitionType(str, Enum):
list = "LIST"
range = "RANGE"
class DorisConfig(AdapterConfig):
engine: Engine = Engine.olap
engine: Engine
duplicate_key: Tuple[str]
partition_by: Tuple[str]
partition_type: PartitionType
partition_by_init: List[str]
distributed_by: Tuple[str]
buckets: int

View File

@ -17,23 +17,20 @@
{% macro doris__engine() -%}
{% set label = 'ENGINE' %}
{% set engine = config.get('engine', validator=validation.any[basestring]) %}
{% if engine is not none %}
{% set engine = config.get('engine', 'OLAP', validator=validation.any[basestring]) %}
{{ label }} = {{ engine }}
{% else %}
{{ label }} = OLAP
{% endif %}
{%- endmacro %}
{% macro doris__partition_by() -%}
{% set cols = config.get('partition_by') %}
{% set partition_type = config.get('partition_type', 'RANGE') %}
{% if cols is not none %}
PARTITION BY RANGE (
PARTITION BY {{ partition_type }} (
{% for col in cols %}
{{ col }}{% if not loop.last %},{% endif %}
{% endfor %}
)(
{% set init = config.get('partition_by_init',validator=validation.any[list]) %}
{% set init = config.get('partition_by_init', validator=validation.any[list]) %}
{% if init is not none %}
{% for row in init %}
{{ row }}{% if not loop.last %},{% endif %}

View File

@ -16,11 +16,12 @@
-- under the License.
{% macro doris__create_table_as(temporary, relation, sql) -%}
{% set sql_header = config.get('sql_header', none) %}
{{ sql_header if sql_header is not none }}
create table {{ relation.include(database=False) }}
{% set sql_header = config.get('sql_header', none) %}
{% set table = relation.include(database=False) %}
{{ sql_header if sql_header is not none }}
create table {{ table }}
{{ doris__partition_by() }}
{{ doris__distributed_by() }}
{{ doris__properties() }} as {{ sql }}
{{ doris__properties() }} as {{ sql }};
insert into {{ table }} {{ sql }};
{%- endmacro %}