Skip to content

Commit 323b6d7

Browse files
authored
feat: support current timezone (apache#4348)
1 parent 526d216 commit 323b6d7

3 files changed

Lines changed: 42 additions & 1 deletion

File tree

docs/source/contributor-guide/spark_expressions_support.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -220,7 +220,7 @@
220220
- [ ] current_date
221221
- [ ] current_time
222222
- [ ] current_timestamp
223-
- [ ] current_timezone
223+
- [x] current_timezone
224224
- [x] date_add
225225
- [x] date_diff
226226
- [x] date_format

docs/source/user-guide/latest/expressions.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,7 @@ of expressions that be disabled.
101101

102102
| Expression | SQL |
103103
| ---------------- | ---------------------------- |
104+
| CurrentTimeZone | `current_timezone` |
104105
| DateAdd | `date_add` |
105106
| DateDiff | `datediff` |
106107
| DateFormat | `date_format` |
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
-- Licensed to the Apache Software Foundation (ASF) under one
2+
-- or more contributor license agreements. See the NOTICE file
3+
-- distributed with this work for additional information
4+
-- regarding copyright ownership. The ASF licenses this file
5+
-- to you under the Apache License, Version 2.0 (the
6+
-- "License"); you may not use this file except in compliance
7+
-- with the License. You may obtain a copy of the License at
8+
--
9+
-- http://www.apache.org/licenses/LICENSE-2.0
10+
--
11+
-- Unless required by applicable law or agreed to in writing,
12+
-- software distributed under the License is distributed on an
13+
-- "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14+
-- KIND, either express or implied. See the License for the
15+
-- specific language governing permissions and limitations
16+
-- under the License.
17+
18+
statement
19+
CREATE TABLE test_current_timezone(id INT) USING parquet
20+
21+
statement
22+
INSERT INTO test_current_timezone VALUES (1), (2), (3), (4), (NULL)
23+
24+
query
25+
SELECT current_timezone()
26+
27+
query
28+
SELECT current_timezone() IS NOT NULL
29+
30+
query
31+
SELECT current_timezone() = current_timezone()
32+
33+
query
34+
SELECT length(current_timezone()) > 0
35+
36+
query
37+
SELECT id, current_timezone() IS NOT NULL FROM test_current_timezone
38+
39+
query
40+
SELECT id FROM test_current_timezone WHERE current_timezone() = current_timezone()

0 commit comments

Comments
 (0)