Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test constraints for geometry and geography types #969

Merged
merged 7 commits into from
Apr 17, 2024

Conversation

MichelleArk
Copy link
Contributor

@MichelleArk MichelleArk commented Apr 12, 2024

resolves: #894
tests: dbt-labs/dbt-adapters#166
docs dbt-labs/docs.getdbt.com/# N/A

Problem

Solution

Checklist

  • I have read the contributing guide and understand what's expected of me
  • I have run this code in development and it appears to resolve the stated issue
  • This PR includes tests, or tests are not required/relevant for this PR
  • This PR has no interface changes (e.g. macros, cli, logs, json artifacts, config files, adapter interface, etc) or this PR has already received feedback and approval from Product or DX

Skipping changelog as this is a test-only change

🎩

-- geography.sql
SELECT 
TO_GEOMETRY('POINT(1820.12 890.56)') as geometry_field, 
TO_GEOGRAPHY('POINT(-122.35 37.55)') as geography_field

✅ correct & passing contract:

❯ dbt run --select geography
02:05:28  Running dbt...
02:05:28  target not specified in profile 'snowflake', using 'default'
02:05:29  Found 14 models, 6 seeds, 20 data tests, 6 sources, 13 metrics, 709 macros, 6 semantic models, 3 unit tests
02:05:29  
02:05:31  Concurrency: 4 threads (target='default')
02:05:31  
02:05:31  1 of 1 START sql view model dbt_marky.geography ................................ [RUN]
02:05:31  1 of 1 OK created sql view model dbt_marky.geography ........................... [SUCCESS 1 in 0.72s]
02:05:31  
02:05:31  Finished running 1 view model in 0 hours 0 minutes and 1.84 seconds (1.84s).
02:05:31  
02:05:31  Completed successfully
02:05:31  
02:05:31  Done. PASS=1 WARN=0 ERROR=0 SKIP=0 TOTAL=1

✅ incorrect and failing contract error message looks good!

❯ dbt run --select geography
02:06:46  Running dbt...
02:06:46  target not specified in profile 'snowflake', using 'default'
02:06:47  Found 14 models, 6 seeds, 20 data tests, 6 sources, 13 metrics, 709 macros, 6 semantic models, 3 unit tests
02:06:47  
02:06:48  Concurrency: 4 threads (target='default')
02:06:48  
02:06:48  1 of 1 START sql view model dbt_marky.geography ................................ [RUN]
02:06:49  1 of 1 ERROR creating sql view model dbt_marky.geography ....................... [ERROR in 0.70s]
02:06:49  
02:06:49  Finished running 1 view model in 0 hours 0 minutes and 1.80 seconds (1.80s).
02:06:49  
02:06:49  Completed with 1 error and 0 warnings:
02:06:49  
02:06:49    Compilation Error in model geography (models/geography.sql)
  This model has an enforced contract that failed.
  Please ensure the name, data_type, and number of columns in your contract match the columns in your model's definition.
  
  | column_name     | definition_type | contract_type | mismatch_reason    |
  | --------------- | --------------- | ------------- | ------------------ |
  | GEOGRAPHY_FIELD | GEOGRAPHY       | TEXT          | data type mismatch |
  | GEOMETRY_FIELD  | GEOMETRY        | TEXT          | data type mismatch |

@cla-bot cla-bot bot added the cla:yes label Apr 12, 2024
Copy link
Contributor

Thank you for your pull request! We could not find a changelog entry for this change. For details on how to document a change, see the dbt-snowflake contributing guide.

@MichelleArk
Copy link
Contributor Author

MichelleArk commented Apr 12, 2024

f25e6cb demonstrates that the current behaviour (before pulling changes in dbt-labs/dbt-adapters#165) fails as described in dbt-labs/dbt-adapters#165 with:

01:34:43  Completed with 1 error and 0 warnings:
01:34:43  
01:34:43    Database Error in model my_model_data_type (models/my_model_data_type.sql)
  001007 (22023): SQL compilation error:
  invalid type [CAST(null AS GEOGRAPHY)] for parameter 'TO_GEOGRAPHY'
01:34:43  
01:34:43  Done. PASS=0 WARN=0 ERROR=1 SKIP=0 TOTAL=1
----------------------------- Captured stderr call -----------------------------
failed to send telemetry to the Datadog Agent at http://localhost:8126/telemetry/proxy/api/v2/apmtelemetry.
---------------------------- Captured logbook call -----------------------------
[DEBUG] ddtrace.internal.telemetry.writer: failed to send telemetry to the Datadog Agent at http://localhost:8126/telemetry/proxy/api/v2/apmtelemetry.
--------------------- CSV report: integration_results.csv ----------------------
=========================== short test summary info ============================
FAILED tests/functional/adapter/test_constraints.py::TestSnowflakeViewConstraintsColumnsEqual::test__constraints_correct_column_data_types - AssertionError: dbt exit state did not match expected
FAILED tests/functional/adapter/test_constraints.py::TestSnowflakeIncrementalConstraintsColumnsEqual::test__constraints_correct_column_data_types - AssertionError: dbt exit state did not match expected
FAILED tests/functional/adapter/test_constraints.py::TestSnowflakeTableConstraintsColumnsEqual::test__constraints_correct_column_data_types - AssertionError: dbt exit state did not match expected
============= 3 failed, 216 passed, 3 skipped in 754.52s (0:12:34) =============

@MichelleArk MichelleArk added the Skip Changelog Skips GHA to check for changelog file label Apr 12, 2024
@MichelleArk MichelleArk marked this pull request as ready for review April 12, 2024 02:08
@dbeatty10
Copy link
Contributor

dbeatty10 commented Apr 12, 2024

@MichelleArk looks like the combination of this PR and dbt-labs/dbt-adapters#165 resolves #894 too 🤩

@MichelleArk MichelleArk merged commit f2f0868 into main Apr 17, 2024
29 checks passed
@MichelleArk MichelleArk deleted the expand-constraint-data-type-testing branch April 17, 2024 22:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cla:yes Skip Changelog Skips GHA to check for changelog file
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Bug] Contract enforcement results in an error when data_type: GEOGRAPHY
3 participants