mgaido91 closed pull request #23468: [SPARK-26535][SQL] Parse literals as 
DOUBLE instead of DECIMALS
URL: https://github.com/apache/spark/pull/23468
 
 
   

This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:

As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):

diff --git a/R/pkg/tests/fulltests/test_sparkSQL.R 
b/R/pkg/tests/fulltests/test_sparkSQL.R
index a1805f57b1dcf..33b296b611490 100644
--- a/R/pkg/tests/fulltests/test_sparkSQL.R
+++ b/R/pkg/tests/fulltests/test_sparkSQL.R
@@ -3038,7 +3038,7 @@ test_that("Method coltypes() to get and set R's data 
types of a DataFrame", {
   expect_equal(coltypes(x), "map<string,string>")
 
   df <- selectExpr(read.json(jsonPath), "name", "(age * 1.21) as age")
-  expect_equal(dtypes(df), list(c("name", "string"), c("age", 
"decimal(24,2)")))
+  expect_equal(dtypes(df), list(c("name", "string"), c("age", "double")))
 
   df1 <- select(df, cast(df$age, "integer"))
   coltypes(df) <- c("character", "integer")
diff --git 
a/sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/parser/AstBuilder.scala
 
b/sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/parser/AstBuilder.scala
index 8959f78b656d2..fc243bf554e37 100644
--- 
a/sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/parser/AstBuilder.scala
+++ 
b/sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/parser/AstBuilder.scala
@@ -1591,7 +1591,7 @@ class AstBuilder(conf: SQLConf) extends 
SqlBaseBaseVisitor[AnyRef] with Logging
 
   /**
    * Create an integral literal expression. The code selects the most narrow 
integral type
-   * possible, either a BigDecimal, a Long or an Integer is returned.
+   * possible, either a BigDecimal, a Double, a Long or an Integer is returned.
    */
   override def visitIntegerLiteral(ctx: IntegerLiteralContext): Literal = 
withOrigin(ctx) {
     BigDecimal(ctx.getText) match {
@@ -1599,15 +1599,21 @@ class AstBuilder(conf: SQLConf) extends 
SqlBaseBaseVisitor[AnyRef] with Logging
         Literal(v.intValue())
       case v if v.isValidLong =>
         Literal(v.longValue())
+      case v if v.isDecimalDouble && 
!conf.getConf(SQLConf.LEGACY_LITERALS_AS_DECIMAL) =>
+        Literal(v.doubleValue())
       case v => Literal(v.underlying())
     }
   }
 
   /**
-   * Create a decimal literal for a regular decimal number.
+   * Create a Double or Decimal literal for a regular decimal number.
    */
   override def visitDecimalLiteral(ctx: DecimalLiteralContext): Literal = 
withOrigin(ctx) {
-    Literal(BigDecimal(ctx.getText).underlying())
+    BigDecimal(ctx.getText) match {
+      case v if v.isDecimalDouble && 
!conf.getConf(SQLConf.LEGACY_LITERALS_AS_DECIMAL) =>
+        Literal(v.doubleValue())
+      case v => Literal(v.underlying())
+    }
   }
 
   /** Create a numeric literal expression. */
diff --git 
a/sql/catalyst/src/main/scala/org/apache/spark/sql/internal/SQLConf.scala 
b/sql/catalyst/src/main/scala/org/apache/spark/sql/internal/SQLConf.scala
index fe445e0019353..279c7a304bbf3 100644
--- a/sql/catalyst/src/main/scala/org/apache/spark/sql/internal/SQLConf.scala
+++ b/sql/catalyst/src/main/scala/org/apache/spark/sql/internal/SQLConf.scala
@@ -1639,6 +1639,14 @@ object SQLConf {
       "java.time.* packages are used for the same purpose.")
     .booleanConf
     .createWithDefault(false)
+
+  val LEGACY_LITERALS_AS_DECIMAL = 
buildConf("spark.sql.legacy.literals.asDecimal")
+    .internal()
+    .doc("When set to true, literal values which don't fit in the long range 
are considered as " +
+      "decimals. If set to false (default), they are parsed as double if 
possible; if the value" +
+      "is not representable as double, then we fallback to decimal.")
+    .booleanConf
+    .createWithDefault(false)
 }
 
 /**
diff --git 
a/sql/catalyst/src/test/scala/org/apache/spark/sql/catalyst/parser/ExpressionParserSuite.scala
 
b/sql/catalyst/src/test/scala/org/apache/spark/sql/catalyst/parser/ExpressionParserSuite.scala
index 8bcc69d580d83..2f2998d6b37e7 100644
--- 
a/sql/catalyst/src/test/scala/org/apache/spark/sql/catalyst/parser/ExpressionParserSuite.scala
+++ 
b/sql/catalyst/src/test/scala/org/apache/spark/sql/catalyst/parser/ExpressionParserSuite.scala
@@ -437,8 +437,12 @@ class ExpressionParserSuite extends PlanTest {
   }
 
   test("literals") {
-    def testDecimal(value: String): Unit = {
-      assertEqual(value, Literal(BigDecimal(value).underlying))
+    def testDecimal(value: String, asDecimal: Boolean, parser: 
ParserInterface): Unit = {
+      if (asDecimal) {
+        assertEqual(value, Literal(BigDecimal(value).underlying), parser)
+      } else {
+        assertEqual(value, Literal(BigDecimal(value).doubleValue()), parser)
+      }
     }
 
     // NULL
@@ -451,18 +455,26 @@ class ExpressionParserSuite extends PlanTest {
     // Integral should have the narrowest possible type
     assertEqual("787324", Literal(787324))
     assertEqual("7873247234798249234", Literal(7873247234798249234L))
-    testDecimal("78732472347982492793712334")
-
-    // Decimal
-    testDecimal("7873247234798249279371.2334")
-
-    // Scientific Decimal
-    testDecimal("9.0e1")
-    testDecimal(".9e+2")
-    testDecimal("0.9e+2")
-    testDecimal("900e-1")
-    testDecimal("900.0E-1")
-    testDecimal("9.e+1")
+
+    Seq(true, false).foreach { asDecimal =>
+      val conf = new SQLConf()
+      conf.setConf(SQLConf.LEGACY_LITERALS_AS_DECIMAL, asDecimal)
+      val parser = new CatalystSqlParser(conf)
+      testDecimal("78732472347982492793712334", true, parser)
+      testDecimal("1e40", asDecimal, parser)
+
+      // Decimal
+      testDecimal("7873247234798249279371.2334", true, parser)
+
+      // Scientific Decimal
+      testDecimal("9.0e1", asDecimal, parser)
+      testDecimal(".9e+2", asDecimal, parser)
+      testDecimal("0.9e+2", asDecimal, parser)
+      testDecimal("900e-1", asDecimal, parser)
+      testDecimal("900.0E-1", asDecimal, parser)
+      testDecimal("9.e+1", asDecimal, parser)
+    }
+
     intercept(".e3")
 
     // Tiny Int Literal
diff --git 
a/sql/core/src/test/resources/sql-tests/inputs/typeCoercion/native/decimalArithmeticOperations.sql
 
b/sql/core/src/test/resources/sql-tests/inputs/typeCoercion/native/decimalArithmeticOperations.sql
index 28a0e20c0f495..f7a84749c0acc 100644
--- 
a/sql/core/src/test/resources/sql-tests/inputs/typeCoercion/native/decimalArithmeticOperations.sql
+++ 
b/sql/core/src/test/resources/sql-tests/inputs/typeCoercion/native/decimalArithmeticOperations.sql
@@ -15,6 +15,8 @@
 --   limitations under the License.
 --
 
+set spark.sql.legacy.literals.asDecimal=true;
+
 CREATE TEMPORARY VIEW t AS SELECT 1.0 as a, 0.0 as b;
 
 -- division, remainder and pmod by 0 return NULL
diff --git a/sql/core/src/test/resources/sql-tests/results/literals.sql.out 
b/sql/core/src/test/resources/sql-tests/results/literals.sql.out
index 7f301614523b2..5b463255b1e64 100644
--- a/sql/core/src/test/resources/sql-tests/results/literals.sql.out
+++ b/sql/core/src/test/resources/sql-tests/results/literals.sql.out
@@ -167,17 +167,17 @@ select 1234567890123456789012345678901234567890.0
 -- !query 17
 select 1D, 1.2D, 1e10, 1.5e5, .10D, 0.10D, .1e5, .9e+2, 0.9e+2, 900e-1, 9.e+1
 -- !query 17 schema
-struct<1.0:double,1.2:double,1E+10:decimal(1,-10),1.5E+5:decimal(2,-4),0.1:double,0.1:double,1E+4:decimal(1,-4),9E+1:decimal(1,-1),9E+1:decimal(1,-1),90.0:decimal(3,1),9E+1:decimal(1,-1)>
+struct<1.0:double,1.2:double,1.0E10:double,150000.0:double,0.1:double,0.1:double,10000.0:double,90.0:double,90.0:double,90.0:double,90.0:double>
 -- !query 17 output
-1.0    1.2     10000000000     150000  0.1     0.1     10000   90      90      
90      90
+1.0    1.2     1.0E10  150000.0        0.1     0.1     10000.0 90.0    90.0    
90.0    90.0
 
 
 -- !query 18
 select -1D, -1.2D, -1e10, -1.5e5, -.10D, -0.10D, -.1e5
 -- !query 18 schema
-struct<-1.0:double,-1.2:double,-1E+10:decimal(1,-10),-1.5E+5:decimal(2,-4),-0.1:double,-0.1:double,-1E+4:decimal(1,-4)>
+struct<-1.0:double,-1.2:double,-1.0E10:double,-150000.0:double,-0.1:double,-0.1:double,-10000.0:double>
 -- !query 18 output
--1.0   -1.2    -10000000000    -150000 -0.1    -0.1    -10000
+-1.0   -1.2    -1.0E10 -150000.0       -0.1    -0.1    -10000.0
 
 
 -- !query 19
@@ -205,7 +205,7 @@ struct<1E+309:decimal(1,-309),-1E+309:decimal(1,-309)>
 -- !query 21
 select 0.3, -0.8, .5, -.18, 0.1111, .1111
 -- !query 21 schema
-struct<0.3:decimal(1,1),-0.8:decimal(1,1),0.5:decimal(1,1),-0.18:decimal(2,2),0.1111:decimal(4,4),0.1111:decimal(4,4)>
+struct<0.3:double,-0.8:double,0.5:double,-0.18:double,0.1111:double,0.1111:double>
 -- !query 21 output
 0.3    -0.8    0.5     -0.18   0.1111  0.1111
 
@@ -411,9 +411,9 @@ select X'XuZ'
 -- !query 42
 SELECT 3.14, -3.14, 3.14e8, 3.14e-8, -3.14e8, -3.14e-8, 3.14e+8, 3.14E8, 
3.14E-8
 -- !query 42 schema
-struct<3.14:decimal(3,2),-3.14:decimal(3,2),3.14E+8:decimal(3,-6),3.14E-8:decimal(10,10),-3.14E+8:decimal(3,-6),-3.14E-8:decimal(10,10),3.14E+8:decimal(3,-6),3.14E+8:decimal(3,-6),3.14E-8:decimal(10,10)>
+struct<3.14:double,-3.14:double,3.14E8:double,3.14E-8:double,-3.14E8:double,-3.14E-8:double,3.14E8:double,3.14E8:double,3.14E-8:double>
 -- !query 42 output
-3.14   -3.14   314000000       0.0000000314    -314000000      -0.0000000314   
314000000       314000000       0.0000000314
+3.14   -3.14   3.14E8  3.14E-8 -3.14E8 -3.14E-8        3.14E8  3.14E8  3.14E-8
 
 
 -- !query 43
diff --git a/sql/core/src/test/resources/sql-tests/results/operators.sql.out 
b/sql/core/src/test/resources/sql-tests/results/operators.sql.out
index e0cbd575bc346..d20a6c6a7e1f5 100644
--- a/sql/core/src/test/resources/sql-tests/results/operators.sql.out
+++ b/sql/core/src/test/resources/sql-tests/results/operators.sql.out
@@ -21,7 +21,7 @@ struct<230:int>
 -- !query 2
 select -5.2
 -- !query 2 schema
-struct<-5.2:decimal(2,1)>
+struct<-5.2:double>
 -- !query 2 output
 -5.2
 
@@ -29,7 +29,7 @@ struct<-5.2:decimal(2,1)>
 -- !query 3
 select +6.8e0
 -- !query 3 schema
-struct<6.8:decimal(2,1)>
+struct<6.8:double>
 -- !query 3 output
 6.8
 
@@ -261,7 +261,7 @@ struct<CEIL(1234567890123456):bigint>
 -- !query 32
 select ceil(0.01)
 -- !query 32 schema
-struct<CEIL(0.01):decimal(1,0)>
+struct<CEIL(0.01):bigint>
 -- !query 32 output
 1
 
@@ -269,7 +269,7 @@ struct<CEIL(0.01):decimal(1,0)>
 -- !query 33
 select ceiling(-0.10)
 -- !query 33 schema
-struct<CEIL(-0.10):decimal(1,0)>
+struct<CEIL(-0.1):bigint>
 -- !query 33 output
 0
 
@@ -301,7 +301,7 @@ struct<FLOOR(1234567890123456):bigint>
 -- !query 37
 select floor(0.01)
 -- !query 37 schema
-struct<FLOOR(0.01):decimal(1,0)>
+struct<FLOOR(0.01):bigint>
 -- !query 37 output
 0
 
@@ -309,7 +309,7 @@ struct<FLOOR(0.01):decimal(1,0)>
 -- !query 38
 select floor(-0.10)
 -- !query 38 schema
-struct<FLOOR(-0.10):decimal(1,0)>
+struct<FLOOR(-0.1):bigint>
 -- !query 38 output
 -1
 
@@ -317,7 +317,7 @@ struct<FLOOR(-0.10):decimal(1,0)>
 -- !query 39
 select 1 > 0.00001
 -- !query 39 schema
-struct<(CAST(1 AS BIGINT) > 0):boolean>
+struct<(CAST(1 AS DOUBLE) > 1.0E-5):boolean>
 -- !query 39 output
 true
 
@@ -365,7 +365,7 @@ struct<octet_length(abc):int>
 -- !query 45
 select abs(-3.13), abs('-2.19')
 -- !query 45 schema
-struct<abs(-3.13):decimal(3,2),abs(CAST(-2.19 AS DOUBLE)):double>
+struct<abs(-3.13):double,abs(CAST(-2.19 AS DOUBLE)):double>
 -- !query 45 output
 3.13   2.19
 
@@ -373,7 +373,7 @@ struct<abs(-3.13):decimal(3,2),abs(CAST(-2.19 AS 
DOUBLE)):double>
 -- !query 46
 select positive('-1.11'), positive(-1.11), negative('-1.11'), negative(-1.11)
 -- !query 46 schema
-struct<(+ CAST(-1.11 AS DOUBLE)):double,(+ -1.11):decimal(3,2),(- CAST(-1.11 
AS DOUBLE)):double,(- -1.11):decimal(3,2)>
+struct<(+ CAST(-1.11 AS DOUBLE)):double,(+ -1.11):double,(- CAST(-1.11 AS 
DOUBLE)):double,(- -1.11):double>
 -- !query 46 output
 -1.11  -1.11   1.11    1.11
 
diff --git 
a/sql/core/src/test/resources/sql-tests/results/predicate-functions.sql.out 
b/sql/core/src/test/resources/sql-tests/results/predicate-functions.sql.out
index cf828c69af62a..38a34258eba83 100644
--- a/sql/core/src/test/resources/sql-tests/results/predicate-functions.sql.out
+++ b/sql/core/src/test/resources/sql-tests/results/predicate-functions.sql.out
@@ -21,7 +21,7 @@ true
 -- !query 2
 select 1.0 = '1'
 -- !query 2 schema
-struct<(CAST(1.0 AS DOUBLE) = CAST(1 AS DOUBLE)):boolean>
+struct<(1.0 = CAST(1 AS DOUBLE)):boolean>
 -- !query 2 output
 true
 
@@ -29,7 +29,7 @@ true
 -- !query 3
 select 1.5 = '1.51'
 -- !query 3 schema
-struct<(CAST(1.5 AS DOUBLE) = CAST(1.51 AS DOUBLE)):boolean>
+struct<(1.5 = CAST(1.51 AS DOUBLE)):boolean>
 -- !query 3 output
 false
 
@@ -69,7 +69,7 @@ false
 -- !query 8
 select '1.5' > 0.5
 -- !query 8 schema
-struct<(CAST(1.5 AS DOUBLE) > CAST(0.5 AS DOUBLE)):boolean>
+struct<(CAST(1.5 AS DOUBLE) > 0.5):boolean>
 -- !query 8 output
 true
 
@@ -117,7 +117,7 @@ true
 -- !query 14
 select 2.0 >= '2.2'
 -- !query 14 schema
-struct<(CAST(2.0 AS DOUBLE) >= CAST(2.2 AS DOUBLE)):boolean>
+struct<(2.0 >= CAST(2.2 AS DOUBLE)):boolean>
 -- !query 14 output
 false
 
@@ -125,7 +125,7 @@ false
 -- !query 15
 select '1.5' >= 0.5
 -- !query 15 schema
-struct<(CAST(1.5 AS DOUBLE) >= CAST(0.5 AS DOUBLE)):boolean>
+struct<(CAST(1.5 AS DOUBLE) >= 0.5):boolean>
 -- !query 15 output
 true
 
@@ -173,7 +173,7 @@ false
 -- !query 21
 select 2.0 < '2.2'
 -- !query 21 schema
-struct<(CAST(2.0 AS DOUBLE) < CAST(2.2 AS DOUBLE)):boolean>
+struct<(2.0 < CAST(2.2 AS DOUBLE)):boolean>
 -- !query 21 output
 true
 
@@ -181,7 +181,7 @@ true
 -- !query 22
 select 0.5 < '1.5'
 -- !query 22 schema
-struct<(CAST(0.5 AS DOUBLE) < CAST(1.5 AS DOUBLE)):boolean>
+struct<(0.5 < CAST(1.5 AS DOUBLE)):boolean>
 -- !query 22 output
 true
 
@@ -229,7 +229,7 @@ true
 -- !query 28
 select 2.0 <= '2.2'
 -- !query 28 schema
-struct<(CAST(2.0 AS DOUBLE) <= CAST(2.2 AS DOUBLE)):boolean>
+struct<(2.0 <= CAST(2.2 AS DOUBLE)):boolean>
 -- !query 28 output
 true
 
@@ -237,7 +237,7 @@ true
 -- !query 29
 select 0.5 <= '1.5'
 -- !query 29 schema
-struct<(CAST(0.5 AS DOUBLE) <= CAST(1.5 AS DOUBLE)):boolean>
+struct<(0.5 <= CAST(1.5 AS DOUBLE)):boolean>
 -- !query 29 output
 true
 
diff --git a/sql/core/src/test/resources/sql-tests/results/random.sql.out 
b/sql/core/src/test/resources/sql-tests/results/random.sql.out
index bca67320fe7bb..877548002856a 100644
--- a/sql/core/src/test/resources/sql-tests/results/random.sql.out
+++ b/sql/core/src/test/resources/sql-tests/results/random.sql.out
@@ -40,7 +40,7 @@ SELECT rand(1.0)
 struct<>
 -- !query 4 output
 org.apache.spark.sql.AnalysisException
-cannot resolve 'rand(1.0BD)' due to data type mismatch: argument 1 requires 
(int or bigint) type, however, '1.0BD' is of decimal(2,1) type.; line 1 pos 7
+cannot resolve 'rand(1.0D)' due to data type mismatch: argument 1 requires 
(int or bigint) type, however, '1.0D' is of double type.; line 1 pos 7
 
 
 -- !query 5
diff --git 
a/sql/core/src/test/resources/sql-tests/results/subquery/in-subquery/in-group-by.sql.out
 
b/sql/core/src/test/resources/sql-tests/results/subquery/in-subquery/in-group-by.sql.out
index a159aa81eff1c..9dc39df10b0ec 100644
--- 
a/sql/core/src/test/resources/sql-tests/results/subquery/in-subquery/in-group-by.sql.out
+++ 
b/sql/core/src/test/resources/sql-tests/results/subquery/in-subquery/in-group-by.sql.out
@@ -172,16 +172,16 @@ WHERE  t1b IN (SELECT Max(t2b)
                FROM   t2
                GROUP  BY t2a)
 -- !query 9 schema
-struct<t1a:string,t1b:smallint,t1c:int,t1d:bigint,t1e:float,t1f:double,t1g:decimal(2,-2),t1h:timestamp,t1i:date>
+struct<t1a:string,t1b:smallint,t1c:int,t1d:bigint,t1e:float,t1f:double,t1g:double,t1h:timestamp,t1i:date>
 -- !query 9 output
-t1a    6       8       10      15.0    20.0    2000    2014-04-04 01:00:00     
2014-04-04
-t1a    6       8       10      15.0    20.0    2000    2014-04-04 01:02:00.001 
2014-04-04
-t1b    8       16      19      17.0    25.0    2600    2014-05-04 01:01:00     
2014-05-04
-t1c    8       16      19      17.0    25.0    2600    2014-05-04 01:02:00.001 
2014-05-05
-t1d    10      NULL    12      17.0    25.0    2600    2015-05-04 01:01:00     
2015-05-04
-t1e    10      NULL    19      17.0    25.0    2600    2014-05-04 01:01:00     
2014-05-04
-t1e    10      NULL    19      17.0    25.0    2600    2014-09-04 01:02:00.001 
2014-09-04
-t1e    10      NULL    25      17.0    25.0    2600    2014-08-04 01:01:00     
2014-08-04
+t1a    6       8       10      15.0    20.0    2000.0  2014-04-04 01:00:00     
2014-04-04
+t1a    6       8       10      15.0    20.0    2000.0  2014-04-04 01:02:00.001 
2014-04-04
+t1b    8       16      19      17.0    25.0    2600.0  2014-05-04 01:01:00     
2014-05-04
+t1c    8       16      19      17.0    25.0    2600.0  2014-05-04 01:02:00.001 
2014-05-05
+t1d    10      NULL    12      17.0    25.0    2600.0  2015-05-04 01:01:00     
2015-05-04
+t1e    10      NULL    19      17.0    25.0    2600.0  2014-05-04 01:01:00     
2014-05-04
+t1e    10      NULL    19      17.0    25.0    2600.0  2014-09-04 01:02:00.001 
2014-09-04
+t1e    10      NULL    25      17.0    25.0    2600.0  2014-08-04 01:01:00     
2014-08-04
 
 
 -- !query 10
diff --git 
a/sql/core/src/test/resources/sql-tests/results/subquery/in-subquery/in-limit.sql.out
 
b/sql/core/src/test/resources/sql-tests/results/subquery/in-subquery/in-limit.sql.out
index 71ca1f8649475..134877bb49f16 100644
--- 
a/sql/core/src/test/resources/sql-tests/results/subquery/in-subquery/in-limit.sql.out
+++ 
b/sql/core/src/test/resources/sql-tests/results/subquery/in-subquery/in-limit.sql.out
@@ -74,10 +74,10 @@ WHERE  t1a IN (SELECT t2a
                WHERE  t1d = t2d)
 LIMIT  2
 -- !query 3 schema
-struct<t1a:string,t1b:smallint,t1c:int,t1d:bigint,t1e:float,t1f:double,t1g:decimal(2,-2),t1h:timestamp,t1i:date>
+struct<t1a:string,t1b:smallint,t1c:int,t1d:bigint,t1e:float,t1f:double,t1g:double,t1h:timestamp,t1i:date>
 -- !query 3 output
-val1b  8       16      19      17.0    25.0    2600    2014-05-04 01:01:00     
2014-05-04
-val1c  8       16      19      17.0    25.0    2600    2014-05-04 01:02:00.001 
2014-05-05
+val1b  8       16      19      17.0    25.0    2600.0  2014-05-04 01:01:00     
2014-05-04
+val1c  8       16      19      17.0    25.0    2600.0  2014-05-04 01:02:00.001 
2014-05-05
 
 
 -- !query 4
@@ -89,12 +89,12 @@ WHERE  t1c IN (SELECT t2c
                LIMIT  2)
 LIMIT 4
 -- !query 4 schema
-struct<t1a:string,t1b:smallint,t1c:int,t1d:bigint,t1e:float,t1f:double,t1g:decimal(2,-2),t1h:timestamp,t1i:date>
+struct<t1a:string,t1b:smallint,t1c:int,t1d:bigint,t1e:float,t1f:double,t1g:double,t1h:timestamp,t1i:date>
 -- !query 4 output
-val1a  16      12      10      15.0    20.0    2000    2014-07-04 01:01:00     
2014-07-04
-val1a  16      12      21      15.0    20.0    2000    2014-06-04 01:02:00.001 
2014-06-04
-val1b  8       16      19      17.0    25.0    2600    2014-05-04 01:01:00     
2014-05-04
-val1c  8       16      19      17.0    25.0    2600    2014-05-04 01:02:00.001 
2014-05-05
+val1a  16      12      10      15.0    20.0    2000.0  2014-07-04 01:01:00     
2014-07-04
+val1a  16      12      21      15.0    20.0    2000.0  2014-06-04 01:02:00.001 
2014-06-04
+val1b  8       16      19      17.0    25.0    2600.0  2014-05-04 01:01:00     
2014-05-04
+val1c  8       16      19      17.0    25.0    2600.0  2014-05-04 01:02:00.001 
2014-05-05
 
 
 -- !query 5
@@ -122,12 +122,12 @@ WHERE  t1b NOT IN (SELECT t2b
                    WHERE  t2b > 6
                    LIMIT  2)
 -- !query 6 schema
-struct<t1a:string,t1b:smallint,t1c:int,t1d:bigint,t1e:float,t1f:double,t1g:decimal(2,-2),t1h:timestamp,t1i:date>
+struct<t1a:string,t1b:smallint,t1c:int,t1d:bigint,t1e:float,t1f:double,t1g:double,t1h:timestamp,t1i:date>
 -- !query 6 output
-val1a  16      12      10      15.0    20.0    2000    2014-07-04 01:01:00     
2014-07-04
-val1a  16      12      21      15.0    20.0    2000    2014-06-04 01:02:00.001 
2014-06-04
-val1a  6       8       10      15.0    20.0    2000    2014-04-04 01:00:00     
2014-04-04
-val1a  6       8       10      15.0    20.0    2000    2014-04-04 01:02:00.001 
2014-04-04
+val1a  16      12      10      15.0    20.0    2000.0  2014-07-04 01:01:00     
2014-07-04
+val1a  16      12      21      15.0    20.0    2000.0  2014-06-04 01:02:00.001 
2014-06-04
+val1a  6       8       10      15.0    20.0    2000.0  2014-04-04 01:00:00     
2014-04-04
+val1a  6       8       10      15.0    20.0    2000.0  2014-04-04 01:02:00.001 
2014-04-04
 
 
 -- !query 7
diff --git 
a/sql/core/src/test/resources/sql-tests/results/subquery/in-subquery/in-order-by.sql.out
 
b/sql/core/src/test/resources/sql-tests/results/subquery/in-subquery/in-order-by.sql.out
index 4bebd9622c3c5..4602c34896d56 100644
--- 
a/sql/core/src/test/resources/sql-tests/results/subquery/in-subquery/in-order-by.sql.out
+++ 
b/sql/core/src/test/resources/sql-tests/results/subquery/in-subquery/in-order-by.sql.out
@@ -73,13 +73,13 @@ WHERE  t1a IN (SELECT t2a
                FROM   t2)
 ORDER  BY t1a
 -- !query 3 schema
-struct<t1a:string,t1b:smallint,t1c:int,t1d:bigint,t1e:float,t1f:double,t1g:decimal(2,-2),t1h:timestamp,t1i:date>
+struct<t1a:string,t1b:smallint,t1c:int,t1d:bigint,t1e:float,t1f:double,t1g:double,t1h:timestamp,t1i:date>
 -- !query 3 output
-val1b  8       16      19      17.0    25.0    2600    2014-05-04 01:01:00     
2014-05-04
-val1c  8       16      19      17.0    25.0    2600    2014-05-04 01:02:00.001 
2014-05-05
-val1e  10      NULL    25      17.0    25.0    2600    2014-08-04 01:01:00     
2014-08-04
-val1e  10      NULL    19      17.0    25.0    2600    2014-09-04 01:02:00.001 
2014-09-04
-val1e  10      NULL    19      17.0    25.0    2600    2014-05-04 01:01:00     
2014-05-04
+val1b  8       16      19      17.0    25.0    2600.0  2014-05-04 01:01:00     
2014-05-04
+val1c  8       16      19      17.0    25.0    2600.0  2014-05-04 01:02:00.001 
2014-05-05
+val1e  10      NULL    25      17.0    25.0    2600.0  2014-08-04 01:01:00     
2014-08-04
+val1e  10      NULL    19      17.0    25.0    2600.0  2014-09-04 01:02:00.001 
2014-09-04
+val1e  10      NULL    19      17.0    25.0    2600.0  2014-05-04 01:01:00     
2014-05-04
 
 
 -- !query 4
@@ -130,10 +130,10 @@ WHERE  t1b IN (SELECT t2c
                FROM   t2
                ORDER  BY t2d)
 -- !query 7 schema
-struct<t1a:string,t1b:smallint,t1c:int,t1d:bigint,t1e:float,t1f:double,t1g:decimal(2,-2),t1h:timestamp,t1i:date>
+struct<t1a:string,t1b:smallint,t1c:int,t1d:bigint,t1e:float,t1f:double,t1g:double,t1h:timestamp,t1i:date>
 -- !query 7 output
-val1a  16      12      10      15.0    20.0    2000    2014-07-04 01:01:00     
2014-07-04
-val1a  16      12      21      15.0    20.0    2000    2014-06-04 01:02:00.001 
2014-06-04
+val1a  16      12      10      15.0    20.0    2000.0  2014-07-04 01:01:00     
2014-07-04
+val1a  16      12      21      15.0    20.0    2000.0  2014-06-04 01:02:00.001 
2014-06-04
 
 
 -- !query 8
@@ -145,16 +145,16 @@ WHERE  t1b IN (SELECT Min(t2b)
                ORDER  BY Min(t2b))
 ORDER BY t1c DESC nulls first
 -- !query 8 schema
-struct<t1a:string,t1b:smallint,t1c:int,t1d:bigint,t1e:float,t1f:double,t1g:decimal(2,-2),t1h:timestamp,t1i:date>
+struct<t1a:string,t1b:smallint,t1c:int,t1d:bigint,t1e:float,t1f:double,t1g:double,t1h:timestamp,t1i:date>
 -- !query 8 output
-val1e  10      NULL    25      17.0    25.0    2600    2014-08-04 01:01:00     
2014-08-04
-val1e  10      NULL    19      17.0    25.0    2600    2014-09-04 01:02:00.001 
2014-09-04
-val1d  10      NULL    12      17.0    25.0    2600    2015-05-04 01:01:00     
2015-05-04
-val1e  10      NULL    19      17.0    25.0    2600    2014-05-04 01:01:00     
2014-05-04
-val1b  8       16      19      17.0    25.0    2600    2014-05-04 01:01:00     
2014-05-04
-val1c  8       16      19      17.0    25.0    2600    2014-05-04 01:02:00.001 
2014-05-05
-val1a  6       8       10      15.0    20.0    2000    2014-04-04 01:00:00     
2014-04-04
-val1a  6       8       10      15.0    20.0    2000    2014-04-04 01:02:00.001 
2014-04-04
+val1e  10      NULL    25      17.0    25.0    2600.0  2014-08-04 01:01:00     
2014-08-04
+val1e  10      NULL    19      17.0    25.0    2600.0  2014-09-04 01:02:00.001 
2014-09-04
+val1d  10      NULL    12      17.0    25.0    2600.0  2015-05-04 01:01:00     
2015-05-04
+val1e  10      NULL    19      17.0    25.0    2600.0  2014-05-04 01:01:00     
2014-05-04
+val1b  8       16      19      17.0    25.0    2600.0  2014-05-04 01:01:00     
2014-05-04
+val1c  8       16      19      17.0    25.0    2600.0  2014-05-04 01:02:00.001 
2014-05-05
+val1a  6       8       10      15.0    20.0    2000.0  2014-04-04 01:00:00     
2014-04-04
+val1a  6       8       10      15.0    20.0    2000.0  2014-04-04 01:02:00.001 
2014-04-04
 
 
 -- !query 9
@@ -184,15 +184,15 @@ WHERE  t1a NOT IN (SELECT t2a
                    FROM   t2)
 ORDER  BY t1a
 -- !query 10 schema
-struct<t1a:string,t1b:smallint,t1c:int,t1d:bigint,t1e:float,t1f:double,t1g:decimal(2,-2),t1h:timestamp,t1i:date>
+struct<t1a:string,t1b:smallint,t1c:int,t1d:bigint,t1e:float,t1f:double,t1g:double,t1h:timestamp,t1i:date>
 -- !query 10 output
-val1a  6       8       10      15.0    20.0    2000    2014-04-04 01:00:00     
2014-04-04
-val1a  16      12      21      15.0    20.0    2000    2014-06-04 01:02:00.001 
2014-06-04
-val1a  16      12      10      15.0    20.0    2000    2014-07-04 01:01:00     
2014-07-04
-val1a  6       8       10      15.0    20.0    2000    2014-04-04 01:02:00.001 
2014-04-04
-val1d  NULL    16      22      17.0    25.0    2600    2014-06-04 01:01:00     
NULL
-val1d  NULL    16      19      17.0    25.0    2600    2014-07-04 01:02:00.001 
NULL
-val1d  10      NULL    12      17.0    25.0    2600    2015-05-04 01:01:00     
2015-05-04
+val1a  6       8       10      15.0    20.0    2000.0  2014-04-04 01:00:00     
2014-04-04
+val1a  16      12      21      15.0    20.0    2000.0  2014-06-04 01:02:00.001 
2014-06-04
+val1a  16      12      10      15.0    20.0    2000.0  2014-07-04 01:01:00     
2014-07-04
+val1a  6       8       10      15.0    20.0    2000.0  2014-04-04 01:02:00.001 
2014-04-04
+val1d  NULL    16      22      17.0    25.0    2600.0  2014-06-04 01:01:00     
NULL
+val1d  NULL    16      19      17.0    25.0    2600.0  2014-07-04 01:02:00.001 
NULL
+val1d  10      NULL    12      17.0    25.0    2600.0  2015-05-04 01:01:00     
2015-05-04
 
 
 -- !query 11
@@ -226,12 +226,12 @@ WHERE  t1a NOT IN (SELECT t2a
                    ORDER  BY t2b DESC nulls last)
 ORDER  BY t1c DESC nulls last
 -- !query 12 schema
-struct<t1a:string,t1b:smallint,t1c:int,t1d:bigint,t1e:float,t1f:double,t1g:decimal(2,-2),t1h:timestamp,t1i:date>
+struct<t1a:string,t1b:smallint,t1c:int,t1d:bigint,t1e:float,t1f:double,t1g:double,t1h:timestamp,t1i:date>
 -- !query 12 output
-val1d  NULL    16      22      17.0    25.0    2600    2014-06-04 01:01:00     
NULL
-val1d  NULL    16      19      17.0    25.0    2600    2014-07-04 01:02:00.001 
NULL
-val1a  16      12      21      15.0    20.0    2000    2014-06-04 01:02:00.001 
2014-06-04
-val1a  16      12      10      15.0    20.0    2000    2014-07-04 01:01:00     
2014-07-04
+val1d  NULL    16      22      17.0    25.0    2600.0  2014-06-04 01:01:00     
NULL
+val1d  NULL    16      19      17.0    25.0    2600.0  2014-07-04 01:02:00.001 
NULL
+val1a  16      12      21      15.0    20.0    2000.0  2014-06-04 01:02:00.001 
2014-06-04
+val1a  16      12      10      15.0    20.0    2000.0  2014-07-04 01:01:00     
2014-07-04
 
 
 -- !query 13
@@ -242,12 +242,12 @@ WHERE  t1b IN (SELECT Min(t2b)
                GROUP  BY t2a
                ORDER  BY t2a DESC)
 -- !query 13 schema
-struct<t1a:string,t1b:smallint,t1c:int,t1d:bigint,t1e:float,t1f:double,t1g:decimal(2,-2),t1h:timestamp,t1i:date>
+struct<t1a:string,t1b:smallint,t1c:int,t1d:bigint,t1e:float,t1f:double,t1g:double,t1h:timestamp,t1i:date>
 -- !query 13 output
-val1a  6       8       10      15.0    20.0    2000    2014-04-04 01:00:00     
2014-04-04
-val1a  6       8       10      15.0    20.0    2000    2014-04-04 01:02:00.001 
2014-04-04
-val1b  8       16      19      17.0    25.0    2600    2014-05-04 01:01:00     
2014-05-04
-val1c  8       16      19      17.0    25.0    2600    2014-05-04 01:02:00.001 
2014-05-05
+val1a  6       8       10      15.0    20.0    2000.0  2014-04-04 01:00:00     
2014-04-04
+val1a  6       8       10      15.0    20.0    2000.0  2014-04-04 01:02:00.001 
2014-04-04
+val1b  8       16      19      17.0    25.0    2600.0  2014-05-04 01:01:00     
2014-05-04
+val1c  8       16      19      17.0    25.0    2600.0  2014-05-04 01:02:00.001 
2014-05-05
 
 
 -- !query 14
@@ -276,14 +276,14 @@ WHERE  t1b NOT IN (SELECT Min(t2b)
                    GROUP  BY t2a
                    ORDER  BY t2a)
 -- !query 15 schema
-struct<t1a:string,t1b:smallint,t1c:int,t1d:bigint,t1e:float,t1f:double,t1g:decimal(2,-2),t1h:timestamp,t1i:date>
+struct<t1a:string,t1b:smallint,t1c:int,t1d:bigint,t1e:float,t1f:double,t1g:double,t1h:timestamp,t1i:date>
 -- !query 15 output
-val1a  16      12      10      15.0    20.0    2000    2014-07-04 01:01:00     
2014-07-04
-val1a  16      12      21      15.0    20.0    2000    2014-06-04 01:02:00.001 
2014-06-04
-val1d  10      NULL    12      17.0    25.0    2600    2015-05-04 01:01:00     
2015-05-04
-val1e  10      NULL    19      17.0    25.0    2600    2014-05-04 01:01:00     
2014-05-04
-val1e  10      NULL    19      17.0    25.0    2600    2014-09-04 01:02:00.001 
2014-09-04
-val1e  10      NULL    25      17.0    25.0    2600    2014-08-04 01:01:00     
2014-08-04
+val1a  16      12      10      15.0    20.0    2000.0  2014-07-04 01:01:00     
2014-07-04
+val1a  16      12      21      15.0    20.0    2000.0  2014-06-04 01:02:00.001 
2014-06-04
+val1d  10      NULL    12      17.0    25.0    2600.0  2015-05-04 01:01:00     
2015-05-04
+val1e  10      NULL    19      17.0    25.0    2600.0  2014-05-04 01:01:00     
2014-05-04
+val1e  10      NULL    19      17.0    25.0    2600.0  2014-09-04 01:02:00.001 
2014-09-04
+val1e  10      NULL    25      17.0    25.0    2600.0  2014-08-04 01:01:00     
2014-08-04
 
 
 -- !query 16
diff --git 
a/sql/core/src/test/resources/sql-tests/results/subquery/in-subquery/in-set-operations.sql.out
 
b/sql/core/src/test/resources/sql-tests/results/subquery/in-subquery/in-set-operations.sql.out
index e06f9206d3401..fb8d43a275b84 100644
--- 
a/sql/core/src/test/resources/sql-tests/results/subquery/in-subquery/in-set-operations.sql.out
+++ 
b/sql/core/src/test/resources/sql-tests/results/subquery/in-subquery/in-set-operations.sql.out
@@ -498,9 +498,9 @@ FROM   (SELECT *
                           FROM   t3
                           WHERE  t4.t2a = t3a))
 -- !query 13 schema
-struct<t2a:string,t2b:smallint,t2c:int,t2d:bigint,t2e:float,t2f:double,t2g:decimal(2,-2),t2h:timestamp,t2i:date>
+struct<t2a:string,t2b:smallint,t2c:int,t2d:bigint,t2e:float,t2f:double,t2g:double,t2h:timestamp,t2i:date>
 -- !query 13 output
-val1b  8       16      19      17.0    25.0    2600    2014-05-04 01:01:00     
2014-05-04
+val1b  8       16      19      17.0    25.0    2600.0  2014-05-04 01:01:00     
2014-05-04
 
 
 -- !query 14
diff --git 
a/sql/core/src/test/resources/sql-tests/results/subquery/in-subquery/not-in-unit-tests-multi-column-literal.sql.out
 
b/sql/core/src/test/resources/sql-tests/results/subquery/in-subquery/not-in-unit-tests-multi-column-literal.sql.out
index a16e98af9a417..9448c5c60c57a 100644
--- 
a/sql/core/src/test/resources/sql-tests/results/subquery/in-subquery/not-in-unit-tests-multi-column-literal.sql.out
+++ 
b/sql/core/src/test/resources/sql-tests/results/subquery/in-subquery/not-in-unit-tests-multi-column-literal.sql.out
@@ -23,9 +23,9 @@ FROM   m
 WHERE  b = 1.0 -- Matches (null, 1.0)
        AND (a, b) NOT IN ((2, 3.0))
 -- !query 1 schema
-struct<a:int,b:decimal(2,1)>
+struct<a:int,b:double>
 -- !query 1 output
-NULL   1
+NULL   1.0
 
 
 -- !query 2
@@ -36,7 +36,7 @@ FROM   m
 WHERE  b = 3.0 -- Matches (2, 3.0)
        AND (a, b) NOT IN ((2, 3.0))
 -- !query 2 schema
-struct<a:int,b:decimal(2,1)>
+struct<a:int,b:double>
 -- !query 2 output
 
 
@@ -49,6 +49,6 @@ FROM   m
 WHERE  b = 5.0 -- Matches (4, 5.0)
        AND (a, b) NOT IN ((2, 3.0))
 -- !query 3 schema
-struct<a:int,b:decimal(2,1)>
+struct<a:int,b:double>
 -- !query 3 output
-4      5
+4      5.0
diff --git 
a/sql/core/src/test/resources/sql-tests/results/subquery/in-subquery/not-in-unit-tests-multi-column.sql.out
 
b/sql/core/src/test/resources/sql-tests/results/subquery/in-subquery/not-in-unit-tests-multi-column.sql.out
index aa5f64b8ebf55..1bf000cb7e49c 100644
--- 
a/sql/core/src/test/resources/sql-tests/results/subquery/in-subquery/not-in-unit-tests-multi-column.sql.out
+++ 
b/sql/core/src/test/resources/sql-tests/results/subquery/in-subquery/not-in-unit-tests-multi-column.sql.out
@@ -37,11 +37,11 @@ WHERE  (a, b) NOT IN (SELECT *
                       FROM   s
                       WHERE  d > 5.0) -- Matches no rows
 -- !query 2 schema
-struct<a:int,b:decimal(2,1)>
+struct<a:int,b:double>
 -- !query 2 output
-2      3
-4      5
-NULL   1
+2      3.0
+4      5.0
+NULL   1.0
 NULL   NULL
 
 
@@ -54,7 +54,7 @@ WHERE  (a, b) NOT IN (SELECT *
                       FROM s
                       WHERE c IS NULL AND d IS NULL) -- Matches only (null, 
null)
 -- !query 3 schema
-struct<a:int,b:decimal(2,1)>
+struct<a:int,b:double>
 -- !query 3 output
 
 
@@ -69,7 +69,7 @@ WHERE  a IS NULL AND b IS NULL -- Matches only (null, null)
                           FROM s
                           WHERE c IS NOT NULL) -- Matches (0, 1.0), (2, 3.0), 
(4, null)
 -- !query 4 schema
-struct<a:int,b:decimal(2,1)>
+struct<a:int,b:double>
 -- !query 4 output
 
 
@@ -84,7 +84,7 @@ WHERE  b = 1.0 -- Matches (null, 1.0)
                           FROM s
                           WHERE c IS NOT NULL) -- Matches (0, 1.0), (2, 3.0), 
(4, null)
 -- !query 5 schema
-struct<a:int,b:decimal(2,1)>
+struct<a:int,b:double>
 -- !query 5 output
 
 
@@ -99,9 +99,9 @@ WHERE  b = 1.0 -- Matches (null, 1.0)
                           FROM s
                           WHERE c = 2) -- Matches (2, 3.0)
 -- !query 6 schema
-struct<a:int,b:decimal(2,1)>
+struct<a:int,b:double>
 -- !query 6 output
-NULL   1
+NULL   1.0
 
 
 -- !query 7
@@ -114,7 +114,7 @@ WHERE  b = 3.0 -- Matches (2, 3.0)
                           FROM s
                           WHERE c = 2) -- Matches (2, 3.0)
 -- !query 7 schema
-struct<a:int,b:decimal(2,1)>
+struct<a:int,b:double>
 -- !query 7 output
 
 
@@ -129,6 +129,6 @@ WHERE  b = 5.0 -- Matches (4, 5.0)
                           FROM s
                           WHERE c = 2) -- Matches (2, 3.0)
 -- !query 8 schema
-struct<a:int,b:decimal(2,1)>
+struct<a:int,b:double>
 -- !query 8 output
-4      5
+4      5.0
diff --git 
a/sql/core/src/test/resources/sql-tests/results/subquery/in-subquery/not-in-unit-tests-single-column-literal.sql.out
 
b/sql/core/src/test/resources/sql-tests/results/subquery/in-subquery/not-in-unit-tests-single-column-literal.sql.out
index 446447e890449..9a4131d043057 100644
--- 
a/sql/core/src/test/resources/sql-tests/results/subquery/in-subquery/not-in-unit-tests-single-column-literal.sql.out
+++ 
b/sql/core/src/test/resources/sql-tests/results/subquery/in-subquery/not-in-unit-tests-single-column-literal.sql.out
@@ -25,7 +25,7 @@ SELECT *
 FROM   m
 WHERE  a NOT IN (null)
 -- !query 1 schema
-struct<a:int,b:decimal(2,1)>
+struct<a:int,b:double>
 -- !query 1 output
 
 
@@ -38,7 +38,7 @@ FROM   m
 WHERE  b = 1.0 -- Only matches (null, 1.0)
        AND a NOT IN (2)
 -- !query 2 schema
-struct<a:int,b:decimal(2,1)>
+struct<a:int,b:double>
 -- !query 2 output
 
 
@@ -51,7 +51,7 @@ FROM   m
 WHERE  b = 3.0 -- Only matches (2, 3.0)
        AND a NOT IN (2)
 -- !query 3 schema
-struct<a:int,b:decimal(2,1)>
+struct<a:int,b:double>
 -- !query 3 output
 
 
@@ -64,6 +64,6 @@ FROM   m
 WHERE  b = 3.0 -- Only matches (2, 3.0)
        AND a NOT IN (6)
 -- !query 4 schema
-struct<a:int,b:decimal(2,1)>
+struct<a:int,b:double>
 -- !query 4 output
-2      3
+2      3.0
diff --git 
a/sql/core/src/test/resources/sql-tests/results/subquery/in-subquery/not-in-unit-tests-single-column.sql.out
 
b/sql/core/src/test/resources/sql-tests/results/subquery/in-subquery/not-in-unit-tests-single-column.sql.out
index f58ebeacc2872..b7be4170a0cc9 100644
--- 
a/sql/core/src/test/resources/sql-tests/results/subquery/in-subquery/not-in-unit-tests-single-column.sql.out
+++ 
b/sql/core/src/test/resources/sql-tests/results/subquery/in-subquery/not-in-unit-tests-single-column.sql.out
@@ -36,11 +36,11 @@ WHERE  a NOT IN (SELECT c
                  FROM   s
                  WHERE  d > 10.0) -- (empty subquery)
 -- !query 2 schema
-struct<a:int,b:decimal(2,1)>
+struct<a:int,b:double>
 -- !query 2 output
-2      3
-4      5
-NULL   1
+2      3.0
+4      5.0
+NULL   1.0
 
 
 -- !query 3
@@ -52,7 +52,7 @@ WHERE  a NOT IN (SELECT c
                  FROM   s
                  WHERE  d = 1.0) -- Only matches (null, 1.0)
 -- !query 3 schema
-struct<a:int,b:decimal(2,1)>
+struct<a:int,b:double>
 -- !query 3 output
 
 
@@ -67,7 +67,7 @@ WHERE  b = 1.0 -- Only matches (null, 1.0)
                      FROM   s
                      WHERE  d = 3.0) -- Matches (2, 3.0)
 -- !query 4 schema
-struct<a:int,b:decimal(2,1)>
+struct<a:int,b:double>
 -- !query 4 output
 
 
@@ -82,7 +82,7 @@ WHERE  b = 3.0 -- Only matches (2, 3.0)
                      FROM   s
                      WHERE  d = 3.0) -- Matches (2, 3.0)
 -- !query 5 schema
-struct<a:int,b:decimal(2,1)>
+struct<a:int,b:double>
 -- !query 5 output
 
 
@@ -97,9 +97,9 @@ WHERE  b = 3.0 -- Only matches (2, 3.0)
                      FROM   s
                      WHERE  d = 7.0) -- Matches (6, 7.0)
 -- !query 6 schema
-struct<a:int,b:decimal(2,1)>
+struct<a:int,b:double>
 -- !query 6 output
-2      3
+2      3.0
 
 
 -- !query 7
@@ -112,11 +112,11 @@ WHERE a NOT IN (SELECT c
                 FROM   s
                 WHERE  d = b + 10) -- Matches no row
 -- !query 7 schema
-struct<a:int,b:decimal(2,1)>
+struct<a:int,b:double>
 -- !query 7 output
-2      3
-4      5
-NULL   1
+2      3.0
+4      5.0
+NULL   1.0
 
 
 -- !query 8
@@ -129,9 +129,9 @@ WHERE  b = 1.0 -- Only matches (null, 1.0)
                      FROM   s
                      WHERE  d = b + 10) -- Matches no row
 -- !query 8 schema
-struct<a:int,b:decimal(2,1)>
+struct<a:int,b:double>
 -- !query 8 output
-NULL   1
+NULL   1.0
 
 
 -- !query 9
@@ -144,6 +144,6 @@ WHERE  b = 3.0 -- Only matches (2, 3.0)
                      FROM   s
                      WHERE  d = b + 10) -- Matches no row
 -- !query 9 schema
-struct<a:int,b:decimal(2,1)>
+struct<a:int,b:double>
 -- !query 9 output
-2      3
+2      3.0
diff --git 
a/sql/core/src/test/resources/sql-tests/results/subquery/in-subquery/simple-in.sql.out
 
b/sql/core/src/test/resources/sql-tests/results/subquery/in-subquery/simple-in.sql.out
index d69b4bcf185c3..3a4f3c179293c 100644
--- 
a/sql/core/src/test/resources/sql-tests/results/subquery/in-subquery/simple-in.sql.out
+++ 
b/sql/core/src/test/resources/sql-tests/results/subquery/in-subquery/simple-in.sql.out
@@ -72,13 +72,13 @@ FROM   t1
 WHERE  t1a IN (SELECT t2a
                FROM   t2)
 -- !query 3 schema
-struct<t1a:string,t1b:smallint,t1c:int,t1d:bigint,t1e:float,t1f:double,t1g:decimal(2,-2),t1h:timestamp,t1i:date>
+struct<t1a:string,t1b:smallint,t1c:int,t1d:bigint,t1e:float,t1f:double,t1g:double,t1h:timestamp,t1i:date>
 -- !query 3 output
-t1b    8       16      19      17.0    25.0    2600    2014-05-04 01:01:00     
2014-05-04
-t1c    8       16      19      17.0    25.0    2600    2014-05-04 01:02:00.001 
2014-05-05
-t1e    10      NULL    19      17.0    25.0    2600    2014-05-04 01:01:00     
2014-05-04
-t1e    10      NULL    19      17.0    25.0    2600    2014-09-04 01:02:00.001 
2014-09-04
-t1e    10      NULL    25      17.0    25.0    2600    2014-08-04 01:01:00     
2014-08-04
+t1b    8       16      19      17.0    25.0    2600.0  2014-05-04 01:01:00     
2014-05-04
+t1c    8       16      19      17.0    25.0    2600.0  2014-05-04 01:02:00.001 
2014-05-05
+t1e    10      NULL    19      17.0    25.0    2600.0  2014-05-04 01:01:00     
2014-05-04
+t1e    10      NULL    19      17.0    25.0    2600.0  2014-09-04 01:02:00.001 
2014-09-04
+t1e    10      NULL    25      17.0    25.0    2600.0  2014-08-04 01:01:00     
2014-08-04
 
 
 -- !query 4
@@ -88,9 +88,9 @@ WHERE  t1b IN (SELECT t2b
                FROM   t2
                WHERE  t1a = t2a)
 -- !query 4 schema
-struct<t1a:string,t1b:smallint,t1c:int,t1d:bigint,t1e:float,t1f:double,t1g:decimal(2,-2),t1h:timestamp,t1i:date>
+struct<t1a:string,t1b:smallint,t1c:int,t1d:bigint,t1e:float,t1f:double,t1g:double,t1h:timestamp,t1i:date>
 -- !query 4 output
-t1b    8       16      19      17.0    25.0    2600    2014-05-04 01:01:00     
2014-05-04
+t1b    8       16      19      17.0    25.0    2600.0  2014-05-04 01:01:00     
2014-05-04
 
 
 -- !query 5
diff --git 
a/sql/core/src/test/resources/sql-tests/results/subquery/scalar-subquery/scalar-subquery-predicate.sql.out
 
b/sql/core/src/test/resources/sql-tests/results/subquery/scalar-subquery/scalar-subquery-predicate.sql.out
index dd82efba0dde1..f11e9e213e85d 100644
--- 
a/sql/core/src/test/resources/sql-tests/results/subquery/scalar-subquery/scalar-subquery-predicate.sql.out
+++ 
b/sql/core/src/test/resources/sql-tests/results/subquery/scalar-subquery/scalar-subquery-predicate.sql.out
@@ -174,10 +174,10 @@ FROM   t1
 WHERE  t1c + 5 = (SELECT max(t2e)
                   FROM   t2)
 -- !query 11 schema
-struct<t1a:string,t1b:smallint,t1g:decimal(2,-2)>
+struct<t1a:string,t1b:smallint,t1g:double>
 -- !query 11 output
-val1a  16      2000
-val1a  16      2000
+val1a  16      2000.0
+val1a  16      2000.0
 
 
 -- !query 12
@@ -217,11 +217,11 @@ WHERE  t2a = t1a
 AND    max_t1g = (SELECT max(t1g)
                   FROM   t1)
 -- !query 14 schema
-struct<t2a:string,max_t1g:decimal(2,-2)>
+struct<t2a:string,max_t1g:double>
 -- !query 14 output
-val1b  2600
-val1c  2600
-val1e  2600
+val1b  2600.0
+val1c  2600.0
+val1e  2600.0
 
 
 -- !query 15
diff --git 
a/sql/core/src/test/resources/sql-tests/results/table-aliases.sql.out 
b/sql/core/src/test/resources/sql-tests/results/table-aliases.sql.out
index 1a2bd5ea91cde..5fe363136b7f6 100644
--- a/sql/core/src/test/resources/sql-tests/results/table-aliases.sql.out
+++ b/sql/core/src/test/resources/sql-tests/results/table-aliases.sql.out
@@ -90,8 +90,8 @@ struct<>
 -- !query 10
 SELECT * FROM (src1 s1 INNER JOIN src2 s2 ON s1.id = s2.id) dst(a, b, c, d)
 -- !query 10 schema
-struct<a:int,b:string,c:int,d:decimal(2,1)>
+struct<a:int,b:string,c:int,d:double>
 -- !query 10 output
 1      a       1       8.5
-2      b       2       1
+2      b       2       1.0
 3      c       3       3.2
diff --git 
a/sql/core/src/test/resources/sql-tests/results/typeCoercion/native/decimalArithmeticOperations.sql.out
 
b/sql/core/src/test/resources/sql-tests/results/typeCoercion/native/decimalArithmeticOperations.sql.out
index cbf44548b3cce..214c0dafe1dc0 100644
--- 
a/sql/core/src/test/resources/sql-tests/results/typeCoercion/native/decimalArithmeticOperations.sql.out
+++ 
b/sql/core/src/test/resources/sql-tests/results/typeCoercion/native/decimalArithmeticOperations.sql.out
@@ -1,50 +1,49 @@
 -- Automatically generated by SQLQueryTestSuite
--- Number of queries: 40
+-- Number of queries: 41
 
 
 -- !query 0
-CREATE TEMPORARY VIEW t AS SELECT 1.0 as a, 0.0 as b
+set spark.sql.legacy.literals.asDecimal=true
 -- !query 0 schema
-struct<>
+struct<key:string,value:string>
 -- !query 0 output
-
+spark.sql.legacy.literals.asDecimal    true
 
 
 -- !query 1
-select a / b from t
+CREATE TEMPORARY VIEW t AS SELECT 1.0 as a, 0.0 as b
 -- !query 1 schema
-struct<(CAST(a AS DECIMAL(2,1)) / CAST(b AS DECIMAL(2,1))):decimal(8,6)>
+struct<>
 -- !query 1 output
-NULL
+
 
 
 -- !query 2
-select a % b from t
+select a / b from t
 -- !query 2 schema
-struct<(CAST(a AS DECIMAL(2,1)) % CAST(b AS DECIMAL(2,1))):decimal(1,1)>
+struct<(CAST(a AS DECIMAL(2,1)) / CAST(b AS DECIMAL(2,1))):decimal(8,6)>
 -- !query 2 output
 NULL
 
 
 -- !query 3
-select pmod(a, b) from t
+select a % b from t
 -- !query 3 schema
-struct<pmod(CAST(a AS DECIMAL(2,1)), CAST(b AS DECIMAL(2,1))):decimal(1,1)>
+struct<(CAST(a AS DECIMAL(2,1)) % CAST(b AS DECIMAL(2,1))):decimal(1,1)>
 -- !query 3 output
 NULL
 
 
 -- !query 4
-create table decimals_test(id int, a decimal(38,18), b decimal(38,18)) using 
parquet
+select pmod(a, b) from t
 -- !query 4 schema
-struct<>
+struct<pmod(CAST(a AS DECIMAL(2,1)), CAST(b AS DECIMAL(2,1))):decimal(1,1)>
 -- !query 4 output
-
+NULL
 
 
 -- !query 5
-insert into decimals_test values(1, 100.0, 999.0), (2, 12345.123, 12345.123),
-  (3, 0.1234567891011, 1234.1), (4, 123456789123456789.0, 1.123456789123456789)
+create table decimals_test(id int, a decimal(38,18), b decimal(38,18)) using 
parquet
 -- !query 5 schema
 struct<>
 -- !query 5 output
@@ -52,284 +51,293 @@ struct<>
 
 
 -- !query 6
-select id, a+b, a-b, a*b, a/b from decimals_test order by id
+insert into decimals_test values(1, 100.0, 999.0), (2, 12345.123, 12345.123),
+  (3, 0.1234567891011, 1234.1), (4, 123456789123456789.0, 1.123456789123456789)
 -- !query 6 schema
-struct<id:int,(a + b):decimal(38,17),(a - b):decimal(38,17),(a * 
b):decimal(38,6),(a / b):decimal(38,6)>
+struct<>
 -- !query 6 output
+
+
+
+-- !query 7
+select id, a+b, a-b, a*b, a/b from decimals_test order by id
+-- !query 7 schema
+struct<id:int,(a + b):decimal(38,17),(a - b):decimal(38,17),(a * 
b):decimal(38,6),(a / b):decimal(38,6)>
+-- !query 7 output
 1      1099    -899    99900   0.1001
 2      24690.246       0       152402061.885129        1
 3      1234.2234567891011      -1233.9765432108989     152.358023      0.0001
 4      123456789123456790.12345678912345679    
123456789123456787.87654321087654321    138698367904130467.515623       
109890109097814272.043109
 
 
--- !query 7
+-- !query 8
 select id, a*10, b/10 from decimals_test order by id
--- !query 7 schema
+-- !query 8 schema
 struct<id:int,(CAST(a AS DECIMAL(38,18)) * CAST(CAST(10 AS DECIMAL(2,0)) AS 
DECIMAL(38,18))):decimal(38,15),(CAST(b AS DECIMAL(38,18)) / CAST(CAST(10 AS 
DECIMAL(2,0)) AS DECIMAL(38,18))):decimal(38,18)>
--- !query 7 output
+-- !query 8 output
 1      1000    99.9
 2      123451.23       1234.5123
 3      1.234567891011  123.41
 4      1234567891234567890     0.112345678912345679
 
 
--- !query 8
-select 10.3 * 3.0
--- !query 8 schema
-struct<(CAST(10.3 AS DECIMAL(3,1)) * CAST(3.0 AS DECIMAL(3,1))):decimal(6,2)>
--- !query 8 output
-30.9
-
-
 -- !query 9
-select 10.3000 * 3.0
+select 10.3 * 3.0
 -- !query 9 schema
-struct<(CAST(10.3000 AS DECIMAL(6,4)) * CAST(3.0 AS 
DECIMAL(6,4))):decimal(9,5)>
+struct<(CAST(10.3 AS DECIMAL(3,1)) * CAST(3.0 AS DECIMAL(3,1))):decimal(6,2)>
 -- !query 9 output
 30.9
 
 
 -- !query 10
-select 10.30000 * 30.0
+select 10.3000 * 3.0
 -- !query 10 schema
-struct<(CAST(10.30000 AS DECIMAL(7,5)) * CAST(30.0 AS 
DECIMAL(7,5))):decimal(11,6)>
+struct<(CAST(10.3000 AS DECIMAL(6,4)) * CAST(3.0 AS 
DECIMAL(6,4))):decimal(9,5)>
 -- !query 10 output
-309
+30.9
 
 
 -- !query 11
-select 10.300000000000000000 * 3.000000000000000000
+select 10.30000 * 30.0
 -- !query 11 schema
-struct<(CAST(10.300000000000000000 AS DECIMAL(20,18)) * 
CAST(3.000000000000000000 AS DECIMAL(20,18))):decimal(38,34)>
+struct<(CAST(10.30000 AS DECIMAL(7,5)) * CAST(30.0 AS 
DECIMAL(7,5))):decimal(11,6)>
 -- !query 11 output
-30.9
+309
 
 
 -- !query 12
-select 10.300000000000000000 * 3.0000000000000000000
+select 10.300000000000000000 * 3.000000000000000000
 -- !query 12 schema
-struct<(CAST(10.300000000000000000 AS DECIMAL(21,19)) * 
CAST(3.0000000000000000000 AS DECIMAL(21,19))):decimal(38,34)>
+struct<(CAST(10.300000000000000000 AS DECIMAL(20,18)) * 
CAST(3.000000000000000000 AS DECIMAL(20,18))):decimal(38,34)>
 -- !query 12 output
 30.9
 
 
 -- !query 13
-select 2.35E10 * 1.0
+select 10.300000000000000000 * 3.0000000000000000000
 -- !query 13 schema
-struct<(CAST(2.35E+10 AS DECIMAL(12,1)) * CAST(1.0 AS 
DECIMAL(12,1))):decimal(6,-7)>
+struct<(CAST(10.300000000000000000 AS DECIMAL(21,19)) * 
CAST(3.0000000000000000000 AS DECIMAL(21,19))):decimal(38,34)>
 -- !query 13 output
-23500000000
+30.9
 
 
 -- !query 14
-select (5e36 + 0.1) + 5e36
+select 2.35E10 * 1.0
 -- !query 14 schema
-struct<(CAST((CAST(5E+36 AS DECIMAL(38,1)) + CAST(0.1 AS DECIMAL(38,1))) AS 
DECIMAL(38,1)) + CAST(5E+36 AS DECIMAL(38,1))):decimal(38,1)>
+struct<(CAST(2.35E+10 AS DECIMAL(12,1)) * CAST(1.0 AS 
DECIMAL(12,1))):decimal(6,-7)>
 -- !query 14 output
-NULL
+23500000000
 
 
 -- !query 15
-select (-4e36 - 0.1) - 7e36
+select (5e36 + 0.1) + 5e36
 -- !query 15 schema
-struct<(CAST((CAST(-4E+36 AS DECIMAL(38,1)) - CAST(0.1 AS DECIMAL(38,1))) AS 
DECIMAL(38,1)) - CAST(7E+36 AS DECIMAL(38,1))):decimal(38,1)>
+struct<(CAST((CAST(5E+36 AS DECIMAL(38,1)) + CAST(0.1 AS DECIMAL(38,1))) AS 
DECIMAL(38,1)) + CAST(5E+36 AS DECIMAL(38,1))):decimal(38,1)>
 -- !query 15 output
 NULL
 
 
 -- !query 16
-select 12345678901234567890.0 * 12345678901234567890.0
+select (-4e36 - 0.1) - 7e36
 -- !query 16 schema
-struct<(12345678901234567890.0 * 12345678901234567890.0):decimal(38,2)>
+struct<(CAST((CAST(-4E+36 AS DECIMAL(38,1)) - CAST(0.1 AS DECIMAL(38,1))) AS 
DECIMAL(38,1)) - CAST(7E+36 AS DECIMAL(38,1))):decimal(38,1)>
 -- !query 16 output
 NULL
 
 
 -- !query 17
-select 1e35 / 0.1
+select 12345678901234567890.0 * 12345678901234567890.0
 -- !query 17 schema
-struct<(CAST(1E+35 AS DECIMAL(37,1)) / CAST(0.1 AS 
DECIMAL(37,1))):decimal(38,6)>
+struct<(12345678901234567890.0 * 12345678901234567890.0):decimal(38,2)>
 -- !query 17 output
 NULL
 
 
 -- !query 18
-select 1.2345678901234567890E30 * 1.2345678901234567890E25
+select 1e35 / 0.1
 -- !query 18 schema
-struct<(CAST(1.2345678901234567890E+30 AS DECIMAL(25,-6)) * 
CAST(1.2345678901234567890E+25 AS DECIMAL(25,-6))):decimal(38,-17)>
+struct<(CAST(1E+35 AS DECIMAL(37,1)) / CAST(0.1 AS 
DECIMAL(37,1))):decimal(38,6)>
 -- !query 18 output
 NULL
 
 
 -- !query 19
-select 12345678912345678912345678912.1234567 + 
9999999999999999999999999999999.12345
+select 1.2345678901234567890E30 * 1.2345678901234567890E25
 -- !query 19 schema
-struct<(CAST(12345678912345678912345678912.1234567 AS DECIMAL(38,6)) + 
CAST(9999999999999999999999999999999.12345 AS DECIMAL(38,6))):decimal(38,6)>
+struct<(CAST(1.2345678901234567890E+30 AS DECIMAL(25,-6)) * 
CAST(1.2345678901234567890E+25 AS DECIMAL(25,-6))):decimal(38,-17)>
 -- !query 19 output
-10012345678912345678912345678911.246907
+NULL
 
 
 -- !query 20
-select 123456789123456789.1234567890 * 1.123456789123456789
+select 12345678912345678912345678912.1234567 + 
9999999999999999999999999999999.12345
 -- !query 20 schema
-struct<(CAST(123456789123456789.1234567890 AS DECIMAL(36,18)) * 
CAST(1.123456789123456789 AS DECIMAL(36,18))):decimal(38,18)>
+struct<(CAST(12345678912345678912345678912.1234567 AS DECIMAL(38,6)) + 
CAST(9999999999999999999999999999999.12345 AS DECIMAL(38,6))):decimal(38,6)>
 -- !query 20 output
-138698367904130467.654320988515622621
+10012345678912345678912345678911.246907
 
 
 -- !query 21
-select 12345678912345.123456789123 / 0.000000012345678
+select 123456789123456789.1234567890 * 1.123456789123456789
 -- !query 21 schema
-struct<(CAST(12345678912345.123456789123 AS DECIMAL(29,15)) / 
CAST(1.2345678E-8 AS DECIMAL(29,15))):decimal(38,9)>
+struct<(CAST(123456789123456789.1234567890 AS DECIMAL(36,18)) * 
CAST(1.123456789123456789 AS DECIMAL(36,18))):decimal(38,18)>
 -- !query 21 output
-1000000073899961059796.725866332
+138698367904130467.654320988515622621
 
 
 -- !query 22
-set spark.sql.decimalOperations.allowPrecisionLoss=false
+select 12345678912345.123456789123 / 0.000000012345678
 -- !query 22 schema
-struct<key:string,value:string>
+struct<(CAST(12345678912345.123456789123 AS DECIMAL(29,15)) / 
CAST(1.2345678E-8 AS DECIMAL(29,15))):decimal(38,9)>
 -- !query 22 output
-spark.sql.decimalOperations.allowPrecisionLoss false
+1000000073899961059796.725866332
 
 
 -- !query 23
-select id, a+b, a-b, a*b, a/b from decimals_test order by id
+set spark.sql.decimalOperations.allowPrecisionLoss=false
 -- !query 23 schema
-struct<id:int,(a + b):decimal(38,18),(a - b):decimal(38,18),(a * 
b):decimal(38,36),(a / b):decimal(38,18)>
+struct<key:string,value:string>
 -- !query 23 output
+spark.sql.decimalOperations.allowPrecisionLoss false
+
+
+-- !query 24
+select id, a+b, a-b, a*b, a/b from decimals_test order by id
+-- !query 24 schema
+struct<id:int,(a + b):decimal(38,18),(a - b):decimal(38,18),(a * 
b):decimal(38,36),(a / b):decimal(38,18)>
+-- !query 24 output
 1      1099    -899    NULL    0.1001001001001001
 2      24690.246       0       NULL    1
 3      1234.2234567891011      -1233.9765432108989     NULL    
0.000100037913541123
 4      123456789123456790.123456789123456789   
123456789123456787.876543210876543211   NULL    
109890109097814272.043109406191131436
 
 
--- !query 24
+-- !query 25
 select id, a*10, b/10 from decimals_test order by id
--- !query 24 schema
+-- !query 25 schema
 struct<id:int,(CAST(a AS DECIMAL(38,18)) * CAST(CAST(10 AS DECIMAL(2,0)) AS 
DECIMAL(38,18))):decimal(38,18),(CAST(b AS DECIMAL(38,18)) / CAST(CAST(10 AS 
DECIMAL(2,0)) AS DECIMAL(38,18))):decimal(38,19)>
--- !query 24 output
+-- !query 25 output
 1      1000    99.9
 2      123451.23       1234.5123
 3      1.234567891011  123.41
 4      1234567891234567890     0.1123456789123456789
 
 
--- !query 25
-select 10.3 * 3.0
--- !query 25 schema
-struct<(CAST(10.3 AS DECIMAL(3,1)) * CAST(3.0 AS DECIMAL(3,1))):decimal(6,2)>
--- !query 25 output
-30.9
-
-
 -- !query 26
-select 10.3000 * 3.0
+select 10.3 * 3.0
 -- !query 26 schema
-struct<(CAST(10.3000 AS DECIMAL(6,4)) * CAST(3.0 AS 
DECIMAL(6,4))):decimal(9,5)>
+struct<(CAST(10.3 AS DECIMAL(3,1)) * CAST(3.0 AS DECIMAL(3,1))):decimal(6,2)>
 -- !query 26 output
 30.9
 
 
 -- !query 27
-select 10.30000 * 30.0
+select 10.3000 * 3.0
 -- !query 27 schema
-struct<(CAST(10.30000 AS DECIMAL(7,5)) * CAST(30.0 AS 
DECIMAL(7,5))):decimal(11,6)>
+struct<(CAST(10.3000 AS DECIMAL(6,4)) * CAST(3.0 AS 
DECIMAL(6,4))):decimal(9,5)>
 -- !query 27 output
-309
+30.9
 
 
 -- !query 28
-select 10.300000000000000000 * 3.000000000000000000
+select 10.30000 * 30.0
 -- !query 28 schema
-struct<(CAST(10.300000000000000000 AS DECIMAL(20,18)) * 
CAST(3.000000000000000000 AS DECIMAL(20,18))):decimal(38,36)>
+struct<(CAST(10.30000 AS DECIMAL(7,5)) * CAST(30.0 AS 
DECIMAL(7,5))):decimal(11,6)>
 -- !query 28 output
-30.9
+309
 
 
 -- !query 29
-select 10.300000000000000000 * 3.0000000000000000000
+select 10.300000000000000000 * 3.000000000000000000
 -- !query 29 schema
-struct<(CAST(10.300000000000000000 AS DECIMAL(21,19)) * 
CAST(3.0000000000000000000 AS DECIMAL(21,19))):decimal(38,37)>
+struct<(CAST(10.300000000000000000 AS DECIMAL(20,18)) * 
CAST(3.000000000000000000 AS DECIMAL(20,18))):decimal(38,36)>
 -- !query 29 output
-NULL
+30.9
 
 
 -- !query 30
-select 2.35E10 * 1.0
+select 10.300000000000000000 * 3.0000000000000000000
 -- !query 30 schema
-struct<(CAST(2.35E+10 AS DECIMAL(12,1)) * CAST(1.0 AS 
DECIMAL(12,1))):decimal(6,-7)>
+struct<(CAST(10.300000000000000000 AS DECIMAL(21,19)) * 
CAST(3.0000000000000000000 AS DECIMAL(21,19))):decimal(38,37)>
 -- !query 30 output
-23500000000
+NULL
 
 
 -- !query 31
-select (5e36 + 0.1) + 5e36
+select 2.35E10 * 1.0
 -- !query 31 schema
-struct<(CAST((CAST(5E+36 AS DECIMAL(38,1)) + CAST(0.1 AS DECIMAL(38,1))) AS 
DECIMAL(38,1)) + CAST(5E+36 AS DECIMAL(38,1))):decimal(38,1)>
+struct<(CAST(2.35E+10 AS DECIMAL(12,1)) * CAST(1.0 AS 
DECIMAL(12,1))):decimal(6,-7)>
 -- !query 31 output
-NULL
+23500000000
 
 
 -- !query 32
-select (-4e36 - 0.1) - 7e36
+select (5e36 + 0.1) + 5e36
 -- !query 32 schema
-struct<(CAST((CAST(-4E+36 AS DECIMAL(38,1)) - CAST(0.1 AS DECIMAL(38,1))) AS 
DECIMAL(38,1)) - CAST(7E+36 AS DECIMAL(38,1))):decimal(38,1)>
+struct<(CAST((CAST(5E+36 AS DECIMAL(38,1)) + CAST(0.1 AS DECIMAL(38,1))) AS 
DECIMAL(38,1)) + CAST(5E+36 AS DECIMAL(38,1))):decimal(38,1)>
 -- !query 32 output
 NULL
 
 
 -- !query 33
-select 12345678901234567890.0 * 12345678901234567890.0
+select (-4e36 - 0.1) - 7e36
 -- !query 33 schema
-struct<(12345678901234567890.0 * 12345678901234567890.0):decimal(38,2)>
+struct<(CAST((CAST(-4E+36 AS DECIMAL(38,1)) - CAST(0.1 AS DECIMAL(38,1))) AS 
DECIMAL(38,1)) - CAST(7E+36 AS DECIMAL(38,1))):decimal(38,1)>
 -- !query 33 output
 NULL
 
 
 -- !query 34
-select 1e35 / 0.1
+select 12345678901234567890.0 * 12345678901234567890.0
 -- !query 34 schema
-struct<(CAST(1E+35 AS DECIMAL(37,1)) / CAST(0.1 AS 
DECIMAL(37,1))):decimal(38,3)>
+struct<(12345678901234567890.0 * 12345678901234567890.0):decimal(38,2)>
 -- !query 34 output
 NULL
 
 
 -- !query 35
-select 1.2345678901234567890E30 * 1.2345678901234567890E25
+select 1e35 / 0.1
 -- !query 35 schema
-struct<(CAST(1.2345678901234567890E+30 AS DECIMAL(25,-6)) * 
CAST(1.2345678901234567890E+25 AS DECIMAL(25,-6))):decimal(38,-17)>
+struct<(CAST(1E+35 AS DECIMAL(37,1)) / CAST(0.1 AS 
DECIMAL(37,1))):decimal(38,3)>
 -- !query 35 output
 NULL
 
 
 -- !query 36
-select 12345678912345678912345678912.1234567 + 
9999999999999999999999999999999.12345
+select 1.2345678901234567890E30 * 1.2345678901234567890E25
 -- !query 36 schema
-struct<(CAST(12345678912345678912345678912.1234567 AS DECIMAL(38,7)) + 
CAST(9999999999999999999999999999999.12345 AS DECIMAL(38,7))):decimal(38,7)>
+struct<(CAST(1.2345678901234567890E+30 AS DECIMAL(25,-6)) * 
CAST(1.2345678901234567890E+25 AS DECIMAL(25,-6))):decimal(38,-17)>
 -- !query 36 output
 NULL
 
 
 -- !query 37
-select 123456789123456789.1234567890 * 1.123456789123456789
+select 12345678912345678912345678912.1234567 + 
9999999999999999999999999999999.12345
 -- !query 37 schema
-struct<(CAST(123456789123456789.1234567890 AS DECIMAL(36,18)) * 
CAST(1.123456789123456789 AS DECIMAL(36,18))):decimal(38,28)>
+struct<(CAST(12345678912345678912345678912.1234567 AS DECIMAL(38,7)) + 
CAST(9999999999999999999999999999999.12345 AS DECIMAL(38,7))):decimal(38,7)>
 -- !query 37 output
 NULL
 
 
 -- !query 38
-select 12345678912345.123456789123 / 0.000000012345678
+select 123456789123456789.1234567890 * 1.123456789123456789
 -- !query 38 schema
-struct<(CAST(12345678912345.123456789123 AS DECIMAL(29,15)) / 
CAST(1.2345678E-8 AS DECIMAL(29,15))):decimal(38,18)>
+struct<(CAST(123456789123456789.1234567890 AS DECIMAL(36,18)) * 
CAST(1.123456789123456789 AS DECIMAL(36,18))):decimal(38,28)>
 -- !query 38 output
 NULL
 
 
 -- !query 39
-drop table decimals_test
+select 12345678912345.123456789123 / 0.000000012345678
 -- !query 39 schema
-struct<>
+struct<(CAST(12345678912345.123456789123 AS DECIMAL(29,15)) / 
CAST(1.2345678E-8 AS DECIMAL(29,15))):decimal(38,18)>
 -- !query 39 output
+NULL
+
+
+-- !query 40
+drop table decimals_test
+-- !query 40 schema
+struct<>
+-- !query 40 output
 
diff --git 
a/sql/core/src/test/resources/sql-tests/results/typeCoercion/native/implicitTypeCasts.sql.out
 
b/sql/core/src/test/resources/sql-tests/results/typeCoercion/native/implicitTypeCasts.sql.out
index 44fa48e2697b3..fa6daaca06751 100644
--- 
a/sql/core/src/test/resources/sql-tests/results/typeCoercion/native/implicitTypeCasts.sql.out
+++ 
b/sql/core/src/test/resources/sql-tests/results/typeCoercion/native/implicitTypeCasts.sql.out
@@ -45,7 +45,7 @@ struct<(CAST(4 AS DOUBLE) / CAST(CAST(2 AS DOUBLE) AS 
DOUBLE)):double>
 -- !query 5
 SELECT 1.1 + '2' FROM t
 -- !query 5 schema
-struct<(CAST(1.1 AS DOUBLE) + CAST(2 AS DOUBLE)):double>
+struct<(1.1 + CAST(2 AS DOUBLE)):double>
 -- !query 5 output
 3.1
 
@@ -53,7 +53,7 @@ struct<(CAST(1.1 AS DOUBLE) + CAST(2 AS DOUBLE)):double>
 -- !query 6
 SELECT 1.1 - '2' FROM t
 -- !query 6 schema
-struct<(CAST(1.1 AS DOUBLE) - CAST(2 AS DOUBLE)):double>
+struct<(1.1 - CAST(2 AS DOUBLE)):double>
 -- !query 6 output
 -0.8999999999999999
 
@@ -61,7 +61,7 @@ struct<(CAST(1.1 AS DOUBLE) - CAST(2 AS DOUBLE)):double>
 -- !query 7
 SELECT 1.1 * '2' FROM t
 -- !query 7 schema
-struct<(CAST(1.1 AS DOUBLE) * CAST(2 AS DOUBLE)):double>
+struct<(1.1 * CAST(2 AS DOUBLE)):double>
 -- !query 7 output
 2.2
 
@@ -69,7 +69,7 @@ struct<(CAST(1.1 AS DOUBLE) * CAST(2 AS DOUBLE)):double>
 -- !query 8
 SELECT 4.4 / '2' FROM t
 -- !query 8 schema
-struct<(CAST(4.4 AS DOUBLE) / CAST(2 AS DOUBLE)):double>
+struct<(4.4 / CAST(2 AS DOUBLE)):double>
 -- !query 8 output
 2.2
 
@@ -77,7 +77,7 @@ struct<(CAST(4.4 AS DOUBLE) / CAST(2 AS DOUBLE)):double>
 -- !query 9
 SELECT 1.1 + '2.2' FROM t
 -- !query 9 schema
-struct<(CAST(1.1 AS DOUBLE) + CAST(2.2 AS DOUBLE)):double>
+struct<(1.1 + CAST(2.2 AS DOUBLE)):double>
 -- !query 9 output
 3.3000000000000003
 
@@ -85,7 +85,7 @@ struct<(CAST(1.1 AS DOUBLE) + CAST(2.2 AS DOUBLE)):double>
 -- !query 10
 SELECT 1.1 - '2.2' FROM t
 -- !query 10 schema
-struct<(CAST(1.1 AS DOUBLE) - CAST(2.2 AS DOUBLE)):double>
+struct<(1.1 - CAST(2.2 AS DOUBLE)):double>
 -- !query 10 output
 -1.1
 
@@ -93,7 +93,7 @@ struct<(CAST(1.1 AS DOUBLE) - CAST(2.2 AS DOUBLE)):double>
 -- !query 11
 SELECT 1.1 * '2.2' FROM t
 -- !query 11 schema
-struct<(CAST(1.1 AS DOUBLE) * CAST(2.2 AS DOUBLE)):double>
+struct<(1.1 * CAST(2.2 AS DOUBLE)):double>
 -- !query 11 output
 2.4200000000000004
 
@@ -101,7 +101,7 @@ struct<(CAST(1.1 AS DOUBLE) * CAST(2.2 AS DOUBLE)):double>
 -- !query 12
 SELECT 4.4 / '2.2' FROM t
 -- !query 12 schema
-struct<(CAST(4.4 AS DOUBLE) / CAST(2.2 AS DOUBLE)):double>
+struct<(4.4 / CAST(2.2 AS DOUBLE)):double>
 -- !query 12 output
 2.0
 
diff --git a/sql/core/src/test/resources/sql-tests/results/union.sql.out 
b/sql/core/src/test/resources/sql-tests/results/union.sql.out
index b023df825d814..751d1b4a95581 100644
--- a/sql/core/src/test/resources/sql-tests/results/union.sql.out
+++ b/sql/core/src/test/resources/sql-tests/results/union.sql.out
@@ -40,14 +40,14 @@ FROM   (SELECT * FROM t1
         UNION ALL
         SELECT * FROM t2)
 -- !query 3 schema
-struct<c1:decimal(11,1),c2:string>
+struct<c1:double,c2:string>
 -- !query 3 output
-1      1
-1      1
-1      a
-2      4
-2      4
-2      b
+1.0    1
+1.0    1
+1.0    a
+2.0    4
+2.0    4
+2.0    b
 
 
 -- !query 4
diff --git a/sql/core/src/test/resources/sql-tests/results/window.sql.out 
b/sql/core/src/test/resources/sql-tests/results/window.sql.out
index 367dc4f513635..58ce07b4deef4 100644
--- a/sql/core/src/test/resources/sql-tests/results/window.sql.out
+++ b/sql/core/src/test/resources/sql-tests/results/window.sql.out
@@ -119,7 +119,7 @@ NULL        b       NULL
 SELECT val_double, cate, sum(val_double) OVER(PARTITION BY cate ORDER BY 
val_double
 RANGE BETWEEN CURRENT ROW AND 2.5 FOLLOWING) FROM testData ORDER BY cate, 
val_double
 -- !query 7 schema
-struct<val_double:double,cate:string,sum(val_double) OVER (PARTITION BY cate 
ORDER BY val_double ASC NULLS FIRST RANGE BETWEEN CURRENT ROW AND CAST(2.5 AS 
DOUBLE) FOLLOWING):double>
+struct<val_double:double,cate:string,sum(val_double) OVER (PARTITION BY cate 
ORDER BY val_double ASC NULLS FIRST RANGE BETWEEN CURRENT ROW AND 2.5 
FOLLOWING):double>
 -- !query 7 output
 NULL   NULL    NULL
 1.0    NULL    1.0


 

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
[email protected]


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to