Skip to content

Commit 18f86a8

Browse files
authored
test: add timestamptz bind test cases with different units/zones (#138)
## What's Changed Closes #120.
1 parent 81eed41 commit 18f86a8

4 files changed

Lines changed: 306 additions & 13 deletions

File tree

Lines changed: 94 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,94 @@
1+
// Copyright (c) 2025 ADBC Drivers Contributors
2+
//
3+
// Licensed under the Apache License, Version 2.0 (the "License");
4+
// you may not use this file except in compliance with the License.
5+
// You may obtain a copy of the License at
6+
//
7+
// http://www.apache.org/licenses/LICENSE-2.0
8+
//
9+
// Unless required by applicable law or agreed to in writing, software
10+
// distributed under the License is distributed on an "AS IS" BASIS,
11+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
// See the License for the specific language governing permissions and
13+
// limitations under the License.
14+
15+
// part: metadata
16+
17+
[setup]
18+
drop = "test_timestamptz"
19+
20+
[tags]
21+
sql-type-name = "TIMESTAMP WITH TIME ZONE"
22+
23+
// part: setup_query
24+
25+
CREATE TABLE test_timestamptz (
26+
idx INT,
27+
res TIMESTAMP(3) WITH TIME ZONE,
28+
res2 TIMESTAMP(3) WITH TIME ZONE
29+
);
30+
31+
// part: bind_query
32+
33+
INSERT INTO test_timestamptz VALUES ($1, $2, $3)
34+
35+
// part: bind_schema
36+
37+
{
38+
"format": "+s",
39+
"children": [
40+
{
41+
"name": "idx",
42+
"format": "i",
43+
"flags": []
44+
},
45+
{
46+
"name": "res",
47+
"format": "tsm:UTC",
48+
"flags": ["nullable"]
49+
},
50+
{
51+
"name": "res2",
52+
"format": "tsm:Asia/Tokyo",
53+
"flags": ["nullable"]
54+
}
55+
]
56+
}
57+
58+
// part: bind
59+
60+
{"idx": 3, "res": 1684158330000, "res2": 1684158330000}
61+
{"idx": 2, "res": 946684800000, "res2": 946684800000}
62+
{"idx": 1, "res": -14182940000, "res2": -14182940000}
63+
{"idx": 4, "res": 253402300799999, "res2": 253402300799999}
64+
{"idx": 0, "res": null, "res2": null}
65+
66+
// part: query
67+
68+
SELECT res, res2 FROM test_timestamptz ORDER BY idx
69+
70+
// part: expected_schema
71+
72+
{
73+
"format": "+s",
74+
"children": [
75+
{
76+
"name": "res",
77+
"format": "tsm:UTC",
78+
"flags": ["nullable"]
79+
},
80+
{
81+
"name": "res2",
82+
"format": "tsm:UTC",
83+
"flags": ["nullable"]
84+
}
85+
]
86+
}
87+
88+
// part: expected
89+
90+
{"res": null, "res2": null}
91+
{"res": -14182940000, "res2": -14182940000}
92+
{"res": 946684800000, "res2": 946684800000}
93+
{"res": 1684158330000, "res2": 1684158330000}
94+
{"res": 253402300799999, "res2": 253402300799999}
Lines changed: 94 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,94 @@
1+
// Copyright (c) 2025 ADBC Drivers Contributors
2+
//
3+
// Licensed under the Apache License, Version 2.0 (the "License");
4+
// you may not use this file except in compliance with the License.
5+
// You may obtain a copy of the License at
6+
//
7+
// http://www.apache.org/licenses/LICENSE-2.0
8+
//
9+
// Unless required by applicable law or agreed to in writing, software
10+
// distributed under the License is distributed on an "AS IS" BASIS,
11+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
// See the License for the specific language governing permissions and
13+
// limitations under the License.
14+
15+
// part: metadata
16+
17+
[setup]
18+
drop = "test_timestamptz"
19+
20+
[tags]
21+
sql-type-name = "TIMESTAMP WITH TIME ZONE"
22+
23+
// part: setup_query
24+
25+
CREATE TABLE test_timestamptz (
26+
idx INT,
27+
res TIMESTAMP(9) WITH TIME ZONE,
28+
res2 TIMESTAMP(9) WITH TIME ZONE
29+
);
30+
31+
// part: bind_query
32+
33+
INSERT INTO test_timestamptz VALUES ($1, $2, $3)
34+
35+
// part: bind_schema
36+
37+
{
38+
"format": "+s",
39+
"children": [
40+
{
41+
"name": "idx",
42+
"format": "i",
43+
"flags": []
44+
},
45+
{
46+
"name": "res",
47+
"format": "tsn:UTC",
48+
"flags": ["nullable"]
49+
},
50+
{
51+
"name": "res2",
52+
"format": "tsn:Asia/Tokyo",
53+
"flags": ["nullable"]
54+
}
55+
]
56+
}
57+
58+
// part: bind
59+
60+
{"idx": 3, "res": 1684158330000000000, "res2": 1684158330000000000}
61+
{"idx": 2, "res": 946684800000000000, "res2": 946684800000000000}
62+
{"idx": 1, "res": -9223372036854775808, "res2": -9223372036854775808}
63+
{"idx": 4, "res": 9223372036854775807, "res2": 9223372036854775807}
64+
{"idx": 0, "res": null, "res2": null}
65+
66+
// part: query
67+
68+
SELECT res, res2 FROM test_timestamptz ORDER BY idx
69+
70+
// part: expected_schema
71+
72+
{
73+
"format": "+s",
74+
"children": [
75+
{
76+
"name": "res",
77+
"format": "tsn:UTC",
78+
"flags": ["nullable"]
79+
},
80+
{
81+
"name": "res2",
82+
"format": "tsn:UTC",
83+
"flags": ["nullable"]
84+
}
85+
]
86+
}
87+
88+
// part: expected
89+
90+
{"res": null, "res2": null}
91+
{"res": -9223372036854775808, "res2": -9223372036854775808}
92+
{"res": 946684800000000000, "res2": 946684800000000000}
93+
{"res": 1684158330000000000, "res2": 1684158330000000000}
94+
{"res": 9223372036854775807, "res2": 9223372036854775807}
Lines changed: 94 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,94 @@
1+
// Copyright (c) 2025 ADBC Drivers Contributors
2+
//
3+
// Licensed under the Apache License, Version 2.0 (the "License");
4+
// you may not use this file except in compliance with the License.
5+
// You may obtain a copy of the License at
6+
//
7+
// http://www.apache.org/licenses/LICENSE-2.0
8+
//
9+
// Unless required by applicable law or agreed to in writing, software
10+
// distributed under the License is distributed on an "AS IS" BASIS,
11+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
// See the License for the specific language governing permissions and
13+
// limitations under the License.
14+
15+
// part: metadata
16+
17+
[setup]
18+
drop = "test_timestamptz"
19+
20+
[tags]
21+
sql-type-name = "TIMESTAMP WITH TIME ZONE"
22+
23+
// part: setup_query
24+
25+
CREATE TABLE test_timestamptz (
26+
idx INT,
27+
res TIMESTAMP(0) WITH TIME ZONE,
28+
res2 TIMESTAMP(0) WITH TIME ZONE
29+
);
30+
31+
// part: bind_query
32+
33+
INSERT INTO test_timestamptz VALUES ($1, $2, $3)
34+
35+
// part: bind_schema
36+
37+
{
38+
"format": "+s",
39+
"children": [
40+
{
41+
"name": "idx",
42+
"format": "i",
43+
"flags": []
44+
},
45+
{
46+
"name": "res",
47+
"format": "tss:UTC",
48+
"flags": ["nullable"]
49+
},
50+
{
51+
"name": "res2",
52+
"format": "tss:Asia/Tokyo",
53+
"flags": ["nullable"]
54+
}
55+
]
56+
}
57+
58+
// part: bind
59+
60+
{"idx": 3, "res": 1684158330, "res2": 1684158330}
61+
{"idx": 2, "res": 946684800, "res2": 946684800}
62+
{"idx": 1, "res": -14182940, "res2": -14182940}
63+
{"idx": 4, "res": 253402300799, "res2": 253402300799}
64+
{"idx": 0, "res": null, "res2": null}
65+
66+
// part: query
67+
68+
SELECT res, res2 FROM test_timestamptz ORDER BY idx
69+
70+
// part: expected_schema
71+
72+
{
73+
"format": "+s",
74+
"children": [
75+
{
76+
"name": "res",
77+
"format": "tss:UTC",
78+
"flags": ["nullable"]
79+
},
80+
{
81+
"name": "res2",
82+
"format": "tss:UTC",
83+
"flags": ["nullable"]
84+
}
85+
]
86+
}
87+
88+
// part: expected
89+
90+
{"res": null, "res2": null}
91+
{"res": -14182940, "res2": -14182940}
92+
{"res": 946684800, "res2": 946684800}
93+
{"res": 1684158330, "res2": 1684158330}
94+
{"res": 253402300799, "res2": 253402300799}

adbc_drivers_validation/queries/type/bind/timestamptz_us.txtcase

Lines changed: 24 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -24,12 +24,13 @@ sql-type-name = "TIMESTAMP WITH TIME ZONE"
2424

2525
CREATE TABLE test_timestamptz (
2626
idx INT,
27-
res TIMESTAMP WITH TIME ZONE
27+
res TIMESTAMP(6) WITH TIME ZONE,
28+
res2 TIMESTAMP(6) WITH TIME ZONE
2829
);
2930

3031
// part: bind_query
3132

32-
INSERT INTO test_timestamptz VALUES ($1, $2)
33+
INSERT INTO test_timestamptz VALUES ($1, $2, $3)
3334

3435
// part: bind_schema
3536

@@ -45,21 +46,26 @@ INSERT INTO test_timestamptz VALUES ($1, $2)
4546
"name": "res",
4647
"format": "tsu:UTC",
4748
"flags": ["nullable"]
49+
},
50+
{
51+
"name": "res2",
52+
"format": "tsu:Asia/Tokyo",
53+
"flags": ["nullable"]
4854
}
4955
]
5056
}
5157

5258
// part: bind
5359

54-
{"idx": 3, "res": 1684158330000000}
55-
{"idx": 2, "res": 946684800000000}
56-
{"idx": 1, "res": -14182940000000}
57-
{"idx": 4, "res": 253402300799000000}
58-
{"idx": 0, "res": null}
60+
{"idx": 3, "res": 1684158330000000, "res2": 1684158330000000}
61+
{"idx": 2, "res": 946684800000000, "res2": 946684800000000}
62+
{"idx": 1, "res": -14182940000000, "res2": -14182940000000}
63+
{"idx": 4, "res": 253402300799999999, "res2": 253402300799999999}
64+
{"idx": 0, "res": null, "res2": null}
5965

6066
// part: query
6167

62-
SELECT res FROM test_timestamptz ORDER BY idx
68+
SELECT res, res2 FROM test_timestamptz ORDER BY idx
6369

6470
// part: expected_schema
6571

@@ -70,14 +76,19 @@ SELECT res FROM test_timestamptz ORDER BY idx
7076
"name": "res",
7177
"format": "tsu:UTC",
7278
"flags": ["nullable"]
79+
},
80+
{
81+
"name": "res2",
82+
"format": "tsu:UTC",
83+
"flags": ["nullable"]
7384
}
7485
]
7586
}
7687

7788
// part: expected
7889

79-
{"res": null}
80-
{"res": -14182940000000}
81-
{"res": 946684800000000}
82-
{"res": 1684158330000000}
83-
{"res": 253402300799000000}
90+
{"res": null, "res2": null}
91+
{"res": -14182940000000, "res2": -14182940000000}
92+
{"res": 946684800000000, "res2": 946684800000000}
93+
{"res": 1684158330000000, "res2": 1684158330000000}
94+
{"res": 253402300799999999, "res2": 253402300799999999}

0 commit comments

Comments
 (0)