Ian created SPARK-13731:
---------------------------

             Summary: expression evaluation for NaN in select statement
                 Key: SPARK-13731
                 URL: https://issues.apache.org/jira/browse/SPARK-13731
             Project: Spark
          Issue Type: Bug
          Components: SQL
    Affects Versions: 1.6.0
            Reporter: Ian


We are expecting arithmetic expression a/b should be:
1. returning NaN if a=0 and b=0
2. returning Infinity if a=1 and b=0

Is the expectation reasonable? 
The following is a simple test case snippet that read from storage and evaluate 
arithmetic in select.
It si assuming org.apache.spark.sql.hive.execution.SQLQuerySuite: 
{code}
  test("Expression should be evaluated to Nan/Infinity in Select") {
    withTable("testNan") {
      withTempTable("src") {
        Seq((1d, 0d), (0d, 0d)).toDF().registerTempTable("src")
        sql("CREATE TABLE testNan(a double, b double) STORED AS PARQUET AS 
SELECT * FROM src")
      }

      checkAnswer(sql(
        """
          |SELECT a/b FROM testNan
        """.stripMargin),
        Seq(
          Row(Double.PositiveInfinity),
          Row(Double.NaN)
        )
      )
    }
  }

{code}



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscr...@spark.apache.org
For additional commands, e-mail: issues-h...@spark.apache.org

Reply via email to