-
Notifications
You must be signed in to change notification settings - Fork 27
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Co-authored-by: sachinthakur96 <[email protected]>
- Loading branch information
1 parent
a6b8662
commit d79a47b
Showing
19 changed files
with
2,600 additions
and
63 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
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 |
---|---|---|
|
@@ -14,4 +14,4 @@ | |
|
||
|
||
|
||
version = "1.6.0" | ||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,162 @@ | ||
{% macro vertica__get_catalog(information_schema, schemas) -%} | ||
|
||
|
||
{% set query %} | ||
|
||
with tables as ( | ||
{{ vertica__get_catalog_tables_sql(information_schema) }} | ||
{{ vertica__get_catalog_schemas_where_clause_sql(schemas) }} | ||
), | ||
columns as ( | ||
{{ vertica__get_catalog_columns_sql(information_schema) }} | ||
{{ vertica__get_catalog_schemas_where_clause_sql(schemas) }} | ||
|
||
) | ||
|
||
{{vertica__get_catalog_results_sql ()}} | ||
|
||
{%- endset -%} | ||
{{ return(run_query(query)) }} | ||
|
||
|
||
|
||
{%- endmacro %} | ||
|
||
|
||
|
||
|
||
|
||
|
||
{% macro vertica__get_catalog_relations(information_schema, relations) -%} | ||
{% set query %} | ||
|
||
|
||
with tables as ( | ||
{{ vertica__get_catalog_tables_sql(information_schema) }} | ||
{{ vertica__get_catalog_relations_where_clause_sql(relations) }} | ||
), | ||
columns as ( | ||
{{ vertica__get_catalog_columns_sql(information_schema) }} | ||
{{ vertica__get_catalog_relations_where_clause_sql(relations) }} | ||
|
||
) | ||
{{vertica__get_catalog_results_sql ()}} | ||
{%- endset -%} | ||
|
||
{{ return(run_query(query)) }} | ||
|
||
{%- endmacro %} | ||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
{% macro vertica__get_catalog_tables_sql(information_schema) -%} | ||
select * from ( | ||
select | ||
'{{ information_schema.database }}' table_database | ||
, tab.table_schema | ||
, tab.table_name | ||
, 'TABLE' table_type | ||
, comment table_comment | ||
, tab.owner_name table_owner | ||
, col.column_name | ||
, col.ordinal_position column_index | ||
, col.data_type column_type | ||
, nullif('','') column_comment | ||
from v_catalog.tables tab | ||
join v_catalog.columns col on tab.table_id = col.table_id | ||
left join v_catalog.comments on tab.table_id = object_id | ||
union all | ||
select | ||
'{{ information_schema.database }}' table_database | ||
, vw.table_schema | ||
, vw.table_name | ||
, 'VIEW' table_type | ||
, comment table_comment | ||
, vw.owner_name table_owner | ||
, col.column_name | ||
, col.ordinal_position column_index | ||
, col.data_type column_type | ||
, nullif('','') column_comment | ||
from v_catalog.views vw | ||
join v_catalog.view_columns col on vw.table_id = col.table_id | ||
left join v_catalog.comments on vw.table_id = object_id | ||
|
||
) anything | ||
{%- endmacro %} | ||
|
||
|
||
|
||
{% macro vertica__get_catalog_columns_sql(information_schema) -%} | ||
select * from ( select | ||
'{{ information_schema.database }}' table_database , | ||
table_schema | ||
,table_name | ||
, column_name | ||
, ordinal_position column_index | ||
, data_type column_type | ||
|
||
from v_catalog.columns | ||
|
||
union all | ||
|
||
select | ||
'{{ information_schema.database }}' table_database , | ||
table_schema | ||
,table_name | ||
, column_name | ||
, ordinal_position column_index | ||
, data_type column_type | ||
|
||
from v_catalog.view_columns | ||
) y | ||
{%- endmacro %} | ||
|
||
{% macro vertica__get_catalog_results_sql() -%} | ||
select * | ||
from tables | ||
join columns using ("table_database", "table_schema", "table_name"); | ||
|
||
{%- endmacro %} | ||
|
||
{% macro vertica__get_catalog_schemas_where_clause_sql(schemas) -%} | ||
where | ||
( | ||
{%- for schema in schemas -%} | ||
|
||
|
||
lower(table_schema) = lower('{{ schema }}') {%- if not loop.last %} or {% endif %} | ||
{%- endfor -%} | ||
) | ||
|
||
order by table_schema, table_name, column_index | ||
|
||
{%- endmacro %} | ||
|
||
|
||
{% macro vertica__get_catalog_relations_where_clause_sql(relations) -%} | ||
where ( | ||
{%- for relation in relations -%} | ||
{% if relation.schema and relation.identifier %} | ||
( | ||
upper("table_schema") = upper('{{ relation.schema }}') | ||
and upper("table_name") = upper('{{ relation.identifier }}') | ||
) | ||
{% elif relation.schema %} | ||
( | ||
upper("table_schema") = upper('{{ relation.schema }}') | ||
) | ||
{% else %} | ||
{% do exceptions.raise_compiler_error( | ||
'`get_catalog_relations` requires a list of relations, each with a schema' | ||
) %} | ||
{% endif %} | ||
|
||
{%- if not loop.last %} or {% endif -%} | ||
{%- 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 |
---|---|---|
@@ -1,7 +1,7 @@ | ||
{% macro vertica__array_construct(inputs, data_type) -%} | ||
{% if inputs|length > 0 %} | ||
[ {{ inputs|join(' , ') }} ] | ||
ARRAY[ {{ inputs|join(' , ') }} ] | ||
{% else %} | ||
ARRAY<{{data_type}}>[] | ||
ARRAY[{{data_type}}] | ||
{% endif %} | ||
{%- endmacro %} |
Oops, something went wrong.