diff --git a/sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/analysis/TypeCoercion.scala b/sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/analysis/TypeCoercion.scala index c451eb2b877d..7e049bb1dc7c 100644 --- a/sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/analysis/TypeCoercion.scala +++ b/sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/analysis/TypeCoercion.scala @@ -412,10 +412,10 @@ object TypeCoercion { case e if !e.childrenResolved => e case a @ BinaryArithmetic(left @ StringType(), right) - if right.dataType != CalendarIntervalType => + if !Seq(CalendarIntervalType, TimestampType, DateType).contains(right.dataType) => a.makeCopy(Array(Cast(left, DoubleType), right)) case a @ BinaryArithmetic(left, right @ StringType()) - if left.dataType != CalendarIntervalType => + if !Seq(CalendarIntervalType, TimestampType, DateType).contains(left.dataType) => a.makeCopy(Array(left, Cast(right, DoubleType))) // For equality between string and timestamp we cast the string to a timestamp @@ -846,6 +846,8 @@ object TypeCoercion { Cast(TimeAdd(l, r), l.dataType) case Subtract(l, r @ CalendarIntervalType()) if acceptedTypes.contains(l.dataType) => Cast(TimeSub(l, r), l.dataType) + case Subtract(l @ CalendarIntervalType(), r @ StringType()) => + Subtract(l, Cast(r, CalendarIntervalType)) case Add(l @ DateType(), r @ IntegerType()) => DateAdd(l, r) case Add(l @ IntegerType(), r @ DateType()) => DateAdd(r, l) @@ -858,6 +860,17 @@ object TypeCoercion { SubtractTimestamps(l, Cast(r, TimestampType)) case Subtract(l @ DateType(), r @ TimestampType()) => SubtractTimestamps(Cast(l, TimestampType), r) + + // Cast StringType to CalendarIntervalType + case Add(l @ StringType(), r @ (TimestampType() | DateType())) => + TimeAdd(r, Cast(l, CalendarIntervalType)) + case Add(l @ (TimestampType() | DateType()), r @ StringType()) => + TimeAdd(l, Cast(r, CalendarIntervalType)) + // Cast StringType to TimestampType + case Subtract(l @ StringType(), r @ (TimestampType() | DateType())) => + SubtractTimestamps(Cast(l, TimestampType), r) + case Subtract(l @ (TimestampType() | DateType()), r @ StringType()) => + SubtractTimestamps(l, Cast(r, TimestampType)) } } diff --git a/sql/catalyst/src/test/scala/org/apache/spark/sql/catalyst/analysis/TypeCoercionSuite.scala b/sql/catalyst/src/test/scala/org/apache/spark/sql/catalyst/analysis/TypeCoercionSuite.scala index 4f9e4ec0201d..5694892e0402 100644 --- a/sql/catalyst/src/test/scala/org/apache/spark/sql/catalyst/analysis/TypeCoercionSuite.scala +++ b/sql/catalyst/src/test/scala/org/apache/spark/sql/catalyst/analysis/TypeCoercionSuite.scala @@ -1408,6 +1408,7 @@ class TypeCoercionSuite extends AnalysisTest { val interval = Literal(new CalendarInterval(0, 0)) val str = Literal("2015-01-01") val intValue = Literal(0, IntegerType) + val strInterval = Literal("1 day") ruleTest(dateTimeOperations, Add(date, interval), Cast(TimeAdd(date, interval), DateType)) ruleTest(dateTimeOperations, Add(interval, date), Cast(TimeAdd(date, interval), DateType)) @@ -1422,6 +1423,8 @@ class TypeCoercionSuite extends AnalysisTest { ruleTest(dateTimeOperations, Subtract(timestamp, interval), Cast(TimeSub(timestamp, interval), TimestampType)) ruleTest(dateTimeOperations, Subtract(str, interval), Cast(TimeSub(str, interval), StringType)) + ruleTest(dateTimeOperations, Subtract(interval, strInterval), + Subtract(interval, Cast(strInterval, CalendarIntervalType))) // interval operations should not be effected ruleTest(dateTimeOperations, Add(interval, interval), Add(interval, interval)) @@ -1437,6 +1440,22 @@ class TypeCoercionSuite extends AnalysisTest { SubtractTimestamps(timestamp, Cast(date, TimestampType))) ruleTest(dateTimeOperations, Subtract(date, timestamp), SubtractTimestamps(Cast(date, TimestampType), timestamp)) + + ruleTest(dateTimeOperations, Add(timestamp, str), + TimeAdd(timestamp, Cast(str, CalendarIntervalType))) + ruleTest(dateTimeOperations, Add(date, str), TimeAdd(date, Cast(str, CalendarIntervalType))) + ruleTest(dateTimeOperations, Add(str, timestamp), + TimeAdd(timestamp, Cast(str, CalendarIntervalType))) + ruleTest(dateTimeOperations, Add(str, date), TimeAdd(date, Cast(str, CalendarIntervalType))) + + ruleTest(dateTimeOperations, Subtract(timestamp, str), + SubtractTimestamps(timestamp, Cast(str, TimestampType))) + ruleTest(dateTimeOperations, Subtract(date, str), + SubtractTimestamps(date, Cast(str, TimestampType))) + ruleTest(dateTimeOperations, Subtract(str, timestamp), + SubtractTimestamps(Cast(str, TimestampType), timestamp)) + ruleTest(dateTimeOperations, Subtract(str, date), + SubtractTimestamps(Cast(str, TimestampType), date)) } /** diff --git a/sql/core/src/test/resources/sql-tests/inputs/typeCoercion/native/dateTimeOperations.sql b/sql/core/src/test/resources/sql-tests/inputs/typeCoercion/native/dateTimeOperations.sql index 1e9822186796..00177b9b1db9 100644 --- a/sql/core/src/test/resources/sql-tests/inputs/typeCoercion/native/dateTimeOperations.sql +++ b/sql/core/src/test/resources/sql-tests/inputs/typeCoercion/native/dateTimeOperations.sql @@ -58,3 +58,15 @@ select cast('1' as binary) - interval 2 day; select cast(1 as boolean) - interval 2 day; select cast('2017-12-11 09:30:00.0' as timestamp) - interval 2 day; select cast('2017-12-11 09:30:00' as date) - interval 2 day; + +select interval 1 month - '2 seconds'; + +select '1 month' + date'2019-10-01'; +select '1 month 1 second' + timestamp'2019-10-18 10:11:12'; +select date'2019-10-01' + '1 month'; +select timestamp'2019-10-18 10:11:12' + '1 month 1 second'; + +select timestamp'2019-10-18 10:11:12' - '2019-10-18'; +select date'2019-10-18' - '2019-10-01'; +select '2019-10-18 10:11:12' - timestamp'2019-10-18 00:00:00'; +select '2019-10-18 10:11:12' - date'2019-10-18'; diff --git a/sql/core/src/test/resources/sql-tests/results/typeCoercion/native/dateTimeOperations.sql.out b/sql/core/src/test/resources/sql-tests/results/typeCoercion/native/dateTimeOperations.sql.out index a4cd408c04bf..9f5601e5e49d 100644 --- a/sql/core/src/test/resources/sql-tests/results/typeCoercion/native/dateTimeOperations.sql.out +++ b/sql/core/src/test/resources/sql-tests/results/typeCoercion/native/dateTimeOperations.sql.out @@ -1,5 +1,5 @@ -- Automatically generated by SQLQueryTestSuite --- Number of queries: 40 +-- Number of queries: 49 -- !query 0 @@ -347,3 +347,75 @@ select cast('2017-12-11 09:30:00' as date) - interval 2 day struct -- !query 39 output 2017-12-09 + + +-- !query 40 +select interval 1 month - '2 seconds' +-- !query 40 schema +struct<(interval 1 months - CAST(2 seconds AS INTERVAL)):interval> +-- !query 40 output +interval 1 months -2 seconds + + +-- !query 41 +select '1 month' + date'2019-10-01' +-- !query 41 schema +struct +-- !query 41 output +2019-11-01 00:00:00 + + +-- !query 42 +select '1 month 1 second' + timestamp'2019-10-18 10:11:12' +-- !query 42 schema +struct +-- !query 42 output +2019-11-18 10:11:13 + + +-- !query 43 +select date'2019-10-01' + '1 month' +-- !query 43 schema +struct +-- !query 43 output +2019-11-01 00:00:00 + + +-- !query 44 +select timestamp'2019-10-18 10:11:12' + '1 month 1 second' +-- !query 44 schema +struct +-- !query 44 output +2019-11-18 10:11:13 + + +-- !query 45 +select timestamp'2019-10-18 10:11:12' - '2019-10-18' +-- !query 45 schema +struct +-- !query 45 output +interval 10 hours 11 minutes 12 seconds + + +-- !query 46 +select date'2019-10-18' - '2019-10-01' +-- !query 46 schema +struct +-- !query 46 output +interval 2 weeks 3 days + + +-- !query 47 +select '2019-10-18 10:11:12' - timestamp'2019-10-18 00:00:00' +-- !query 47 schema +struct +-- !query 47 output +interval 10 hours 11 minutes 12 seconds + + +-- !query 48 +select '2019-10-18 10:11:12' - date'2019-10-18' +-- !query 48 schema +struct +-- !query 48 output +interval 10 hours 11 minutes 12 seconds diff --git a/sql/core/src/test/resources/sql-tests/results/typeCoercion/native/division.sql.out b/sql/core/src/test/resources/sql-tests/results/typeCoercion/native/division.sql.out index 017e0fea30e9..959770f50970 100644 --- a/sql/core/src/test/resources/sql-tests/results/typeCoercion/native/division.sql.out +++ b/sql/core/src/test/resources/sql-tests/results/typeCoercion/native/division.sql.out @@ -798,7 +798,7 @@ SELECT cast(1 as string) / cast('2017-12-11 09:30:00.0' as timestamp) FROM t struct<> -- !query 95 output org.apache.spark.sql.AnalysisException -cannot resolve '(CAST(CAST(1 AS STRING) AS DOUBLE) / CAST('2017-12-11 09:30:00.0' AS TIMESTAMP))' due to data type mismatch: differing types in '(CAST(CAST(1 AS STRING) AS DOUBLE) / CAST('2017-12-11 09:30:00.0' AS TIMESTAMP))' (double and timestamp).; line 1 pos 7 +cannot resolve '(CAST(1 AS STRING) / CAST('2017-12-11 09:30:00.0' AS TIMESTAMP))' due to data type mismatch: differing types in '(CAST(1 AS STRING) / CAST('2017-12-11 09:30:00.0' AS TIMESTAMP))' (string and timestamp).; line 1 pos 7 -- !query 96 @@ -807,7 +807,7 @@ SELECT cast(1 as string) / cast('2017-12-11 09:30:00' as date) FROM t struct<> -- !query 96 output org.apache.spark.sql.AnalysisException -cannot resolve '(CAST(CAST(1 AS STRING) AS DOUBLE) / CAST('2017-12-11 09:30:00' AS DATE))' due to data type mismatch: differing types in '(CAST(CAST(1 AS STRING) AS DOUBLE) / CAST('2017-12-11 09:30:00' AS DATE))' (double and date).; line 1 pos 7 +cannot resolve '(CAST(1 AS STRING) / CAST('2017-12-11 09:30:00' AS DATE))' due to data type mismatch: differing types in '(CAST(1 AS STRING) / CAST('2017-12-11 09:30:00' AS DATE))' (string and date).; line 1 pos 7 -- !query 97 @@ -1095,7 +1095,7 @@ SELECT cast('2017-12-11 09:30:00.0' as timestamp) / cast(1 as string) FROM t struct<> -- !query 128 output org.apache.spark.sql.AnalysisException -cannot resolve '(CAST('2017-12-11 09:30:00.0' AS TIMESTAMP) / CAST(CAST(1 AS STRING) AS DOUBLE))' due to data type mismatch: differing types in '(CAST('2017-12-11 09:30:00.0' AS TIMESTAMP) / CAST(CAST(1 AS STRING) AS DOUBLE))' (timestamp and double).; line 1 pos 7 +cannot resolve '(CAST('2017-12-11 09:30:00.0' AS TIMESTAMP) / CAST(1 AS STRING))' due to data type mismatch: differing types in '(CAST('2017-12-11 09:30:00.0' AS TIMESTAMP) / CAST(1 AS STRING))' (timestamp and string).; line 1 pos 7 -- !query 129 @@ -1203,7 +1203,7 @@ SELECT cast('2017-12-11 09:30:00' as date) / cast(1 as string) FROM t struct<> -- !query 140 output org.apache.spark.sql.AnalysisException -cannot resolve '(CAST('2017-12-11 09:30:00' AS DATE) / CAST(CAST(1 AS STRING) AS DOUBLE))' due to data type mismatch: differing types in '(CAST('2017-12-11 09:30:00' AS DATE) / CAST(CAST(1 AS STRING) AS DOUBLE))' (date and double).; line 1 pos 7 +cannot resolve '(CAST('2017-12-11 09:30:00' AS DATE) / CAST(1 AS STRING))' due to data type mismatch: differing types in '(CAST('2017-12-11 09:30:00' AS DATE) / CAST(1 AS STRING))' (date and string).; line 1 pos 7 -- !query 141 diff --git a/sql/core/src/test/resources/sql-tests/results/typeCoercion/native/promoteStrings.sql.out b/sql/core/src/test/resources/sql-tests/results/typeCoercion/native/promoteStrings.sql.out index c54ceba85ce7..fc5d4aa5611c 100644 --- a/sql/core/src/test/resources/sql-tests/results/typeCoercion/native/promoteStrings.sql.out +++ b/sql/core/src/test/resources/sql-tests/results/typeCoercion/native/promoteStrings.sql.out @@ -95,19 +95,17 @@ cannot resolve '(CAST('1' AS DOUBLE) + CAST(1 AS BOOLEAN))' due to data type mis -- !query 11 SELECT '1' + cast('2017-12-11 09:30:00.0' as timestamp) FROM t -- !query 11 schema -struct<> +struct -- !query 11 output -org.apache.spark.sql.AnalysisException -cannot resolve '(CAST('1' AS DOUBLE) + CAST('2017-12-11 09:30:00.0' AS TIMESTAMP))' due to data type mismatch: differing types in '(CAST('1' AS DOUBLE) + CAST('2017-12-11 09:30:00.0' AS TIMESTAMP))' (double and timestamp).; line 1 pos 7 +NULL -- !query 12 SELECT '1' + cast('2017-12-11 09:30:00' as date) FROM t -- !query 12 schema -struct<> +struct -- !query 12 output -org.apache.spark.sql.AnalysisException -cannot resolve '(CAST('1' AS DOUBLE) + CAST('2017-12-11 09:30:00' AS DATE))' due to data type mismatch: differing types in '(CAST('1' AS DOUBLE) + CAST('2017-12-11 09:30:00' AS DATE))' (double and date).; line 1 pos 7 +NULL -- !query 13 @@ -195,19 +193,17 @@ cannot resolve '(CAST('1' AS DOUBLE) - CAST(1 AS BOOLEAN))' due to data type mis -- !query 23 SELECT '1' - cast('2017-12-11 09:30:00.0' as timestamp) FROM t -- !query 23 schema -struct<> +struct -- !query 23 output -org.apache.spark.sql.AnalysisException -cannot resolve '(CAST('1' AS DOUBLE) - CAST('2017-12-11 09:30:00.0' AS TIMESTAMP))' due to data type mismatch: differing types in '(CAST('1' AS DOUBLE) - CAST('2017-12-11 09:30:00.0' AS TIMESTAMP))' (double and timestamp).; line 1 pos 7 +NULL -- !query 24 SELECT '1' - cast('2017-12-11 09:30:00' as date) FROM t -- !query 24 schema -struct<> +struct -- !query 24 output -org.apache.spark.sql.AnalysisException -cannot resolve '(CAST('1' AS DOUBLE) - CAST('2017-12-11 09:30:00' AS DATE))' due to data type mismatch: differing types in '(CAST('1' AS DOUBLE) - CAST('2017-12-11 09:30:00' AS DATE))' (double and date).; line 1 pos 7 +NULL -- !query 25 @@ -298,7 +294,7 @@ SELECT '1' * cast('2017-12-11 09:30:00.0' as timestamp) FROM t struct<> -- !query 35 output org.apache.spark.sql.AnalysisException -cannot resolve '(CAST('1' AS DOUBLE) * CAST('2017-12-11 09:30:00.0' AS TIMESTAMP))' due to data type mismatch: differing types in '(CAST('1' AS DOUBLE) * CAST('2017-12-11 09:30:00.0' AS TIMESTAMP))' (double and timestamp).; line 1 pos 7 +cannot resolve '('1' * CAST('2017-12-11 09:30:00.0' AS TIMESTAMP))' due to data type mismatch: differing types in '('1' * CAST('2017-12-11 09:30:00.0' AS TIMESTAMP))' (string and timestamp).; line 1 pos 7 -- !query 36 @@ -307,7 +303,7 @@ SELECT '1' * cast('2017-12-11 09:30:00' as date) FROM t struct<> -- !query 36 output org.apache.spark.sql.AnalysisException -cannot resolve '(CAST('1' AS DOUBLE) * CAST('2017-12-11 09:30:00' AS DATE))' due to data type mismatch: differing types in '(CAST('1' AS DOUBLE) * CAST('2017-12-11 09:30:00' AS DATE))' (double and date).; line 1 pos 7 +cannot resolve '('1' * CAST('2017-12-11 09:30:00' AS DATE))' due to data type mismatch: differing types in '('1' * CAST('2017-12-11 09:30:00' AS DATE))' (string and date).; line 1 pos 7 -- !query 37 @@ -398,7 +394,7 @@ SELECT '1' / cast('2017-12-11 09:30:00.0' as timestamp) FROM t struct<> -- !query 47 output org.apache.spark.sql.AnalysisException -cannot resolve '(CAST('1' AS DOUBLE) / CAST('2017-12-11 09:30:00.0' AS TIMESTAMP))' due to data type mismatch: differing types in '(CAST('1' AS DOUBLE) / CAST('2017-12-11 09:30:00.0' AS TIMESTAMP))' (double and timestamp).; line 1 pos 7 +cannot resolve '('1' / CAST('2017-12-11 09:30:00.0' AS TIMESTAMP))' due to data type mismatch: differing types in '('1' / CAST('2017-12-11 09:30:00.0' AS TIMESTAMP))' (string and timestamp).; line 1 pos 7 -- !query 48 @@ -407,7 +403,7 @@ SELECT '1' / cast('2017-12-11 09:30:00' as date) FROM t struct<> -- !query 48 output org.apache.spark.sql.AnalysisException -cannot resolve '(CAST('1' AS DOUBLE) / CAST('2017-12-11 09:30:00' AS DATE))' due to data type mismatch: differing types in '(CAST('1' AS DOUBLE) / CAST('2017-12-11 09:30:00' AS DATE))' (double and date).; line 1 pos 7 +cannot resolve '('1' / CAST('2017-12-11 09:30:00' AS DATE))' due to data type mismatch: differing types in '('1' / CAST('2017-12-11 09:30:00' AS DATE))' (string and date).; line 1 pos 7 -- !query 49 @@ -498,7 +494,7 @@ SELECT '1' % cast('2017-12-11 09:30:00.0' as timestamp) FROM t struct<> -- !query 59 output org.apache.spark.sql.AnalysisException -cannot resolve '(CAST('1' AS DOUBLE) % CAST('2017-12-11 09:30:00.0' AS TIMESTAMP))' due to data type mismatch: differing types in '(CAST('1' AS DOUBLE) % CAST('2017-12-11 09:30:00.0' AS TIMESTAMP))' (double and timestamp).; line 1 pos 7 +cannot resolve '('1' % CAST('2017-12-11 09:30:00.0' AS TIMESTAMP))' due to data type mismatch: differing types in '('1' % CAST('2017-12-11 09:30:00.0' AS TIMESTAMP))' (string and timestamp).; line 1 pos 7 -- !query 60 @@ -507,7 +503,7 @@ SELECT '1' % cast('2017-12-11 09:30:00' as date) FROM t struct<> -- !query 60 output org.apache.spark.sql.AnalysisException -cannot resolve '(CAST('1' AS DOUBLE) % CAST('2017-12-11 09:30:00' AS DATE))' due to data type mismatch: differing types in '(CAST('1' AS DOUBLE) % CAST('2017-12-11 09:30:00' AS DATE))' (double and date).; line 1 pos 7 +cannot resolve '('1' % CAST('2017-12-11 09:30:00' AS DATE))' due to data type mismatch: differing types in '('1' % CAST('2017-12-11 09:30:00' AS DATE))' (string and date).; line 1 pos 7 -- !query 61 @@ -598,7 +594,7 @@ SELECT pmod('1', cast('2017-12-11 09:30:00.0' as timestamp)) FROM t struct<> -- !query 71 output org.apache.spark.sql.AnalysisException -cannot resolve 'pmod(CAST('1' AS DOUBLE), CAST('2017-12-11 09:30:00.0' AS TIMESTAMP))' due to data type mismatch: differing types in 'pmod(CAST('1' AS DOUBLE), CAST('2017-12-11 09:30:00.0' AS TIMESTAMP))' (double and timestamp).; line 1 pos 7 +cannot resolve 'pmod('1', CAST('2017-12-11 09:30:00.0' AS TIMESTAMP))' due to data type mismatch: differing types in 'pmod('1', CAST('2017-12-11 09:30:00.0' AS TIMESTAMP))' (string and timestamp).; line 1 pos 7 -- !query 72 @@ -607,7 +603,7 @@ SELECT pmod('1', cast('2017-12-11 09:30:00' as date)) FROM t struct<> -- !query 72 output org.apache.spark.sql.AnalysisException -cannot resolve 'pmod(CAST('1' AS DOUBLE), CAST('2017-12-11 09:30:00' AS DATE))' due to data type mismatch: differing types in 'pmod(CAST('1' AS DOUBLE), CAST('2017-12-11 09:30:00' AS DATE))' (double and date).; line 1 pos 7 +cannot resolve 'pmod('1', CAST('2017-12-11 09:30:00' AS DATE))' due to data type mismatch: differing types in 'pmod('1', CAST('2017-12-11 09:30:00' AS DATE))' (string and date).; line 1 pos 7 -- !query 73 @@ -687,19 +683,17 @@ cannot resolve '(CAST(1 AS BOOLEAN) + CAST('1' AS DOUBLE))' due to data type mis -- !query 82 SELECT cast('2017-12-11 09:30:00.0' as timestamp) + '1' FROM t -- !query 82 schema -struct<> +struct -- !query 82 output -org.apache.spark.sql.AnalysisException -cannot resolve '(CAST('2017-12-11 09:30:00.0' AS TIMESTAMP) + CAST('1' AS DOUBLE))' due to data type mismatch: differing types in '(CAST('2017-12-11 09:30:00.0' AS TIMESTAMP) + CAST('1' AS DOUBLE))' (timestamp and double).; line 1 pos 7 +NULL -- !query 83 SELECT cast('2017-12-11 09:30:00' as date) + '1' FROM t -- !query 83 schema -struct<> +struct -- !query 83 output -org.apache.spark.sql.AnalysisException -cannot resolve '(CAST('2017-12-11 09:30:00' AS DATE) + CAST('1' AS DOUBLE))' due to data type mismatch: differing types in '(CAST('2017-12-11 09:30:00' AS DATE) + CAST('1' AS DOUBLE))' (date and double).; line 1 pos 7 +NULL -- !query 84 @@ -779,19 +773,17 @@ cannot resolve '(CAST(1 AS BOOLEAN) - CAST('1' AS DOUBLE))' due to data type mis -- !query 93 SELECT cast('2017-12-11 09:30:00.0' as timestamp) - '1' FROM t -- !query 93 schema -struct<> +struct -- !query 93 output -org.apache.spark.sql.AnalysisException -cannot resolve '(CAST('2017-12-11 09:30:00.0' AS TIMESTAMP) - CAST('1' AS DOUBLE))' due to data type mismatch: differing types in '(CAST('2017-12-11 09:30:00.0' AS TIMESTAMP) - CAST('1' AS DOUBLE))' (timestamp and double).; line 1 pos 7 +NULL -- !query 94 SELECT cast('2017-12-11 09:30:00' as date) - '1' FROM t -- !query 94 schema -struct<> +struct -- !query 94 output -org.apache.spark.sql.AnalysisException -cannot resolve '(CAST('2017-12-11 09:30:00' AS DATE) - CAST('1' AS DOUBLE))' due to data type mismatch: differing types in '(CAST('2017-12-11 09:30:00' AS DATE) - CAST('1' AS DOUBLE))' (date and double).; line 1 pos 7 +NULL -- !query 95 @@ -874,7 +866,7 @@ SELECT cast('2017-12-11 09:30:00.0' as timestamp) * '1' FROM t struct<> -- !query 104 output org.apache.spark.sql.AnalysisException -cannot resolve '(CAST('2017-12-11 09:30:00.0' AS TIMESTAMP) * CAST('1' AS DOUBLE))' due to data type mismatch: differing types in '(CAST('2017-12-11 09:30:00.0' AS TIMESTAMP) * CAST('1' AS DOUBLE))' (timestamp and double).; line 1 pos 7 +cannot resolve '(CAST('2017-12-11 09:30:00.0' AS TIMESTAMP) * '1')' due to data type mismatch: differing types in '(CAST('2017-12-11 09:30:00.0' AS TIMESTAMP) * '1')' (timestamp and string).; line 1 pos 7 -- !query 105 @@ -883,7 +875,7 @@ SELECT cast('2017-12-11 09:30:00' as date) * '1' FROM t struct<> -- !query 105 output org.apache.spark.sql.AnalysisException -cannot resolve '(CAST('2017-12-11 09:30:00' AS DATE) * CAST('1' AS DOUBLE))' due to data type mismatch: differing types in '(CAST('2017-12-11 09:30:00' AS DATE) * CAST('1' AS DOUBLE))' (date and double).; line 1 pos 7 +cannot resolve '(CAST('2017-12-11 09:30:00' AS DATE) * '1')' due to data type mismatch: differing types in '(CAST('2017-12-11 09:30:00' AS DATE) * '1')' (date and string).; line 1 pos 7 -- !query 106 @@ -966,7 +958,7 @@ SELECT cast('2017-12-11 09:30:00.0' as timestamp) / '1' FROM t struct<> -- !query 115 output org.apache.spark.sql.AnalysisException -cannot resolve '(CAST('2017-12-11 09:30:00.0' AS TIMESTAMP) / CAST('1' AS DOUBLE))' due to data type mismatch: differing types in '(CAST('2017-12-11 09:30:00.0' AS TIMESTAMP) / CAST('1' AS DOUBLE))' (timestamp and double).; line 1 pos 7 +cannot resolve '(CAST('2017-12-11 09:30:00.0' AS TIMESTAMP) / '1')' due to data type mismatch: differing types in '(CAST('2017-12-11 09:30:00.0' AS TIMESTAMP) / '1')' (timestamp and string).; line 1 pos 7 -- !query 116 @@ -975,7 +967,7 @@ SELECT cast('2017-12-11 09:30:00' as date) / '1' FROM t struct<> -- !query 116 output org.apache.spark.sql.AnalysisException -cannot resolve '(CAST('2017-12-11 09:30:00' AS DATE) / CAST('1' AS DOUBLE))' due to data type mismatch: differing types in '(CAST('2017-12-11 09:30:00' AS DATE) / CAST('1' AS DOUBLE))' (date and double).; line 1 pos 7 +cannot resolve '(CAST('2017-12-11 09:30:00' AS DATE) / '1')' due to data type mismatch: differing types in '(CAST('2017-12-11 09:30:00' AS DATE) / '1')' (date and string).; line 1 pos 7 -- !query 117 @@ -1058,7 +1050,7 @@ SELECT cast('2017-12-11 09:30:00.0' as timestamp) % '1' FROM t struct<> -- !query 126 output org.apache.spark.sql.AnalysisException -cannot resolve '(CAST('2017-12-11 09:30:00.0' AS TIMESTAMP) % CAST('1' AS DOUBLE))' due to data type mismatch: differing types in '(CAST('2017-12-11 09:30:00.0' AS TIMESTAMP) % CAST('1' AS DOUBLE))' (timestamp and double).; line 1 pos 7 +cannot resolve '(CAST('2017-12-11 09:30:00.0' AS TIMESTAMP) % '1')' due to data type mismatch: differing types in '(CAST('2017-12-11 09:30:00.0' AS TIMESTAMP) % '1')' (timestamp and string).; line 1 pos 7 -- !query 127 @@ -1067,7 +1059,7 @@ SELECT cast('2017-12-11 09:30:00' as date) % '1' FROM t struct<> -- !query 127 output org.apache.spark.sql.AnalysisException -cannot resolve '(CAST('2017-12-11 09:30:00' AS DATE) % CAST('1' AS DOUBLE))' due to data type mismatch: differing types in '(CAST('2017-12-11 09:30:00' AS DATE) % CAST('1' AS DOUBLE))' (date and double).; line 1 pos 7 +cannot resolve '(CAST('2017-12-11 09:30:00' AS DATE) % '1')' due to data type mismatch: differing types in '(CAST('2017-12-11 09:30:00' AS DATE) % '1')' (date and string).; line 1 pos 7 -- !query 128 @@ -1150,7 +1142,7 @@ SELECT pmod(cast('2017-12-11 09:30:00.0' as timestamp), '1') FROM t struct<> -- !query 137 output org.apache.spark.sql.AnalysisException -cannot resolve 'pmod(CAST('2017-12-11 09:30:00.0' AS TIMESTAMP), CAST('1' AS DOUBLE))' due to data type mismatch: differing types in 'pmod(CAST('2017-12-11 09:30:00.0' AS TIMESTAMP), CAST('1' AS DOUBLE))' (timestamp and double).; line 1 pos 7 +cannot resolve 'pmod(CAST('2017-12-11 09:30:00.0' AS TIMESTAMP), '1')' due to data type mismatch: differing types in 'pmod(CAST('2017-12-11 09:30:00.0' AS TIMESTAMP), '1')' (timestamp and string).; line 1 pos 7 -- !query 138 @@ -1159,7 +1151,7 @@ SELECT pmod(cast('2017-12-11 09:30:00' as date), '1') FROM t struct<> -- !query 138 output org.apache.spark.sql.AnalysisException -cannot resolve 'pmod(CAST('2017-12-11 09:30:00' AS DATE), CAST('1' AS DOUBLE))' due to data type mismatch: differing types in 'pmod(CAST('2017-12-11 09:30:00' AS DATE), CAST('1' AS DOUBLE))' (date and double).; line 1 pos 7 +cannot resolve 'pmod(CAST('2017-12-11 09:30:00' AS DATE), '1')' due to data type mismatch: differing types in 'pmod(CAST('2017-12-11 09:30:00' AS DATE), '1')' (date and string).; line 1 pos 7 -- !query 139