-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test(integration) add test to_timestamp
- Loading branch information
1 parent
9dddab1
commit 016ab1b
Showing
2 changed files
with
66 additions
and
1 deletion.
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
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 |
---|---|---|
@@ -0,0 +1,44 @@ | ||
with Input_data as ( | ||
select | ||
'2023-11-12' as `timestamp_date`, | ||
'2023-11-12 13:14:15' as `timestamp_datetime`, | ||
'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` | ||
) | ||
|
||
select | ||
{{ pm_utils.to_varchar(pm_utils.to_timestamp('`timestamp_date`')) }} as `timestamp_date`, | ||
{{ pm_utils.to_varchar(pm_utils.to_timestamp('`timestamp_datetime`')) }} as `timestamp_datetime`, | ||
{{ pm_utils.to_varchar(pm_utils.to_timestamp('`timestamp_datetime_ms`')) }} as `timestamp_datetime_ms`, | ||
{{ pm_utils.to_varchar(pm_utils.to_timestamp('`timestamp_datetime_ms4`')) }} as `timestamp_datetime_ms4`, | ||
{{ pm_utils.to_varchar(pm_utils.to_timestamp('`timestamp_time`')) }} as `timestamp_time`, | ||
{{ pm_utils.to_varchar(pm_utils.to_timestamp('`null_value`')) }} as `null_value`, | ||
|
||
{% if target.type == 'databricks' %} | ||
'' as `timestamp_date_expected`, | ||
'2023-11-12 13:14:15' as `timestamp_datetime_expected`, | ||
'2023-11-12 13:14:15.678' as `timestamp_datetime_ms_expected`, | ||
'2023-11-12 13:14:15' as `timestamp_datetime_ms4_expected`, | ||
'' as `timestamp_time_expected`, | ||
'' as `null_value_expected` | ||
{% elif target.type == 'sqlserver' %} | ||
--SQL Server uses datetime2 format and always specifies the precision with 7 digits. | ||
--SQL Server will also give a result when only having a date or a time as input | ||
'2023-11-12 00:00:00.0000000' as `timestamp_date_expected`, | ||
'2023-11-12 13:14:15.0000000' as `timestamp_datetime_expected`, | ||
'2023-11-12 13:14:15.6780000' as `timestamp_datetime_ms_expected`, | ||
'2023-11-12 13:14:15.6789000' as `timestamp_datetime_ms4_expected`, | ||
'1900-01-01 13:14:15.0000000' as `timestamp_time_expected`, | ||
'' as `null_value_expected` | ||
{% elif target.type == 'snowflake' %} | ||
'' as `timestamp_date_expected`, | ||
'2023-11-12 13:14:15.000' as `timestamp_datetime_expected`, | ||
'2023-11-12 13:14:15.678' as `timestamp_datetime_ms_expected`, | ||
'2023-11-12 13:14:15.678' as `timestamp_datetime_ms4_expected`, | ||
'' as `timestamp_time_expected`, | ||
'' as `null_value_expected` | ||
{% endif %} | ||
|
||
from Input_data |