Uploaded image for project: 'Spark'
  1. Spark
  2. SPARK-28620

Double type returned for float type in Beeline/JDBC

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Open
    • Major
    • Resolution: Unresolved
    • 3.0.0
    • None
    • SQL
    • None

    Description

        test("SPARK-28620") {
          withJdbcStatement {
            statement =>
              val rs = statement.executeQuery(
                "SELECT CAST('1.2345678901234e+20' AS FLOAT), CAST('4.56' AS FLOAT)")
              rs.next()
              assert(rs.getObject(1).isInstanceOf[java.lang.Double])
              assert(rs.getObject(2).isInstanceOf[java.lang.Double])
          }
        }
      

      This inconsistent with spark-shell and spark-sql:

      0: jdbc:hive2://localhost:10000> SELECT CAST('1.2345678901234e+20' AS FLOAT), CAST('4.56' AS FLOAT);
      +-------------------------------------+----------------------+
      | CAST(1.2345678901234e+20 AS FLOAT)  | CAST(4.56 AS FLOAT)  |
      +-------------------------------------+----------------------+
      | 1.2345679000000001E20               | 4.56                 |
      +-------------------------------------+----------------------+
      1 row selected (0.268 seconds)
      
      spark-sql> SELECT CAST('1.2345678901234e+20' AS FLOAT), CAST('4.56' AS FLOAT);
      1.2345679E20	4.56
      
      scala> spark.sql("SELECT CAST('1.2345678901234e+20' AS FLOAT), CAST('4.56' AS FLOAT)").show
      +----------------------------------+-------------------+
      |CAST(1.2345678901234e+20 AS FLOAT)|CAST(4.56 AS FLOAT)|
      +----------------------------------+-------------------+
      |                      1.2345679E20|               4.56|
      +----------------------------------+-------------------+
      

      Attachments

        Issue Links

          Activity

            People

              Unassigned Unassigned
              yumwang Yuming Wang
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

                Created:
                Updated: