-
Notifications
You must be signed in to change notification settings - Fork 93
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'duckdb:master' into feature/refactor-external-materiali…
…zation
- Loading branch information
Showing
13 changed files
with
229 additions
and
24 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,97 @@ | ||
name: Publish Python 🐍 distribution 📦 to PyPI | ||
|
||
on: | ||
push: | ||
tags: | ||
- '[0-9]+.[0-9]+.[0-9]+' | ||
|
||
jobs: | ||
build: | ||
name: Build distribution 📦 | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- uses: actions/checkout@v4 | ||
- name: Set up Python | ||
uses: actions/setup-python@v5 | ||
with: | ||
python-version: "3.x" | ||
- name: Install pypa/build | ||
run: >- | ||
python3 -m | ||
pip install | ||
build | ||
--user | ||
- name: Build a binary wheel and a source tarball | ||
run: python3 -m build | ||
- name: Store the distribution packages | ||
uses: actions/upload-artifact@v3 | ||
with: | ||
name: python-package-distributions | ||
path: dist/ | ||
|
||
publish-to-pypi: | ||
name: >- | ||
Publish Python 🐍 distribution 📦 to PyPI | ||
if: startsWith(github.ref, 'refs/tags/') # only publish to PyPI on tag pushes | ||
needs: | ||
- build | ||
runs-on: ubuntu-latest | ||
environment: | ||
name: pypi | ||
url: https://pypi.org/p/dbt-duckdb | ||
permissions: | ||
id-token: write # IMPORTANT: mandatory for trusted publishing | ||
|
||
steps: | ||
- name: Download all the dists | ||
uses: actions/download-artifact@v3 | ||
with: | ||
name: python-package-distributions | ||
path: dist/ | ||
- name: Publish distribution 📦 to PyPI | ||
uses: pypa/gh-action-pypi-publish@release/v1 | ||
|
||
github-release: | ||
name: >- | ||
Sign the Python 🐍 distribution 📦 with Sigstore | ||
and upload them to GitHub Release | ||
needs: | ||
- publish-to-pypi | ||
runs-on: ubuntu-latest | ||
|
||
permissions: | ||
contents: write # IMPORTANT: mandatory for making GitHub Releases | ||
id-token: write # IMPORTANT: mandatory for sigstore | ||
|
||
steps: | ||
- name: Download all the dists | ||
uses: actions/download-artifact@v3 | ||
with: | ||
name: python-package-distributions | ||
path: dist/ | ||
- name: Sign the dists with Sigstore | ||
uses: sigstore/[email protected] | ||
with: | ||
inputs: >- | ||
./dist/*.tar.gz | ||
./dist/*.whl | ||
- name: Create GitHub Release | ||
env: | ||
GITHUB_TOKEN: ${{ github.token }} | ||
run: >- | ||
gh release create | ||
'${{ github.ref_name }}' | ||
--repo '${{ github.repository }}' | ||
--title '${{ github.ref_name }}' | ||
--generate-notes | ||
- name: Upload artifact signatures to GitHub Release | ||
env: | ||
GITHUB_TOKEN: ${{ github.token }} | ||
# Upload to GitHub Release using the `gh` CLI. | ||
# `dist/` contains the built packages, and the | ||
# sigstore-produced signatures and certificates. | ||
run: >- | ||
gh release upload | ||
'${{ github.ref_name }}' dist/** | ||
--repo '${{ github.repository }}' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
version = "1.7.2" | ||
version = "1.7.3" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,28 +1,45 @@ | ||
|
||
{% macro duckdb__get_catalog(information_schema, schemas) -%} | ||
{%- call statement('catalog', fetch_result=True) -%} | ||
with relations AS ( | ||
select | ||
t.table_name | ||
, t.database_name | ||
, t.schema_name | ||
, 'BASE TABLE' as table_type | ||
, {{ adapter.catalog_comment('t') }} as table_comment | ||
from duckdb_tables() t | ||
WHERE t.database_name = '{{ database }}' | ||
UNION ALL | ||
SELECT v.view_name as table_name | ||
, v.database_name | ||
, v.schema_name | ||
, 'VIEW' as table_type | ||
, {{ adapter.catalog_comment('v') }} as table_comment | ||
from duckdb_views() v | ||
WHERE v.database_name = '{{ database }}' | ||
) | ||
select | ||
'{{ database }}' as table_database, | ||
t.table_schema, | ||
t.table_name, | ||
t.table_type, | ||
'' as table_comment, | ||
r.schema_name as table_schema, | ||
r.table_name, | ||
r.table_type, | ||
r.table_comment, | ||
c.column_name, | ||
c.ordinal_position as column_index, | ||
c.data_type column_type, | ||
'' as column_comment, | ||
c.column_index as column_index, | ||
c.data_type as column_type, | ||
{{ adapter.catalog_comment('c') }} as column_comment, | ||
'' as table_owner | ||
FROM information_schema.tables t JOIN information_schema.columns c ON t.table_schema = c.table_schema AND t.table_name = c.table_name | ||
FROM relations r JOIN duckdb_columns() c ON r.schema_name = c.schema_name AND r.table_name = c.table_name | ||
WHERE ( | ||
{%- for schema in schemas -%} | ||
upper(t.table_schema) = upper('{{ schema }}'){%- if not loop.last %} or {% endif -%} | ||
upper(r.schema_name) = upper('{{ schema }}'){%- if not loop.last %} or {% endif -%} | ||
{%- endfor -%} | ||
) | ||
AND t.table_type IN ('BASE TABLE', 'VIEW') | ||
ORDER BY | ||
t.table_schema, | ||
t.table_name, | ||
c.ordinal_position | ||
r.schema_name, | ||
r.table_name, | ||
c.column_index | ||
{%- endcall -%} | ||
{{ return(load_result('catalog').table) }} | ||
{%- endmacro %} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
|
||
{# | ||
The logic in this file is adapted from dbt-postgres, since DuckDB matches | ||
the Postgres relation/column commenting model as of 0.10.1 | ||
#} | ||
|
||
{# | ||
By using dollar-quoting like this, users can embed anything they want into their comments | ||
(including nested dollar-quoting), as long as they do not use this exact dollar-quoting | ||
label. It would be nice to just pick a new one but eventually you do have to give up. | ||
#} | ||
{% macro duckdb_escape_comment(comment) -%} | ||
{% if comment is not string %} | ||
{% do exceptions.raise_compiler_error('cannot escape a non-string: ' ~ comment) %} | ||
{% endif %} | ||
{%- set magic = '$dbt_comment_literal_block$' -%} | ||
{%- if magic in comment -%} | ||
{%- do exceptions.raise_compiler_error('The string ' ~ magic ~ ' is not allowed in comments.') -%} | ||
{%- endif -%} | ||
{{ magic }}{{ comment }}{{ magic }} | ||
{%- endmacro %} | ||
|
||
{% macro duckdb__alter_relation_comment(relation, comment) %} | ||
{% set escaped_comment = duckdb_escape_comment(comment) %} | ||
comment on {{ relation.type }} {{ relation }} is {{ escaped_comment }}; | ||
{% endmacro %} | ||
|
||
|
||
{% macro duckdb__alter_column_comment(relation, column_dict) %} | ||
{% set existing_columns = adapter.get_columns_in_relation(relation) | map(attribute="name") | list %} | ||
{% for column_name in column_dict if (column_name in existing_columns) %} | ||
{% set comment = column_dict[column_name]['description'] %} | ||
{% set escaped_comment = duckdb_escape_comment(comment) %} | ||
comment on column {{ relation }}.{{ adapter.quote(column_name) if column_dict[column_name]['quote'] else column_name }} is {{ escaped_comment }}; | ||
{% endfor %} | ||
{% endmacro %} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import pytest | ||
|
||
from dbt.tests.adapter.persist_docs.test_persist_docs import ( | ||
BasePersistDocs, | ||
BasePersistDocsColumnMissing, | ||
BasePersistDocsCommentOnQuotedColumn, | ||
) | ||
|
||
@pytest.mark.skip_profile("md") | ||
class TestPersistDocs(BasePersistDocs): | ||
pass | ||
|
||
|
||
@pytest.mark.skip_profile("md") | ||
class TestPersistDocsColumnMissing(BasePersistDocsColumnMissing): | ||
pass | ||
|
||
|
||
@pytest.mark.skip_profile("md") | ||
class TestPersistDocsCommentOnQuotedColumn(BasePersistDocsCommentOnQuotedColumn): | ||
pass |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters