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

Add integration tests for charindex, dateadd, to_timestamp (DNA-19468 / DNA-20817) #84

Merged
merged 3 commits into from
Nov 23, 2023

Conversation

Dennis-UiPath
Copy link
Contributor

Description

  • Adds integration tests for charindex, dateadd and to_timestamp macro's

Release

  • Direct release (main)
  • Merge to dev (or other) branch
    • Why:

Did you consider?

  • Does it Work on Automation Suite / SQL Server
  • Does it Work on Automation Cloud / Snowflake
    - [ ] What is the performance impact?
    - [ ] The version number in dbt_project.yml

@Dennis-UiPath Dennis-UiPath force-pushed the test/add_integration_tests branch from ef7adf5 to d93ace3 Compare November 21, 2023 07:11
@Dennis-UiPath Dennis-UiPath marked this pull request as ready for review November 21, 2023 07:29
@silviustanimir silviustanimir self-requested a review November 22, 2023 08:31
{{ pm_utils.charindex('is', '`Text`') }} as `Find_first_of_multiple_occurrences`,
3 as `Find_first_of_multiple_occurrences_expected`,

{# Find a space. SQL Server handles spaces differently #}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's true that SQL Server handles spaces differently, but that's applicable for the len function, not the charindex function. Maybe rephrase this?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated the comment to cover it better

{{ pm_utils.to_varchar(pm_utils.dateadd('year', 1, '`testdate`')) }} as `add_years`,

{# Use bigint as the value #}
{{ pm_utils.to_varchar(pm_utils.dateadd('year', '`bigint_value`', '`testdate`')) }} as `add_bigint`,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No test for this use case?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added the testcase here

with Input_data as (
select
'2023-11-12 13:14:15.678' as `testdate`,
null as `null_value`,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be a datetime NULL value.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Technically you are correct. We just removed the test for type tests from pm_utils. We can add it in the test and add Databricks support, but it is not compatible with Spark (no information_schema available). We discussed it and for now we will leave it this way, we will add a test if we run into an issue here.


{# Use null as the date #}
{{ pm_utils.to_varchar(pm_utils.dateadd('year', 1, '`null_value`')) }} as `add_to_null_value`,
'' as `add_to_null_value_expected`
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Then this should also be a NULL datetime/date? 🤔

'2023-11-12 13:14:15.678' as `timestamp_datetime_ms`,
'2023-11-12 13:14:15.6789' as `timestamp_datetime_ms4`,
'13:14:15' as `timestamp_time`,
null as `null_value`
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same as before, shouldn't it be a datetime NULL?

Copy link
Contributor

@silviustanimir silviustanimir left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please address the comments, also check why dbt deps recursively creates folders indefinitely.

@Dennis-UiPath Dennis-UiPath merged commit 048e757 into main Nov 23, 2023
3 checks passed
@Dennis-UiPath Dennis-UiPath deleted the test/add_integration_tests branch November 23, 2023 09:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants