Skip to content

Commit cec11bb

Browse files
Add tests to check Java compatibility
1 parent 302139c commit cec11bb

File tree

1 file changed

+31
-27
lines changed

1 file changed

+31
-27
lines changed

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

Lines changed: 31 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1193,7 +1193,7 @@ public void testInExpr() throws GandivaException, Exception {
11931193
Field c1 = Field.nullable("c1", int32);
11941194

11951195
TreeNode inExpr =
1196-
TreeBuilder.makeInExpressionInt32(TreeBuilder.makeField(c1), Sets.newHashSet(1, 2, 3, 4, 5, 15, 16));
1196+
TreeBuilder.makeInExpressionInt32(TreeBuilder.makeField(c1), Sets.newHashSet(1, 2, 3, 4, 5, 15, 16));
11971197
ExpressionTree expr = TreeBuilder.makeExpression(inExpr, Field.nullable("result", boolType));
11981198
Schema schema = new Schema(Lists.newArrayList(c1));
11991199
Projector eval = Projector.make(schema, Lists.newArrayList(expr));
@@ -1208,10 +1208,10 @@ public void testInExpr() throws GandivaException, Exception {
12081208

12091209
ArrowFieldNode fieldNode = new ArrowFieldNode(numRows, 0);
12101210
ArrowRecordBatch batch =
1211-
new ArrowRecordBatch(
1212-
numRows,
1213-
Lists.newArrayList(fieldNode, fieldNode),
1214-
Lists.newArrayList(c1Validity, c1Data, c2Validity));
1211+
new ArrowRecordBatch(
1212+
numRows,
1213+
Lists.newArrayList(fieldNode, fieldNode),
1214+
Lists.newArrayList(c1Validity, c1Data, c2Validity));
12151215

12161216
BitVector bitVector = new BitVector(EMPTY_SCHEMA_PATH, allocator);
12171217
bitVector.allocateNew(numRows);
@@ -1297,27 +1297,27 @@ public void testInExprStrings() throws GandivaException, Exception {
12971297
List<TreeNode> args = Lists.newArrayList(TreeBuilder.makeField(c1), l1, l2);
12981298
TreeNode substr = TreeBuilder.makeFunction("substr", args, new ArrowType.Utf8());
12991299
TreeNode inExpr =
1300-
TreeBuilder.makeInExpressionString(substr, Sets.newHashSet("one", "two", "thr", "fou"));
1300+
TreeBuilder.makeInExpressionString(substr, Sets.newHashSet("one", "two", "thr", "fou"));
13011301
ExpressionTree expr = TreeBuilder.makeExpression(inExpr, Field.nullable("result", boolType));
13021302
Schema schema = new Schema(Lists.newArrayList(c1));
13031303
Projector eval = Projector.make(schema, Lists.newArrayList(expr));
13041304

13051305
int numRows = 16;
13061306
byte[] validity = new byte[]{(byte) 255, 0};
13071307
String[] c1Values = new String[]{"one", "two", "three", "four", "five", "six", "seven",
1308-
"eight", "nine", "ten", "eleven", "twelve", "thirteen", "fourteen", "fifteen",
1309-
"sixteen"};
1308+
"eight", "nine", "ten", "eleven", "twelve", "thirteen", "fourteen", "fifteen",
1309+
"sixteen"};
13101310

13111311
ArrowBuf c1Validity = buf(validity);
13121312
List<ArrowBuf> dataBufsX = stringBufs(c1Values);
13131313
ArrowBuf c2Validity = buf(validity);
13141314

13151315
ArrowFieldNode fieldNode = new ArrowFieldNode(numRows, 0);
13161316
ArrowRecordBatch batch =
1317-
new ArrowRecordBatch(
1318-
numRows,
1319-
Lists.newArrayList(fieldNode, fieldNode),
1320-
Lists.newArrayList(c1Validity, dataBufsX.get(0), dataBufsX.get(1), c2Validity));
1317+
new ArrowRecordBatch(
1318+
numRows,
1319+
Lists.newArrayList(fieldNode, fieldNode),
1320+
Lists.newArrayList(c1Validity, dataBufsX.get(0), dataBufsX.get(1), c2Validity));
13211321

13221322
BitVector bitVector = new BitVector(EMPTY_SCHEMA_PATH, allocator);
13231323
bitVector.allocateNew(numRows);
@@ -1509,9 +1509,9 @@ public void testDateTrunc() throws Exception {
15091509

15101510
Field resultField = Field.nullable("result", date64);
15111511
List<ExpressionTree> exprs =
1512-
Lists.newArrayList(
1513-
TreeBuilder.makeExpression(dateToYear, resultField),
1514-
TreeBuilder.makeExpression(dateToMonth, resultField));
1512+
Lists.newArrayList(
1513+
TreeBuilder.makeExpression(dateToYear, resultField),
1514+
TreeBuilder.makeExpression(dateToMonth, resultField));
15151515

15161516
Schema schema = new Schema(Lists.newArrayList(dateField));
15171517
Projector eval = Projector.make(schema, exprs);
@@ -1544,10 +1544,10 @@ public void testDateTrunc() throws Exception {
15441544

15451545
ArrowFieldNode fieldNode = new ArrowFieldNode(numRows, 0);
15461546
ArrowRecordBatch batch =
1547-
new ArrowRecordBatch(
1548-
numRows,
1549-
Lists.newArrayList(fieldNode),
1550-
Lists.newArrayList(bufValidity, millisData));
1547+
new ArrowRecordBatch(
1548+
numRows,
1549+
Lists.newArrayList(fieldNode),
1550+
Lists.newArrayList(bufValidity, millisData));
15511551

15521552
List<ValueVector> output = new ArrayList<ValueVector>();
15531553
for (int i = 0; i < exprs.size(); i++) {
@@ -2151,35 +2151,39 @@ public void testCastVarcharFromFloat() throws Exception {
21512151
1.0,
21522152
0.001,
21532153
0.0009,
2154+
0.00099893,
21542155
999999.9999,
21552156
10000000.0,
2157+
23943410000000.343434,
21562158
23.45,
21572159
23.45,
21582160
-23.45,
21592161
};
21602162
long[] lenValues =
21612163
new long[] {
2162-
6L, 6L, 6L, 6L, 10L, 15L, 15L,
2164+
6L, 6L, 6L, 6L, 10L, 15L, 15L, 15L, 30L,
21632165
0L, 6L, 6L
21642166
};
21652167

21662168
/*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"*/
2169+
* follow the same rules:
2170+
* - If the number is greater or equals than 10^7 and less than 10^(-3)
2171+
* it will be represented using scientific notation, e.g:
2172+
* - 0.000012 -> 1.2E-5
2173+
* - 10000002.3 -> 1.00000023E7
2174+
* - If the numbers are between that interval above, they are showed as is.
2175+
* */
21742176
String[] expValues =
21752177
new String[] {
21762178
Double.toString(0.0), // must be cast to -> "0.0"
21772179
Double.toString(-0.0), // must be cast to -> "-0.0"
21782180
Double.toString(1.0), // must be cast to -> "1.0"
21792181
Double.toString(0.001), // must be cast to -> "0.001"
21802182
Double.toString(0.0009), // must be cast to -> "9E-4"
2183+
Double.toString(0.00099893), // must be cast to -> "9E-4"
21812184
Double.toString(999999.9999), // must be cast to -> "999999.9999"
21822185
Double.toString(10000000.0), // must be cast to 1E7
2186+
Double.toString(23943410000000.343434),
21832187
"",
21842188
Double.toString(23.45),
21852189
Double.toString(-23.45)

0 commit comments

Comments
 (0)