Skip to content

Commit

Permalink
Updated tests
Browse files Browse the repository at this point in the history
  • Loading branch information
dogversioning committed Feb 27, 2024
1 parent 3b5c56b commit d55d6b6
Show file tree
Hide file tree
Showing 5 changed files with 48 additions and 33 deletions.
1 change: 1 addition & 0 deletions cumulus_library/.sqlfluff
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ source_id = source_id
table_cols = ["a","b"]
table_cols_types = ["varchar", "varchar"]
table_name = test_table
table_names = ["test_table"]
table_suffix = 2024_01_01_11_11_11
target_col_prefix = prefix
target_table = target_table
Expand Down
9 changes: 4 additions & 5 deletions cumulus_library/template_sql/base_templates.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,20 +90,19 @@ def get_codeable_concept_denormalize_query(
)


# TODO: change test of table_name to plural
def get_column_datatype_query(
schema_name: str,
table_name: str | list,
table_names: str | list,
column_names: list | None = None,
include_table_names: bool | None = False,
):
"""Gets the in-database data representation of a given column"""
if isinstance(table_name, str):
table_name = [table_name]
if isinstance(table_names, str):
table_names = [table_names]
return get_base_template(
"column_datatype",
schema_name=schema_name,
table_name=table_name,
table_names=table_names,
column_names=column_names,
include_table_names=include_table_names,
)
Expand Down
10 changes: 5 additions & 5 deletions cumulus_library/template_sql/column_datatype.sql.jinja
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
SELECT
{%- if include_table_names %}
table_name,
{% endif %}
{%- endif %}
column_name,
data_type
FROM information_schema.columns
WHERE
table_schema = '{{ schema_name }}'
AND table_name IN ('{{ table_name|join("', '")|lower }}')
{%- if column_names %}
AND LOWER(column_name) IN ('{{ column_names|join("', '")|lower }}') --noqa: LT05
{% endif %}
AND table_name IN ('{{ table_names|join("', '")|lower }}')
{%- if column_names %}
AND LOWER(column_name) IN ('{{ column_names|join("', '")|lower }}') --noqa: LT05
{%- endif %}
Loading

0 comments on commit d55d6b6

Please sign in to comment.