diff options
author | William Benton <willb@redhat.com> | 2014-08-29 15:26:59 -0700 |
---|---|---|
committer | Michael Armbrust <michael@databricks.com> | 2014-08-29 15:26:59 -0700 |
commit | 2f1519defaba4f3c7d536669f909bfd9e13e4069 (patch) | |
tree | dc19633311874e2ac5a5df8a94165981e69d44bc /sql/core | |
parent | 53aa8316e88980c6f46d3b9fc90d935a4738a370 (diff) | |
download | spark-2f1519defaba4f3c7d536669f909bfd9e13e4069.tar.gz spark-2f1519defaba4f3c7d536669f909bfd9e13e4069.tar.bz2 spark-2f1519defaba4f3c7d536669f909bfd9e13e4069.zip |
SPARK-2813: [SQL] Implement SQRT() directly in Spark SQL
This PR adds a native implementation for SQL SQRT() and thus avoids delegating this function to Hive.
Author: William Benton <willb@redhat.com>
Closes #1750 from willb/spark-2813 and squashes the following commits:
22c8a79 [William Benton] Fixed missed newline from rebase
d673861 [William Benton] Added string coercions for SQRT and associated test case
e125df4 [William Benton] Added ExpressionEvaluationSuite test cases for SQRT
7b84bcd [William Benton] SQL SQRT now properly returns NULL for NULL inputs
8256971 [William Benton] added SQRT test to SqlQuerySuite
504d2e5 [William Benton] Added native SQRT implementation
Diffstat (limited to 'sql/core')
-rw-r--r-- | sql/core/src/test/scala/org/apache/spark/sql/SQLQuerySuite.scala | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/sql/core/src/test/scala/org/apache/spark/sql/SQLQuerySuite.scala b/sql/core/src/test/scala/org/apache/spark/sql/SQLQuerySuite.scala index 9b2a36d33f..4047bc0672 100644 --- a/sql/core/src/test/scala/org/apache/spark/sql/SQLQuerySuite.scala +++ b/sql/core/src/test/scala/org/apache/spark/sql/SQLQuerySuite.scala @@ -34,6 +34,20 @@ class SQLQuerySuite extends QueryTest { "test") } + test("SQRT") { + checkAnswer( + sql("SELECT SQRT(key) FROM testData"), + (1 to 100).map(x => Row(math.sqrt(x.toDouble))).toSeq + ) + } + + test("SQRT with automatic string casts") { + checkAnswer( + sql("SELECT SQRT(CAST(key AS STRING)) FROM testData"), + (1 to 100).map(x => Row(math.sqrt(x.toDouble))).toSeq + ) + } + test("SPARK-2407 Added Parser of SQL SUBSTR()") { checkAnswer( sql("SELECT substr(tableName, 1, 2) FROM tableName"), |