init
This commit is contained in:
46
dbt/macros/oracle/list_relations_without_caching.sql
Normal file
46
dbt/macros/oracle/list_relations_without_caching.sql
Normal file
@@ -0,0 +1,46 @@
|
||||
#
|
||||
# This macro overwrites the macro with the same name in the dbt-oracle adapter, which was found in
|
||||
# /lib/python3.11/site-packages/dbt/include/oracle/macros/adapters.sql
|
||||
# Reason: The SQL query in the original macro had severe performance issues when accessing sys.all_views
|
||||
#
|
||||
{% macro oracle__list_relations_without_caching(schema_relation) %}
|
||||
{% call statement('list_relations_without_caching', fetch_result=True) -%}
|
||||
with tables as
|
||||
(select SYS_CONTEXT('userenv', 'DB_NAME') table_catalog,
|
||||
owner table_schema,
|
||||
table_name,
|
||||
case
|
||||
when iot_type = 'Y'
|
||||
then 'IOT'
|
||||
when temporary = 'Y'
|
||||
then 'TEMP'
|
||||
else 'BASE TABLE'
|
||||
end table_type
|
||||
from sys.all_tables
|
||||
where upper(table_name) not in (
|
||||
select upper(mview_name)
|
||||
from sys.all_mviews
|
||||
where upper(owner) = upper('{{ schema_relation.schema }}')
|
||||
)
|
||||
union all
|
||||
select SYS_CONTEXT('userenv', 'DB_NAME'),
|
||||
owner,
|
||||
object_name,
|
||||
object_type
|
||||
from sys.all_objects
|
||||
WHERE object_type in ('VIEW', 'MATERIALIZED VIEW')
|
||||
)
|
||||
select table_catalog as "database_name"
|
||||
,table_name as "name"
|
||||
,table_schema as "schema_name"
|
||||
,case table_type
|
||||
when 'BASE TABLE' then 'table'
|
||||
when 'VIEW' then 'view'
|
||||
when 'MATERIALIZED VIEW' then 'materialized_view'
|
||||
end as "kind"
|
||||
from tables
|
||||
where table_type in ('BASE TABLE', 'VIEW', 'MATERIALIZED VIEW')
|
||||
and upper(table_schema) = upper('{{ schema_relation.schema }}')
|
||||
{% endcall %}
|
||||
{{ return(load_result('list_relations_without_caching').table) }}
|
||||
{% endmacro %}
|
||||
Reference in New Issue
Block a user