-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* version bumps * tests for limit added * fix constraints and limit tests, add pytest -n * catalog fix v1.7 --------- Co-authored-by: Marvin Froemming <[email protected]> Co-authored-by: ilikutle <[email protected]>
- Loading branch information
1 parent
ae7f776
commit cdd4927
Showing
11 changed files
with
316 additions
and
135 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 |
---|---|---|
@@ -1 +1 @@ | ||
version = "1.6.0" | ||
version = "1.7.0" |
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,53 +1,119 @@ | ||
{% macro exasol__get_catalog(information_schemas, schemas) -%} | ||
{% for schema in schemas %} | ||
{{ log(schema)}} | ||
{% endfor %} | ||
|
||
{%- call statement('catalog', fetch_result=True) -%} | ||
|
||
WITH tabs as ( | ||
|
||
select | ||
'DB' as table_database, | ||
ROOT_NAME as table_schema, | ||
OBJECT_NAME as table_name, | ||
ROOT_NAME as table_owner, | ||
OBJECT_TYPE AS table_type, | ||
OBJECT_COMMENT as table_comment | ||
from sys.EXA_USER_OBJECTS | ||
WHERE OBJECT_TYPE IN('TABLE', 'VIEW') | ||
|
||
), | ||
|
||
cols as ( | ||
|
||
select | ||
'DB' as table_database, | ||
column_schema as table_schema, | ||
column_table as table_name, | ||
column_name, | ||
column_ordinal_position as column_index, | ||
column_type, | ||
column_comment | ||
from sys.exa_user_columns | ||
{% macro exasol__get_catalog(information_schema, schemas) -%} | ||
|
||
{% set query %} | ||
with tables as ( | ||
{{ exasol__get_catalog_tables_sql(information_schema) }} | ||
), | ||
columns as ( | ||
{{ exasol__get_catalog_columns_sql(information_schema) }} | ||
) | ||
{{ exasol__get_catalog_results_sql() }} | ||
{{ exasol__get_catalog_schemas_where_clause_sql(schemas) }} | ||
order by | ||
tables.table_owner, | ||
columns.table_name, | ||
columns.column_index | ||
{%- endset -%} | ||
|
||
{{ return(run_query(query)) }} | ||
|
||
{%- endmacro %} | ||
|
||
|
||
{% macro exasol__get_catalog_relations(information_schema, relations) -%} | ||
|
||
{% set query %} | ||
with tables as ( | ||
{{ exasol__get_catalog_tables_sql(information_schema) }} | ||
), | ||
columns as ( | ||
{{ exasol__get_catalog_columns_sql(information_schema) }} | ||
) | ||
{{ exasol__get_catalog_results_sql() }} | ||
{{ exasol__get_catalog_relations_where_clause_sql(relations) }} | ||
order by | ||
tables.table_owner, | ||
columns.table_name, | ||
columns.column_index | ||
{%- endset -%} | ||
|
||
{{ return(run_query(query)) }} | ||
|
||
{%- endmacro %} | ||
|
||
) | ||
|
||
select tabs.table_owner as [table_owner], | ||
tabs.table_type AS [table_type], | ||
tabs.table_comment as [table_comment], | ||
cols.table_database as [table_database], | ||
cols.table_schema as [table_schema], | ||
cols.table_name as [table_name], | ||
cols.column_name as [column_name], | ||
cols.column_index as [column_index], | ||
cols.column_type as [column_type], | ||
cols.column_comment as [column_comment] | ||
from tabs | ||
join cols on tabs.table_database = cols.table_database and tabs.table_schema = cols.table_schema and tabs.table_name = cols.table_name | ||
order by column_index | ||
{%- endcall -%} | ||
|
||
{{ return(load_result('catalog').table) }} | ||
{% macro exasol__get_catalog_tables_sql(information_schema) -%} | ||
select | ||
'DB' as table_database, | ||
ROOT_NAME as table_schema, | ||
OBJECT_NAME as table_name, | ||
ROOT_NAME as table_owner, | ||
OBJECT_TYPE AS table_type, | ||
OBJECT_COMMENT as table_comment | ||
from sys.EXA_USER_OBJECTS | ||
WHERE OBJECT_TYPE IN('TABLE', 'VIEW') | ||
{%- endmacro %} | ||
|
||
|
||
{% macro exasol__get_catalog_columns_sql(information_schema) -%} | ||
select | ||
'DB' as table_database, | ||
column_schema as table_schema, | ||
column_table as table_name, | ||
column_name, | ||
column_ordinal_position as column_index, | ||
column_type, | ||
column_comment | ||
from sys.exa_user_columns | ||
{%- endmacro %} | ||
|
||
|
||
{% macro exasol__get_catalog_results_sql() -%} | ||
select | ||
tables.table_owner as [table_owner], | ||
tables.table_type AS [table_type], | ||
tables.table_comment as [table_comment], | ||
columns.table_database as [table_database], | ||
columns.table_schema as [table_schema], | ||
columns.table_name as [table_name], | ||
columns.column_name as [column_name], | ||
columns.column_index as [column_index], | ||
case | ||
when columns.column_type='TIMESTAMP(3)' then 'TIMESTAMP' | ||
else columns.column_type | ||
end as [column_type], | ||
columns.column_comment as [column_comment] | ||
from tables | ||
join columns on tables.table_database = columns.table_database and tables.table_schema = columns.table_schema and tables.table_name = columns.table_name | ||
{%- endmacro %} | ||
|
||
|
||
{% macro exasol__get_catalog_schemas_where_clause_sql(schemas, schema_name) -%} | ||
where ({%- for schema in schemas -%} | ||
upper(tables.table_owner) = upper('{{ schema }}'){%- if not loop.last %} or {% endif -%} | ||
{%- endfor -%}) | ||
{%- endmacro %} | ||
|
||
|
||
{% macro exasol__get_catalog_relations_where_clause_sql(relations) -%} | ||
where ( | ||
{%- for relation in relations -%} | ||
{% if relation.schema and relation.identifier %} | ||
( | ||
upper(tables.table_owner) = upper('{{ relation.schema }}') | ||
and upper(columns.table_name) = upper('{{ relation.identifier }}') | ||
) | ||
{% elif relation.schema %} | ||
( | ||
upper(tables.table_owner) = 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 %} |
Oops, something went wrong.