You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@spark.apache.org by gu...@apache.org on 2020/02/10 07:26:06 UTC
[spark] branch branch-3.0 updated: [SPARK-30592][SQL][FOLLOWUP] Add
some round-trip test cases
This is an automated email from the ASF dual-hosted git repository.
gurwls223 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 b012ff7 [SPARK-30592][SQL][FOLLOWUP] Add some round-trip test cases
b012ff7 is described below
commit b012ff72b64f08e3fcb9e4fbcf04b874711cf5b6
Author: Kent Yao <ya...@hotmail.com>
AuthorDate: Mon Feb 10 16:23:44 2020 +0900
[SPARK-30592][SQL][FOLLOWUP] Add some round-trip test cases
### What changes were proposed in this pull request?
Add round-trip tests for CSV and JSON functions as https://github.com/apache/spark/pull/27317#discussion_r376745135 asked.
### Why are the changes needed?
improve test coverage
### Does this PR introduce any user-facing change?
no
### How was this patch tested?
add uts
Closes #27510 from yaooqinn/SPARK-30592-F.
Authored-by: Kent Yao <ya...@hotmail.com>
Signed-off-by: HyukjinKwon <gu...@apache.org>
(cherry picked from commit 58b9ca1e6f7768b23e752dabc30468c06d0e1c57)
Signed-off-by: HyukjinKwon <gu...@apache.org>
---
.../test/resources/sql-tests/inputs/interval.sql | 14 +++++---
.../sql-tests/results/ansi/interval.sql.out | 38 +++++++++-------------
.../resources/sql-tests/results/interval.sql.out | 38 +++++++++-------------
3 files changed, 40 insertions(+), 50 deletions(-)
diff --git a/sql/core/src/test/resources/sql-tests/inputs/interval.sql b/sql/core/src/test/resources/sql-tests/inputs/interval.sql
index fb6c485..a4e621e 100644
--- a/sql/core/src/test/resources/sql-tests/inputs/interval.sql
+++ b/sql/core/src/test/resources/sql-tests/inputs/interval.sql
@@ -222,7 +222,13 @@ select a * 1.1 from values (interval '-2147483648 months', interval '2147483647
select a / 0.5 from values (interval '-2147483648 months', interval '2147483647 months') t(a, b);
-- interval support for csv and json functions
-SELECT from_csv('1, 1 day', 'a INT, b interval');
-SELECT to_csv(named_struct('a', interval 32 month, 'b', interval 70 minute));
-SELECT from_json('{"a":"1 days"}', 'a interval');
-SELECT to_json(map('a', interval 25 month 100 day 130 minute));
+SELECT
+ from_csv('1, 1 day', 'a INT, b interval'),
+ to_csv(from_csv('1, 1 day', 'a INT, b interval')),
+ to_csv(named_struct('a', interval 32 month, 'b', interval 70 minute)),
+ from_csv(to_csv(named_struct('a', interval 32 month, 'b', interval 70 minute)), 'a interval, b interval');
+SELECT
+ from_json('{"a":"1 days"}', 'a interval'),
+ to_json(from_json('{"a":"1 days"}', 'a interval')),
+ to_json(map('a', interval 25 month 100 day 130 minute)),
+ from_json(to_json(map('a', interval 25 month 100 day 130 minute)), 'a interval');
diff --git a/sql/core/src/test/resources/sql-tests/results/ansi/interval.sql.out b/sql/core/src/test/resources/sql-tests/results/ansi/interval.sql.out
index f370490..7fdb4c5 100644
--- a/sql/core/src/test/resources/sql-tests/results/ansi/interval.sql.out
+++ b/sql/core/src/test/resources/sql-tests/results/ansi/interval.sql.out
@@ -1,5 +1,5 @@
-- Automatically generated by SQLQueryTestSuite
--- Number of queries: 101
+-- Number of queries: 99
-- !query
@@ -988,32 +988,24 @@ integer overflow
-- !query
-SELECT from_csv('1, 1 day', 'a INT, b interval')
--- !query schema
-struct<from_csv(1, 1 day):struct<a:int,b:interval>>
--- !query output
-{"a":1,"b":1 days}
-
-
--- !query
-SELECT to_csv(named_struct('a', interval 32 month, 'b', interval 70 minute))
--- !query schema
-struct<to_csv(named_struct(a, INTERVAL '2 years 8 months', b, INTERVAL '1 hours 10 minutes')):string>
--- !query output
-2 years 8 months,1 hours 10 minutes
-
-
--- !query
-SELECT from_json('{"a":"1 days"}', 'a interval')
+SELECT
+ from_csv('1, 1 day', 'a INT, b interval'),
+ to_csv(from_csv('1, 1 day', 'a INT, b interval')),
+ to_csv(named_struct('a', interval 32 month, 'b', interval 70 minute)),
+ from_csv(to_csv(named_struct('a', interval 32 month, 'b', interval 70 minute)), 'a interval, b interval')
-- !query schema
-struct<from_json({"a":"1 days"}):struct<a:interval>>
+struct<from_csv(1, 1 day):struct<a:int,b:interval>,to_csv(from_csv(1, 1 day)):string,to_csv(named_struct(a, INTERVAL '2 years 8 months', b, INTERVAL '1 hours 10 minutes')):string,from_csv(to_csv(named_struct(a, INTERVAL '2 years 8 months', b, INTERVAL '1 hours 10 minutes'))):struct<a:interval,b:interval>>
-- !query output
-{"a":1 days}
+{"a":1,"b":1 days} 1,1 days 2 years 8 months,1 hours 10 minutes {"a":2 years 8 months,"b":1 hours 10 minutes}
-- !query
-SELECT to_json(map('a', interval 25 month 100 day 130 minute))
+SELECT
+ from_json('{"a":"1 days"}', 'a interval'),
+ to_json(from_json('{"a":"1 days"}', 'a interval')),
+ to_json(map('a', interval 25 month 100 day 130 minute)),
+ from_json(to_json(map('a', interval 25 month 100 day 130 minute)), 'a interval')
-- !query schema
-struct<to_json(map(a, INTERVAL '2 years 1 months 100 days 2 hours 10 minutes')):string>
+struct<from_json({"a":"1 days"}):struct<a:interval>,to_json(from_json({"a":"1 days"})):string,to_json(map(a, INTERVAL '2 years 1 months 100 days 2 hours 10 minutes')):string,from_json(to_json(map(a, INTERVAL '2 years 1 months 100 days 2 hours 10 minutes'))):struct<a:interval>>
-- !query output
-{"a":"2 years 1 months 100 days 2 hours 10 minutes"}
+{"a":1 days} {"a":"1 days"} {"a":"2 years 1 months 100 days 2 hours 10 minutes"} {"a":2 years 1 months 100 days 2 hours 10 minutes}
diff --git a/sql/core/src/test/resources/sql-tests/results/interval.sql.out b/sql/core/src/test/resources/sql-tests/results/interval.sql.out
index 94b4f15..3c4b430 100644
--- a/sql/core/src/test/resources/sql-tests/results/interval.sql.out
+++ b/sql/core/src/test/resources/sql-tests/results/interval.sql.out
@@ -1,5 +1,5 @@
-- Automatically generated by SQLQueryTestSuite
--- Number of queries: 101
+-- Number of queries: 99
-- !query
@@ -969,32 +969,24 @@ integer overflow
-- !query
-SELECT from_csv('1, 1 day', 'a INT, b interval')
--- !query schema
-struct<from_csv(1, 1 day):struct<a:int,b:interval>>
--- !query output
-{"a":1,"b":1 days}
-
-
--- !query
-SELECT to_csv(named_struct('a', interval 32 month, 'b', interval 70 minute))
--- !query schema
-struct<to_csv(named_struct(a, INTERVAL '2 years 8 months', b, INTERVAL '1 hours 10 minutes')):string>
--- !query output
-2 years 8 months,1 hours 10 minutes
-
-
--- !query
-SELECT from_json('{"a":"1 days"}', 'a interval')
+SELECT
+ from_csv('1, 1 day', 'a INT, b interval'),
+ to_csv(from_csv('1, 1 day', 'a INT, b interval')),
+ to_csv(named_struct('a', interval 32 month, 'b', interval 70 minute)),
+ from_csv(to_csv(named_struct('a', interval 32 month, 'b', interval 70 minute)), 'a interval, b interval')
-- !query schema
-struct<from_json({"a":"1 days"}):struct<a:interval>>
+struct<from_csv(1, 1 day):struct<a:int,b:interval>,to_csv(from_csv(1, 1 day)):string,to_csv(named_struct(a, INTERVAL '2 years 8 months', b, INTERVAL '1 hours 10 minutes')):string,from_csv(to_csv(named_struct(a, INTERVAL '2 years 8 months', b, INTERVAL '1 hours 10 minutes'))):struct<a:interval,b:interval>>
-- !query output
-{"a":1 days}
+{"a":1,"b":1 days} 1,1 days 2 years 8 months,1 hours 10 minutes {"a":2 years 8 months,"b":1 hours 10 minutes}
-- !query
-SELECT to_json(map('a', interval 25 month 100 day 130 minute))
+SELECT
+ from_json('{"a":"1 days"}', 'a interval'),
+ to_json(from_json('{"a":"1 days"}', 'a interval')),
+ to_json(map('a', interval 25 month 100 day 130 minute)),
+ from_json(to_json(map('a', interval 25 month 100 day 130 minute)), 'a interval')
-- !query schema
-struct<to_json(map(a, INTERVAL '2 years 1 months 100 days 2 hours 10 minutes')):string>
+struct<from_json({"a":"1 days"}):struct<a:interval>,to_json(from_json({"a":"1 days"})):string,to_json(map(a, INTERVAL '2 years 1 months 100 days 2 hours 10 minutes')):string,from_json(to_json(map(a, INTERVAL '2 years 1 months 100 days 2 hours 10 minutes'))):struct<a:interval>>
-- !query output
-{"a":"2 years 1 months 100 days 2 hours 10 minutes"}
+{"a":1 days} {"a":"1 days"} {"a":"2 years 1 months 100 days 2 hours 10 minutes"} {"a":2 years 1 months 100 days 2 hours 10 minutes}
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@spark.apache.org
For additional commands, e-mail: commits-help@spark.apache.org