-
Notifications
You must be signed in to change notification settings - Fork 72
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(spark): add some numeric function mappings
Signed-off-by: Andrew Coleman <[email protected]>
- Loading branch information
1 parent
e3139c6
commit 5d9d73a
Showing
3 changed files
with
70 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
40 changes: 40 additions & 0 deletions
40
spark/src/test/scala/io/substrait/spark/NumericSuite.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
package io.substrait.spark | ||
|
||
import org.apache.spark.SparkFunSuite | ||
import org.apache.spark.sql.test.SharedSparkSession | ||
|
||
class NumericSuite extends SparkFunSuite with SharedSparkSession with SubstraitPlanTestBase { | ||
|
||
override def beforeAll(): Unit = { | ||
super.beforeAll() | ||
sparkContext.setLogLevel("WARN") | ||
} | ||
|
||
test("basic") { | ||
assertSqlSubstraitRelRoundTrip( | ||
"select sqrt(abs(num)), mod(num, 2) from (values (-5), (7.4)) as table(num)" | ||
) | ||
} | ||
|
||
test("exponentials") { | ||
assertSqlSubstraitRelRoundTrip( | ||
"select power(num, 3), exp(num), ln(num), log10(num) from (values (5), (17)) as table(num)" | ||
) | ||
} | ||
|
||
test("trig") { | ||
assertSqlSubstraitRelRoundTrip( | ||
"select sin(num), cos(num), tan(num) from (values (30), (90)) as table(num)" | ||
) | ||
assertSqlSubstraitRelRoundTrip( | ||
"select asin(num), acos(num), atan(num) from (values (0.5), (-0.5)) as table(num)" | ||
) | ||
assertSqlSubstraitRelRoundTrip( | ||
"select sinh(num), cosh(num), tanh(num) from (values (30), (90)) as table(num)" | ||
) | ||
assertSqlSubstraitRelRoundTrip( | ||
"select asinh(num), acosh(num), atanh(num) from (values (0.5), (-0.5)) as table(num)" | ||
) | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters