[Feature] Support set order by for dbt (#38941)

Signed-off-by: Astralidea <astralidea@163.com>
This commit is contained in:
Xueyan Li 2024-01-12 11:22:02 +08:00 committed by GitHub
parent e210aac09d
commit 2cc316330a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 17 additions and 5 deletions

View File

@ -87,9 +87,10 @@ models:
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'))"]
// RANGE, LIST, or Expr partition types should be used in conjunction with partition_by configuration
// Expr partition type requires an expression (e.g., date_trunc) specified in partition_by
order_by: ['some_column'] // only for PRIMARY table_type
partition_type: 'RANGE' // RANGE or LIST or Expr Need to be used in combination with partition_by configuration
properties: [{"replication_num":"1", "in_memory": "true"}]
refresh_method: 'async' // only for materialized view default manual
refresh_method: 'async' // only for materialized view default manual
```
### dbt run config:
@ -98,6 +99,7 @@ models:
{{ config(materialized='view') }}
{{ config(materialized='table', engine='OLAP', buckets=32, distributed_by=['id']) }}
{{ config(materialized='table', partition_by=['date_trunc("day", first_order)'], partition_type='Expr') }}
{{ config(materialized='table', table_type='PRIMARY', keys=['customer_id'], order_by=['first_name', 'last_name'] }}
{{ 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"}) }}

View File

@ -13,4 +13,4 @@
# See the License for the specific language governing permissions and
# limitations under the License.
version = "1.4.1"
version = "1.4.2"

View File

@ -21,8 +21,9 @@
{%- set table_type = config.get('table_type', 'DUPLICATE') -%}
{%- set keys = config.get('keys') -%}
{%- set partition_by = config.get('partition_by') -%}
{%- set partition_type = config.get('partition_type', 'RANGE') -%}
{%- set partition_by_init = config.get('partition_by_init') -%}
{%- set order_by = config.get('order_by') -%}
{%- set partition_type = config.get('partition_type', 'RANGE') -%}
{%- set buckets = config.get('buckets', 10) -%}
{%- set distributed_by = config.get('distributed_by') -%}
{%- set properties = config.get('properties') -%}
@ -97,7 +98,16 @@
{{ exceptions.raise_compiler_error(msg) }}
{% endif -%}
{# 4. SET PROPERTIES #}
{# 5. SET ORDER BY #}
{%- if order_by is not none %}
ORDER BY (
{%- for item in order_by -%}
{{ item }} {%- if not loop.last -%}, {%- endif -%}
{%- endfor -%}
)
{% endif -%}
{# 6. SET PROPERTIES #}
{%- if properties is not none %}
PROPERTIES (
{% for key, value in properties.items() -%}

View File

@ -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.4.1"
package_version = "1.4.2"
description = """The Starrocks adapter plugin for dbt"""