-
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.
fix: incorrect mapping of floating point + and - ops (#131)
* refactor: allow for custom schema creates in tests * test: mapping of arithmetic operations to Substrait * fix: incorrect mapping of fp + and - ops * feat: map numeric negation * feat: map mod * feat: map power * feat: map exp * feat: map trigonometric functions * feat: map abs * feat: map sign * refactor: simplify arithmetic tests
- Loading branch information
Showing
3 changed files
with
101 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
70 changes: 70 additions & 0 deletions
70
isthmus/src/test/java/io/substrait/isthmus/ArithmeticFunctionTest.java
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,70 @@ | ||
package io.substrait.isthmus; | ||
|
||
import java.util.List; | ||
import org.junit.jupiter.params.ParameterizedTest; | ||
import org.junit.jupiter.params.provider.ValueSource; | ||
|
||
public class ArithmeticFunctionTest extends PlanTestBase { | ||
|
||
static List<String> CREATES = | ||
List.of( | ||
"CREATE TABLE numbers (i8 TINYINT, i16 SMALLINT, i32 INT, i64 BIGINT, fp32 FLOAT, fp64 DOUBLE)"); | ||
|
||
@ParameterizedTest | ||
@ValueSource(strings = {"i8", "i16", "i32", "i64", "fp32", "fp64"}) | ||
void arithmetic(String c) throws Exception { | ||
String query = | ||
String.format( | ||
"SELECT %s + %s, %s - %s, %s * %s, %s / %s FROM numbers", c, c, c, c, c, c, c, c); | ||
assertSqlSubstraitRelRoundTrip(query, CREATES); | ||
} | ||
|
||
@ParameterizedTest | ||
@ValueSource(strings = {"i8", "i16", "i32", "i64", "fp32", "fp64"}) | ||
void abs(String column) throws Exception { | ||
String query = String.format("SELECT abs(%s) FROM numbers", column); | ||
assertSqlSubstraitRelRoundTrip(query, CREATES); | ||
} | ||
|
||
@ParameterizedTest | ||
@ValueSource(strings = {"fp32", "fp64"}) | ||
void exponential(String column) throws Exception { | ||
String query = String.format("SELECT exp(%s) FROM numbers", column); | ||
assertSqlSubstraitRelRoundTrip(query, CREATES); | ||
} | ||
|
||
@ParameterizedTest | ||
@ValueSource(strings = {"i8", "i16", "i32", "i64"}) | ||
void mod(String column) throws Exception { | ||
String query = String.format("SELECT mod(%s, %s) FROM numbers", column, column); | ||
assertSqlSubstraitRelRoundTrip(query, CREATES); | ||
} | ||
|
||
@ParameterizedTest | ||
@ValueSource(strings = {"i8", "i16", "i32", "i64", "fp32", "fp64"}) | ||
void negation(String column) throws Exception { | ||
String query = String.format("SELECT -%s FROM numbers", column); | ||
assertSqlSubstraitRelRoundTrip(query, CREATES); | ||
} | ||
|
||
@ParameterizedTest | ||
@ValueSource(strings = {"i64", "fp32", "fp64"}) | ||
void power(String column) throws Exception { | ||
String query = String.format("SELECT power(%s, %s) FROM numbers", column, column); | ||
assertSqlSubstraitRelRoundTrip(query, CREATES); | ||
} | ||
|
||
@ParameterizedTest | ||
@ValueSource(strings = {"sin", "cos", "tan", "asin", "acos", "atan"}) | ||
void trigonometric(String fname) throws Exception { | ||
String query = String.format("SELECT %s(fp32), %s(fp64) FROM numbers", fname, fname); | ||
assertSqlSubstraitRelRoundTrip(query, CREATES); | ||
} | ||
|
||
@ParameterizedTest | ||
@ValueSource(strings = {"i8", "i16", "i32", "i64", "fp32", "fp64"}) | ||
void sign(String column) throws Exception { | ||
String query = String.format("SELECT sign(%s) FROM numbers", column); | ||
assertSqlSubstraitRelRoundTrip(query, CREATES); | ||
} | ||
} |
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