You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@spark.apache.org by we...@apache.org on 2020/04/23 05:01:50 UTC
[spark] branch branch-3.0 updated: [SPARK-31476][SQL][FOLLOWUP] Add
tests for extract('field', source)
This is an automated email from the ASF dual-hosted git repository.
wenchen pushed a commit to branch branch-3.0
in repository https://gitbox.apache.org/repos/asf/spark.git
The following commit(s) were added to refs/heads/branch-3.0 by this push:
new 6e76310 [SPARK-31476][SQL][FOLLOWUP] Add tests for extract('field', source)
6e76310 is described below
commit 6e76310dd5eaf5da68e3c46bcb536543d1fe27e4
Author: Takeshi Yamamuro <ya...@apache.org>
AuthorDate: Thu Apr 23 04:59:59 2020 +0000
[SPARK-31476][SQL][FOLLOWUP] Add tests for extract('field', source)
### What changes were proposed in this pull request?
SPARK-31476 has supported `extract('field', source)` as side-effect, so this PR intends to add some tests for the function in `SQLQueryTestSuite`.
### Why are the changes needed?
For better test coverage.
### Does this PR introduce any user-facing change?
No.
### How was this patch tested?
Added tests.
Closes #28276 from maropu/SPARK-31476-FOLLOWUP.
Authored-by: Takeshi Yamamuro <ya...@apache.org>
Signed-off-by: Wenchen Fan <we...@databricks.com>
(cherry picked from commit 820733aee29f001037377d5dd3a3cf0d0ef8232d)
Signed-off-by: Wenchen Fan <we...@databricks.com>
---
.../test/resources/sql-tests/inputs/extract.sql | 16 +++-
.../resources/sql-tests/results/extract.sql.out | 98 +++++++++++++++++++++-
2 files changed, 112 insertions(+), 2 deletions(-)
diff --git a/sql/core/src/test/resources/sql-tests/inputs/extract.sql b/sql/core/src/test/resources/sql-tests/inputs/extract.sql
index cba7fc2..abb9e82 100644
--- a/sql/core/src/test/resources/sql-tests/inputs/extract.sql
+++ b/sql/core/src/test/resources/sql-tests/inputs/extract.sql
@@ -108,4 +108,18 @@ select date_part(c, c) from t;
select date_part(null, c) from t;
select date_part(i, i) from t;
-select date_part(null, i) from t;
\ No newline at end of file
+select date_part(null, i) from t;
+
+-- In SPARK-31476, we've supported extract('field', source), too
+select extract('year', c) from t;
+select extract('quarter', c) from t;
+select extract('month', c) from t;
+select extract('week', c) from t;
+select extract('day', c) from t;
+select extract('days', c) from t;
+select extract('dayofweek', c) from t;
+select extract('dow', c) from t;
+select extract('doy', c) from t;
+select extract('hour', c) from t;
+select extract('minute', c) from t;
+select extract('second', c) from t;
diff --git a/sql/core/src/test/resources/sql-tests/results/extract.sql.out b/sql/core/src/test/resources/sql-tests/results/extract.sql.out
index 220acfb..aea09e4 100644
--- a/sql/core/src/test/resources/sql-tests/results/extract.sql.out
+++ b/sql/core/src/test/resources/sql-tests/results/extract.sql.out
@@ -1,5 +1,5 @@
-- Automatically generated by SQLQueryTestSuite
--- Number of queries: 84
+-- Number of queries: 96
-- !query
@@ -677,3 +677,99 @@ select date_part(null, i) from t
struct<date_part(NULL, t.`i`):double>
-- !query output
NULL
+
+
+-- !query
+select extract('year', c) from t
+-- !query schema
+struct<extract('year' FROM t.`c`):int>
+-- !query output
+2011
+
+
+-- !query
+select extract('quarter', c) from t
+-- !query schema
+struct<extract('quarter' FROM t.`c`):int>
+-- !query output
+2
+
+
+-- !query
+select extract('month', c) from t
+-- !query schema
+struct<extract('month' FROM t.`c`):int>
+-- !query output
+5
+
+
+-- !query
+select extract('week', c) from t
+-- !query schema
+struct<extract('week' FROM t.`c`):int>
+-- !query output
+18
+
+
+-- !query
+select extract('day', c) from t
+-- !query schema
+struct<extract('day' FROM t.`c`):int>
+-- !query output
+6
+
+
+-- !query
+select extract('days', c) from t
+-- !query schema
+struct<extract('days' FROM t.`c`):int>
+-- !query output
+6
+
+
+-- !query
+select extract('dayofweek', c) from t
+-- !query schema
+struct<extract('dayofweek' FROM t.`c`):int>
+-- !query output
+6
+
+
+-- !query
+select extract('dow', c) from t
+-- !query schema
+struct<extract('dow' FROM t.`c`):int>
+-- !query output
+6
+
+
+-- !query
+select extract('doy', c) from t
+-- !query schema
+struct<extract('doy' FROM t.`c`):int>
+-- !query output
+126
+
+
+-- !query
+select extract('hour', c) from t
+-- !query schema
+struct<extract('hour' FROM t.`c`):int>
+-- !query output
+7
+
+
+-- !query
+select extract('minute', c) from t
+-- !query schema
+struct<extract('minute' FROM t.`c`):int>
+-- !query output
+8
+
+
+-- !query
+select extract('second', c) from t
+-- !query schema
+struct<extract('second' FROM t.`c`):decimal(8,6)>
+-- !query output
+9.123456
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@spark.apache.org
For additional commands, e-mail: commits-help@spark.apache.org