From eb7745baf76619031846429882062b8234b337a5 Mon Sep 17 00:00:00 2001 From: Dylan Date: Tue, 6 Feb 2024 16:44:29 +0800 Subject: [PATCH] feat: bump to 1.7.0 (#33) --- dbt/adapters/risingwave/__version__.py | 2 +- dbt/include/risingwave/macros/catalog.sql | 101 +++++++++++++--------- setup.py | 4 +- 3 files changed, 61 insertions(+), 46 deletions(-) diff --git a/dbt/adapters/risingwave/__version__.py b/dbt/adapters/risingwave/__version__.py index cead7e8..a55413d 100644 --- a/dbt/adapters/risingwave/__version__.py +++ b/dbt/adapters/risingwave/__version__.py @@ -1 +1 @@ -version = "1.6.1" +version = "1.7.0" diff --git a/dbt/include/risingwave/macros/catalog.sql b/dbt/include/risingwave/macros/catalog.sql index 1c70536..8b59612 100644 --- a/dbt/include/risingwave/macros/catalog.sql +++ b/dbt/include/risingwave/macros/catalog.sql @@ -1,50 +1,65 @@ -- todo: filter out temporary schema when `pg_is_other_temp_schema` is done in rw -- todo: filter out temporary table when `tbl.relpersistence` is done in rw -- todo: add sink support when it's shown in `pg_catalog.pg_class` -{% macro risingwave__get_catalog(information_schema, schemas) -%} +{% macro risingwave__get_catalog_relations(information_schema, relations) -%} + {%- call statement('catalog', fetch_result=True) -%} + {% set database = information_schema.database %} + {{ adapter.verify_database(database) }} - {% set database = information_schema.database %} - {{ adapter.verify_database(database) }} + select + '{{ database }}' as table_database, + sch.nspname as table_schema, + tbl.relname as table_name, + case tbl.relkind + when 'v' then 'VIEW' + when 'm' then 'MATERIALIZED VIEW' + else 'BASE TABLE' + end as table_type, + tbl_desc.description as table_comment, + col.attname as column_name, + col.attnum as column_index, + pg_catalog.format_type(col.atttypid, col.atttypmod) as column_type, + col_desc.description as column_comment, + pg_get_userbyid(tbl.relowner) as table_owner + + from pg_catalog.pg_namespace sch + join pg_catalog.pg_class tbl on tbl.relnamespace = sch.oid + join pg_catalog.pg_attribute col on col.attrelid = tbl.oid + left outer join pg_catalog.pg_description tbl_desc on (tbl_desc.objoid = tbl.oid and tbl_desc.objsubid = 0) + left outer join pg_catalog.pg_description col_desc on (col_desc.objoid = tbl.oid and col_desc.objsubid = col.attnum) + where ( + {%- for relation in relations -%} + {%- if relation.identifier -%} + (upper(sch.nspname) = upper('{{ relation.schema }}') and + upper(tbl.relname) = upper('{{ relation.identifier }}')) + {%- else-%} + upper(sch.nspname) = upper('{{ relation.schema }}') + {%- endif -%} + {%- if not loop.last %} or {% endif -%} + {%- endfor -%} + ) + and tbl.relpersistence in ('p', 'u') -- [p]ermanent table or [u]nlogged table. Exclude [t]emporary tables + and tbl.relkind in ('r', 'v', 'f', 'p', 'm') -- o[r]dinary table, [v]iew, [f]oreign table, [p]artitioned table, [m]aterialized view. Other values are [i]ndex, [S]equence, [c]omposite type, [t]OAST table + and col.attnum > 0 -- negative numbers are used for system columns such as oid + and not col.attisdropped -- column as not been dropped + + order by + sch.nspname, + tbl.relname, + col.attnum - {%- call statement('catalog', fetch_result=True) -%} - SELECT - '{{ database }}' AS table_database, - sch.nspname AS table_schema, - tbl.relname AS table_name, - CASE tbl.relkind - WHEN 'v' THEN - 'VIEW' - WHEN 'x' THEN - 'SOURCE' - ELSE - 'BASE TABLE' - END AS table_type, - tbl_desc.description AS table_comment, - col.attname AS column_name, - col.attnum AS column_index, - pg_catalog.format_type(col.atttypid, NULL) AS column_type, - col_desc.description AS column_comment, - pg_get_userbyid(tbl.relowner) AS table_owner -FROM - pg_catalog.pg_namespace sch - JOIN pg_catalog.pg_class tbl ON tbl.relnamespace = sch.oid - JOIN pg_catalog.pg_attribute col ON col.attrelid = tbl.oid - LEFT OUTER JOIN pg_catalog.pg_description tbl_desc ON (tbl_desc.objoid = tbl.oid - AND tbl_desc.objsubid = 0) - LEFT OUTER JOIN pg_catalog.pg_description col_desc ON (col_desc.objoid = tbl.oid - AND col_desc.objsubid = col.attnum) -WHERE ( - {%- for schema in schemas -%} - upper(sch.nspname) = upper('{{ schema }}'){%- if not loop.last %} or {% endif -%} - {%- endfor -%} - ) - AND tbl.relkind in('r', 'v', 'f', 'p', 'x') -- o[r]dinary table, [v]iew, [f]oreign table, [p]artitioned table, [x] source. Other values are [i]ndex, [S]equence, [c]omposite type, [t]OAST table, [m]aterialized view - AND col.attnum > 0 -- negative numbers are used for system columns such as oid - AND NOT col.attisdropped -- column as not been dropped -ORDER BY - sch.nspname, - tbl.relname, - col.attnum {%- endcall -%} + {{ return(load_result('catalog').table) }} -{%- endmacro %} \ No newline at end of file +{%- endmacro %} + + +{% macro risingwave__get_catalog(information_schema, schemas) -%} + {%- set relations = [] -%} + {%- for schema in schemas -%} + {%- set dummy = relations.append({'schema': schema}) -%} + {%- endfor -%} + {{ return(risingwave__get_catalog_relations(information_schema, relations)) }} +{%- endmacro %} + + diff --git a/setup.py b/setup.py index e13ef8f..a411031 100644 --- a/setup.py +++ b/setup.py @@ -4,7 +4,7 @@ package_name = "dbt-risingwave" # make sure this always matches dbt/adapters/{adapter}/__version__.py -package_version = "1.6.1" +package_version = "1.7.0" description = """The RisingWave adapter plugin for dbt""" with open(os.path.join(os.path.dirname(__file__), "README.md")) as f: @@ -23,5 +23,5 @@ url="https://github.com/risingwavelabs/dbt-risingwave", packages=find_namespace_packages(include=["dbt", "dbt.*"]), include_package_data=True, - install_requires=["dbt-postgres~=1.6.0"], + install_requires=["dbt-postgres~=1.7.0"], )