[Feature][dbt] add partition_type support (#9389)
This commit is contained in:
@ -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
|
||||
|
||||
@ -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 %}
|
||||
|
||||
@ -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 %}
|
||||
|
||||
Reference in New Issue
Block a user