Skip to content

Commit

Permalink
Convert postgres index tests (#6228)
Browse files Browse the repository at this point in the history
  • Loading branch information
stu-k authored Nov 8, 2022
1 parent d5e9ce1 commit f022435
Show file tree
Hide file tree
Showing 12 changed files with 290 additions and 239 deletions.
7 changes: 7 additions & 0 deletions .changes/unreleased/Under the Hood-20221108-115633.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
kind: Under the Hood
body: Convert postgres index tests to pytest
time: 2022-11-08T11:56:33.743042-06:00
custom:
Author: stu-k
Issue: "5770"
PR: "6228"

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

18 changes: 0 additions & 18 deletions test/integration/065_postgres_index_tests/models/incremental.sql

This file was deleted.

14 changes: 0 additions & 14 deletions test/integration/065_postgres_index_tests/models/table.sql

This file was deleted.

4 changes: 0 additions & 4 deletions test/integration/065_postgres_index_tests/seeds/seed.csv

This file was deleted.

29 changes: 0 additions & 29 deletions test/integration/065_postgres_index_tests/snapshots/colors.sql

This file was deleted.

134 changes: 0 additions & 134 deletions test/integration/065_postgres_index_tests/test_postgres_indexes.py

This file was deleted.

134 changes: 134 additions & 0 deletions tests/functional/postgres/fixtures.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,134 @@
models__incremental_sql = """
{{
config(
materialized = "incremental",
indexes=[
{'columns': ['column_a'], 'type': 'hash'},
{'columns': ['column_a', 'column_b'], 'unique': True},
]
)
}}
select *
from (
select 1 as column_a, 2 as column_b
) t
{% if is_incremental() %}
where column_a > (select max(column_a) from {{this}})
{% endif %}
"""

models__table_sql = """
{{
config(
materialized = "table",
indexes=[
{'columns': ['column_a']},
{'columns': ['column_b']},
{'columns': ['column_a', 'column_b']},
{'columns': ['column_b', 'column_a'], 'type': 'btree', 'unique': True},
{'columns': ['column_a'], 'type': 'hash'}
]
)
}}
select 1 as column_a, 2 as column_b
"""

models_invalid__invalid_columns_type_sql = """
{{
config(
materialized = "table",
indexes=[
{'columns': 'column_a, column_b'},
]
)
}}
select 1 as column_a, 2 as column_b
"""

models_invalid__invalid_type_sql = """
{{
config(
materialized = "table",
indexes=[
{'columns': ['column_a'], 'type': 'non_existent_type'},
]
)
}}
select 1 as column_a, 2 as column_b
"""

models_invalid__invalid_unique_config_sql = """
{{
config(
materialized = "table",
indexes=[
{'columns': ['column_a'], 'unique': 'yes'},
]
)
}}
select 1 as column_a, 2 as column_b
"""

models_invalid__missing_columns_sql = """
{{
config(
materialized = "table",
indexes=[
{'unique': True},
]
)
}}
select 1 as column_a, 2 as column_b
"""

snapshots__colors_sql = """
{% snapshot colors %}
{{
config(
target_database=database,
target_schema=schema,
unique_key='id',
strategy='check',
check_cols=['color'],
indexes=[
{'columns': ['id'], 'type': 'hash'},
{'columns': ['id', 'color'], 'unique': True},
]
)
}}
{% if var('version') == 1 %}
select 1 as id, 'red' as color union all
select 2 as id, 'green' as color
{% else %}
select 1 as id, 'blue' as color union all
select 2 as id, 'green' as color
{% endif %}
{% endsnapshot %}
"""

seeds__seed_csv = """country_code,country_name
US,United States
CA,Canada
GB,United Kingdom
"""
Loading

0 comments on commit f022435

Please sign in to comment.