You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit 45e21bd
Browse filesBrowse the repository at this point in the historyBrowse files
Copy file name to clipboardExpand all lines: cases/conversion/text_literal_casts.toml
+27Lines changed: 27 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -20,3 +20,30 @@ rows = [["1"]]
20
20
query = "SELECT CAST('twelve' AS NUMBER(10,0)) AS n FROM input ORDER BY ordinal"
21
21
order = "ordered"
22
22
tags = ["invalid"]
23
+
24
+
[[case]]
25
+
id = "number_literal_casts_to_text"
26
+
description = "Integer and decimal literals cast to VARCHAR and VARCHAR(10) beside an input column."
27
+
columns = [{ name = "x", type = "NUMBER(10,0)" }]
28
+
rows = [["1"], ["NULL"]]
29
+
query = "SELECT x, CAST(501 AS VARCHAR) AS a, 501::VARCHAR(10) AS b, CAST(-7 AS VARCHAR) AS c, CAST(0 AS VARCHAR) AS d, CAST(1.50 AS VARCHAR) AS e FROM input ORDER BY ordinal"
30
+
order = "ordered"
31
+
tags = ["null", "zero", "negative"]
32
+
33
+
[[case]]
34
+
id = "text_literal_minute_timestamps"
35
+
description = "String literals with minutes but no seconds cast to TIMESTAMP_NTZ, TIMESTAMP_NTZ(3) and DATE."
36
+
columns = [{ name = "x", type = "NUMBER(10,0)" }]
37
+
rows = [["1"], ["NULL"]]
38
+
query = "SELECT x, CAST('2024-05-01 15:00' AS TIMESTAMP_NTZ) AS t, '2024-05-01 09:05'::TIMESTAMP_NTZ(3) AS t3, CAST('2024-05-01T15:00' AS TIMESTAMP_NTZ) AS iso FROM input ORDER BY ordinal"
39
+
order = "ordered"
40
+
tags = ["null", "boundary"]
41
+
42
+
[[case]]
43
+
id = "integer_literal_casts_to_text"
44
+
description = "Integer literals cast to VARCHAR and VARCHAR(16) beside an input column: positive, negative, zero and thirteen digits."
45
+
columns = [{ name = "x", type = "NUMBER(10,0)" }]
46
+
rows = [["1"], ["NULL"]]
47
+
query = "SELECT x, CAST(501 AS VARCHAR) AS a, 501::VARCHAR(16) AS b, CAST(-7 AS VARCHAR) AS c, CAST(0 AS VARCHAR) AS d, CAST(1234567890123 AS VARCHAR) AS e FROM input ORDER BY ordinal"
# Casts of VARIANTs built from a FLOAT: a member read as INTEGER or BOOLEAN, an ARRAY cast and an element cast to OBJECT.
2
+
category = "semi-structured-typed"
3
+
construct = "node:cast"
4
+
session_profile = "utc-v1"
5
+
6
+
[[case]]
7
+
id = "held_float_member_integer"
8
+
description = "A FLOAT member of OBJECT_CONSTRUCT read as INTEGER and NUMBER(38,0): halves, negatives, a double just below a half and a missing member."
9
+
columns = [{ name = "x", type = "FLOAT" }]
10
+
rows = [
11
+
["1.5"],
12
+
["2.5"],
13
+
["-2.5"],
14
+
["0.49999999999999994"],
15
+
["123456.789"],
16
+
["1e15"],
17
+
["0"],
18
+
["NULL"],
19
+
]
20
+
query = "SELECT OBJECT_CONSTRUCT('r', x):r::INTEGER AS i, OBJECT_CONSTRUCT('r', x):r::NUMBER(38,0) AS n FROM input ORDER BY ordinal"
21
+
order = "ordered"
22
+
tags = ["null", "boundary", "negative", "zero"]
23
+
24
+
[[case]]
25
+
id = "held_float_object_boolean_member"
26
+
description = "A BOOLEAN member of an object that also holds a FLOAT, read as BOOLEAN, with a missing member when the FLOAT is NULL."
27
+
columns = [{ name = "x", type = "FLOAT" }]
28
+
rows = [
29
+
["1.5"],
30
+
["-0.25"],
31
+
["0"],
32
+
["NULL"],
33
+
]
34
+
query = "SELECT OBJECT_CONSTRUCT('r', x, 'is_positive', x > 0):is_positive::BOOLEAN AS p FROM input ORDER BY ordinal"
35
+
order = "ordered"
36
+
tags = ["null", "zero", "negative"]
37
+
38
+
[[case]]
39
+
id = "held_float_array_cast"
40
+
description = "ARRAY_CONSTRUCT of a FLOAT cast to ARRAY, read by ARRAY_SIZE and TO_JSON, with a NULL element kept as undefined."
41
+
columns = [{ name = "x", type = "FLOAT" }]
42
+
rows = [
43
+
["1.5"],
44
+
["0.1"],
45
+
["-1e-7"],
46
+
["1e300"],
47
+
["NULL"],
48
+
]
49
+
query = "SELECT ARRAY_SIZE(CAST(ARRAY_CONSTRUCT(x) AS ARRAY))::NUMBER(38,0) AS n, TO_JSON(CAST(ARRAY_CONSTRUCT(x) AS ARRAY)) AS j FROM input ORDER BY ordinal"
50
+
order = "ordered"
51
+
expected_divergence = "json_fidelity"
52
+
tags = ["null", "boundary"]
53
+
54
+
[[case]]
55
+
id = "held_float_array_cast_defined"
56
+
description = "ARRAY_CONSTRUCT of a non-NULL FLOAT cast to ARRAY, read by ARRAY_SIZE and TO_JSON."
57
+
columns = [{ name = "x", type = "FLOAT" }]
58
+
rows = [
59
+
["1.5"],
60
+
["0.1"],
61
+
["-1e-7"],
62
+
["1e300"],
63
+
]
64
+
query = "SELECT ARRAY_SIZE(CAST(ARRAY_CONSTRUCT(x) AS ARRAY))::NUMBER(38,0) AS n, TO_JSON(CAST(ARRAY_CONSTRUCT(x) AS ARRAY)) AS j FROM input ORDER BY ordinal"
65
+
order = "ordered"
66
+
tags = ["boundary", "negative"]
67
+
68
+
[[case]]
69
+
id = "held_float_element_object_insert"
70
+
description = "An element of an array of FLOAT-holding objects cast to OBJECT and extended by OBJECT_INSERT, written by TO_JSON."
71
+
columns = [{ name = "x", type = "FLOAT" }, { name = "c", type = "VARCHAR" }]
72
+
rows = [
73
+
["1.5", "'a'"],
74
+
["0.1", "'b'"],
75
+
["NULL", "'c'"],
76
+
["2.5", "NULL"],
77
+
]
78
+
query = "SELECT TO_JSON(OBJECT_INSERT(ARRAY_CONSTRUCT(OBJECT_CONSTRUCT('r', x))[0]::OBJECT, 'check', c)) AS j FROM input ORDER BY ordinal"
0 commit comments