Skip to content

Commit

Permalink
Fix Invalid Quoting Around Partitioning (#277)
Browse files Browse the repository at this point in the history
### Summary

When using `partition_by`, dbt-dremio could be causing invalid
statements to partition columns, surrounding the way quotation was being
handled.

### Description

The sistematic double quoting has been removed from the connector's
logic, stopping such situations from happening and leaving quotation to
be decided by the user. An example of a table materialization under this
new logic is:

```
{{
    config(
        materialized = 'table',
        partition_by = ['forecast_effective_date', 'year("datetime_utc")', 'month("datetime_hour_ending_utc")']
    )
}}
```

### Test Results

n/a

### Changelog

-   [X] Added a summary of what this PR accomplishes to CHANGELOG.md

### Contributor License Agreement

<!--- Applicable for non Dremio employees and for first time
contributors -->

- [X] Please make sure you have signed our [Contributor License
Agreement](https://www.dremio.com/legal/contributor-agreement/), which
enables Dremio to distribute your contribution without restriction.

### Related Issue

#201
  • Loading branch information
bcmeireles authored Feb 12, 2025
1 parent 050a948 commit 261b1bd
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 5 deletions.
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@
- Grants can now be set for both users and for roles. A prefix was added to handle this, with `user:` and `role:` being the valid prefixes. For example, `user:dbt_test_user_1` and `role:dbt_test_role_1`. If no prefix is provided, defaults to user for backwards compatibility.
- Moves the `raw_on_schema_change` variable back into scope for the config validator
- Adds `BaseIncrementalOnSchemaChange` test to test_incremental.py

- Changed logic for partitioning when materializing tables. Double quoting issue has been removed, now letting the user decide the quoting
- New example: `partition_by=['month("datetime_utc")']`
## Features

- [#259](https://github.com/dremio/dbt-dremio/pull/259) Added support for roles in grants
Expand Down
5 changes: 1 addition & 4 deletions dbt/include/dremio/macros/materializations/helpers.sql
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,7 @@ limitations under the License.*/
{%- set cols = [cols] -%}
{%- endif -%}
{{ label }} (
{%- for item in cols -%}
{{ adapter.quote(item) }}
{%- if not loop.last -%},{%- endif -%}
{%- endfor -%}
{{ cols | join(', ') }}
)
{%- endif %}
{%- endmacro -%}
Expand Down

0 comments on commit 261b1bd

Please sign in to comment.