Skip to content

Commit e244502

Browse files
Fix tests to consider java formatting
1 parent 33bc5b2 commit e244502

File tree

1 file changed

+30
-11
lines changed

1 file changed

+30
-11
lines changed

java/gandiva/src/test/java/org/apache/arrow/gandiva/evaluator/ProjectorTest.java

Lines changed: 30 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2082,10 +2082,10 @@ public void testCastVarcharFromInteger() throws Exception {
20822082
String[] expValues =
20832083
new String[] {
20842084
"",
2085-
"2345",
2086-
"23",
2087-
"2345",
2088-
"-2345",
2085+
Integer.toString(2345).substring(0, 4),
2086+
Integer.toString(2345).substring(0, 2),
2087+
Integer.toString(2345),
2088+
Integer.toString(-2345)
20892089
};
20902090

20912091
ArrowBuf bufValidity = buf(validity);
@@ -2146,24 +2146,43 @@ public void testCastVarcharFromFloat() throws Exception {
21462146
byte[] validity = new byte[] {(byte) 255};
21472147
double[] values =
21482148
new double[] {
2149-
23.45,
2150-
23.45,
2149+
-0.0,
2150+
0.0,
2151+
1.0,
2152+
0.001,
2153+
0.0009,
2154+
999999.9999,
2155+
10000000.0,
21512156
23.45,
21522157
23.45,
21532158
-23.45,
21542159
};
21552160
long[] lenValues =
21562161
new long[] {
2157-
0L, 6L, 6L, 6L, 6L
2162+
6L, 6L, 6L, 6L, 10L, 15L, 15L,
2163+
0L, 6L, 6L
21582164
};
21592165

2166+
/*The Java real numbers are represented in two ways and Gandiva must
2167+
* follow the same rules:
2168+
* - If the number is greater or equals than 10^7 and less than 10^(-3)
2169+
* it will be represented using scientific notation, e.g:
2170+
* - 0.000012 -> 1.2E-5
2171+
* - 10000002.3 -> 1.00000023E7
2172+
* - If the numbers are between that interval above, they are showed as is.
2173+
* - The "0.0" and "-0.0" must be represented as the same number: "0.0"*/
21602174
String[] expValues =
21612175
new String[] {
2176+
Double.toString(-0.0), // must becast to -> "0.0"
2177+
Double.toString(0.0), // must be cast to -> "0.0"
2178+
Double.toString(1.0), // must be cast to -> "1.0"
2179+
Double.toString(0.001), // must be cast to -> "0.001"
2180+
Double.toString(0.0009), // must be cast to -> "9E-4"
2181+
Double.toString(999999.9999), // must be cast to -> "999999.9999"
2182+
Double.toString(10000000.0), // must be cast to 10000000.0
21622183
"",
2163-
"23.45",
2164-
"23.45",
2165-
"23.45",
2166-
"-23.45",
2184+
Double.toString(23.45),
2185+
Double.toString(-23.45)
21672186
};
21682187

21692188
ArrowBuf bufValidity = buf(validity);

0 commit comments

Comments
 (0)