diff --git a/docs/source/contributor-guide/spark_expressions_support.md b/docs/source/contributor-guide/spark_expressions_support.md index cb27a439b9..a3d758e14f 100644 --- a/docs/source/contributor-guide/spark_expressions_support.md +++ b/docs/source/contributor-guide/spark_expressions_support.md @@ -220,7 +220,7 @@ - [ ] current_date - [ ] current_time - [ ] current_timestamp -- [ ] current_timezone +- [x] current_timezone - [x] date_add - [x] date_diff - [x] date_format diff --git a/docs/source/user-guide/latest/expressions.md b/docs/source/user-guide/latest/expressions.md index 668081d257..1e4aaaf565 100644 --- a/docs/source/user-guide/latest/expressions.md +++ b/docs/source/user-guide/latest/expressions.md @@ -100,6 +100,7 @@ of expressions that be disabled. | Expression | SQL | | ---------------- | ---------------------------- | +| CurrentTimeZone | `current_timezone` | | DateAdd | `date_add` | | DateDiff | `datediff` | | DateFormat | `date_format` | diff --git a/spark/src/test/resources/sql-tests/expressions/datetime/current_timezone.sql b/spark/src/test/resources/sql-tests/expressions/datetime/current_timezone.sql new file mode 100644 index 0000000000..e5ca98f102 --- /dev/null +++ b/spark/src/test/resources/sql-tests/expressions/datetime/current_timezone.sql @@ -0,0 +1,40 @@ +-- Licensed to the Apache Software Foundation (ASF) under one +-- or more contributor license agreements. See the NOTICE file +-- distributed with this work for additional information +-- regarding copyright ownership. The ASF licenses this file +-- to you under the Apache License, Version 2.0 (the +-- "License"); you may not use this file except in compliance +-- with the License. You may obtain a copy of the License at +-- +-- http://www.apache.org/licenses/LICENSE-2.0 +-- +-- Unless required by applicable law or agreed to in writing, +-- software distributed under the License is distributed on an +-- "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +-- KIND, either express or implied. See the License for the +-- specific language governing permissions and limitations +-- under the License. + +statement +CREATE TABLE test_current_timezone(id INT) USING parquet + +statement +INSERT INTO test_current_timezone VALUES (1), (2), (3), (4), (NULL) + +query +SELECT current_timezone() + +query +SELECT current_timezone() IS NOT NULL + +query +SELECT current_timezone() = current_timezone() + +query +SELECT length(current_timezone()) > 0 + +query +SELECT id, current_timezone() IS NOT NULL FROM test_current_timezone + +query +SELECT id FROM test_current_timezone WHERE current_timezone() = current_timezone()