Commit 5b8122d
authored
Fix for DATENAME() gives incorrect value with TZOFFSET part (#3895)
* Fix for DATENAME() gives incorrect value with TZOFFSET part (#3846)
Currently, DATENAME function returns a numeric value for TZOFFSET
datepart, which does not match SQL Server's text output.
Root cause: The function definition of sys.datename explicitly calls the
DATEPART function for most argument values, including TZOFFSET, thereby
returning a numerical offset value instead of the required text format
(+/-HH:MM).
Fix: Modified the sys function's SQL definition to extract and return
the timezone offset substring from the input - similar to how the
offset_string is determined in DATETRUNC/DATEBUCKET - if the argument
matches tzoffset. Furthermore, translated the function from SQL language
to plpgsql in order to enable raising an exception for unsupported input
datetime datatypes such as date, time, datetime and smalldatetime.
Task: BABEL-5846
Signed-off-by: Manisha Deshpande <mmdeshp@amazon.com>
(cherry picked from commit debf90b)
* Fixed DATENAME to use datetimeoffset cast instead of sys.babelfish_conv_string_to_datetimeoffset
While sys.babelfish_conv_string_to_datetimeoffset is a helpful way to
validate datetimeoffset values before returning the offset string in
DATENAME(TZOFFSET,...) it is crrently not present in 4_X. (BABEL-4896).
Switching to a normal pg cast to datetimeoffset works as well, but does
not validate out of boundary offset hour values above +/-14:00 since PG
accepts upto hour 15.
The incorrect output in the out-of-boundary test case in
`datename+tzoffset-v-verify.sql` can be updated to the expected error
(SQL Server), once the root cause jira BABEL-5827 is fixed.
Task: BABEL-5846
Signed-off-by: Manisha Deshpande <mmdeshp@amazon.com>
(cherry picked from commit 3140b6c)1 parent d76e95f commit 5b8122d
File tree
21 files changed
+1756
-150
lines changed- contrib/babelfishpg_tsql/sql
- upgrades
- test
- JDBC
- expected
- input
- functions
- upgrade
- 16_9
- latest
- python/expected/upgrade_validation
21 files changed
+1756
-150
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2056 | 2056 | | |
2057 | 2057 | | |
2058 | 2058 | | |
2059 | | - | |
2060 | | - | |
2061 | | - | |
2062 | | - | |
| 2059 | + | |
| 2060 | + | |
| 2061 | + | |
| 2062 | + | |
| 2063 | + | |
| 2064 | + | |
| 2065 | + | |
| 2066 | + | |
| 2067 | + | |
2063 | 2068 | | |
2064 | | - | |
2065 | | - | |
| 2069 | + | |
| 2070 | + | |
| 2071 | + | |
| 2072 | + | |
| 2073 | + | |
| 2074 | + | |
| 2075 | + | |
| 2076 | + | |
| 2077 | + | |
| 2078 | + | |
| 2079 | + | |
2066 | 2080 | | |
2067 | | - | |
2068 | | - | |
| 2081 | + | |
| 2082 | + | |
| 2083 | + | |
| 2084 | + | |
2069 | 2085 | | |
2070 | | - | |
2071 | | - | |
| 2086 | + | |
2072 | 2087 | | |
2073 | | - | |
| 2088 | + | |
2074 | 2089 | | |
2075 | 2090 | | |
2076 | | - | |
2077 | | - | |
2078 | | - | |
2079 | | - | |
| 2091 | + | |
| 2092 | + | |
| 2093 | + | |
| 2094 | + | |
| 2095 | + | |
| 2096 | + | |
2080 | 2097 | | |
2081 | | - | |
2082 | | - | |
| 2098 | + | |
| 2099 | + | |
| 2100 | + | |
| 2101 | + | |
| 2102 | + | |
| 2103 | + | |
| 2104 | + | |
2083 | 2105 | | |
2084 | | - | |
2085 | | - | |
| 2106 | + | |
| 2107 | + | |
| 2108 | + | |
| 2109 | + | |
2086 | 2110 | | |
2087 | | - | |
2088 | | - | |
| 2111 | + | |
2089 | 2112 | | |
2090 | 2113 | | |
2091 | 2114 | | |
| |||
Lines changed: 56 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
977 | 977 | | |
978 | 978 | | |
979 | 979 | | |
| 980 | + | |
| 981 | + | |
| 982 | + | |
| 983 | + | |
| 984 | + | |
| 985 | + | |
| 986 | + | |
| 987 | + | |
| 988 | + | |
| 989 | + | |
| 990 | + | |
| 991 | + | |
| 992 | + | |
| 993 | + | |
| 994 | + | |
| 995 | + | |
| 996 | + | |
| 997 | + | |
| 998 | + | |
| 999 | + | |
| 1000 | + | |
| 1001 | + | |
| 1002 | + | |
| 1003 | + | |
| 1004 | + | |
| 1005 | + | |
| 1006 | + | |
| 1007 | + | |
| 1008 | + | |
| 1009 | + | |
| 1010 | + | |
| 1011 | + | |
| 1012 | + | |
| 1013 | + | |
| 1014 | + | |
| 1015 | + | |
| 1016 | + | |
| 1017 | + | |
| 1018 | + | |
| 1019 | + | |
| 1020 | + | |
| 1021 | + | |
| 1022 | + | |
| 1023 | + | |
| 1024 | + | |
| 1025 | + | |
| 1026 | + | |
| 1027 | + | |
| 1028 | + | |
| 1029 | + | |
| 1030 | + | |
| 1031 | + | |
| 1032 | + | |
| 1033 | + | |
| 1034 | + | |
| 1035 | + | |
980 | 1036 | | |
981 | 1037 | | |
982 | 1038 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
3292 | 3292 | | |
3293 | 3293 | | |
3294 | 3294 | | |
3295 | | - | |
| 3295 | + | |
3296 | 3296 | | |
3297 | 3297 | | |
3298 | 3298 | | |
| |||
Lines changed: 11 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
0 commit comments