Skip to content

Commit

Permalink
update annotations
Browse files Browse the repository at this point in the history
  • Loading branch information
llama90 committed Jun 16, 2024
1 parent 8377b66 commit a03b0b8
Show file tree
Hide file tree
Showing 11 changed files with 86 additions and 71 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,8 @@
import org.apache.arrow.vector.types.FloatingPointPrecision;
import org.apache.arrow.vector.types.pojo.ArrowType;
import org.apache.arrow.vector.types.pojo.Schema;
import org.junit.After;
import org.junit.Before;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach;

class BaseEvaluatorTest {

Expand Down Expand Up @@ -185,7 +185,7 @@ public void writeData(ArrowBuf buffer) {
protected ArrowType int64;
protected ArrowType float64;

@Before
@BeforeEach
public void init() {
allocator = new RootAllocator(Long.MAX_VALUE);
boolType = new ArrowType.Bool();
Expand All @@ -195,7 +195,7 @@ public void init() {
float64 = new ArrowType.FloatingPoint(FloatingPointPrecision.DOUBLE);
}

@After
@AfterEach
public void tearDown() {
allocator.close();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
import static org.junit.jupiter.api.Assertions.assertTrue;

import org.apache.arrow.vector.types.pojo.ArrowType;
import org.junit.Test;
import org.junit.jupiter.api.Test;

public class DecimalTypeUtilTest {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
import java.util.Set;
import org.apache.arrow.gandiva.exceptions.GandivaException;
import org.apache.arrow.vector.types.pojo.ArrowType;
import org.junit.Test;
import org.junit.jupiter.api.Test;

public class ExpressionRegistryTest {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
import org.apache.arrow.vector.ipc.message.ArrowRecordBatch;
import org.apache.arrow.vector.types.pojo.Field;
import org.apache.arrow.vector.types.pojo.Schema;
import org.junit.Test;
import org.junit.jupiter.api.Test;

public class FilterProjectTest extends BaseEvaluatorTest {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
import org.apache.arrow.vector.types.pojo.ArrowType;
import org.apache.arrow.vector.types.pojo.Field;
import org.apache.arrow.vector.types.pojo.Schema;
import org.junit.Test;
import org.junit.jupiter.api.Test;

public class FilterTest extends BaseEvaluatorTest {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,10 @@
import org.apache.arrow.gandiva.expression.TreeNode;
import org.apache.arrow.vector.types.pojo.Field;
import org.apache.arrow.vector.types.pojo.Schema;
import org.junit.Ignore;
import org.junit.Test;
import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.Test;

@Ignore
@Disabled
public class MicroBenchmarkTest extends BaseEvaluatorTest {

private double toleranceRatio = 4.0;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@

import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertThrows;
import static org.junit.jupiter.api.Assertions.assertTrue;

import com.google.common.collect.Lists;
Expand All @@ -41,12 +42,9 @@
import org.apache.arrow.vector.types.pojo.ArrowType.Decimal;
import org.apache.arrow.vector.types.pojo.Field;
import org.apache.arrow.vector.types.pojo.Schema;
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.ExpectedException;
import org.junit.jupiter.api.Test;

public class ProjectorDecimalTest extends org.apache.arrow.gandiva.evaluator.BaseEvaluatorTest {
@Rule public ExpectedException exception = ExpectedException.none();

@Test
public void test_add() throws GandivaException {
Expand Down Expand Up @@ -843,39 +841,49 @@ public void testCastStringToDecimal() throws GandivaException {

@Test
public void testInvalidDecimal() throws GandivaException {
exception.expect(IllegalArgumentException.class);
exception.expectMessage(
"Gandiva only supports decimals of upto 38 precision. Input precision" + " : 0");
Decimal decimalType = new Decimal(0, 0, 128);
Field int64f = Field.nullable("int64", int64);

Schema schema = new Schema(Lists.newArrayList(int64f));
Projector eval =
Projector.make(
schema,
Lists.newArrayList(
TreeBuilder.makeExpression(
"castDECIMAL",
Lists.newArrayList(int64f),
Field.nullable("invalid_dec", decimalType))));
IllegalArgumentException exception =
assertThrows(
IllegalArgumentException.class,
() -> {
Decimal decimalType = new Decimal(0, 0, 128);
Field int64f = Field.nullable("int64", int64);

Schema schema = new Schema(Lists.newArrayList(int64f));
Projector eval =
Projector.make(
schema,
Lists.newArrayList(
TreeBuilder.makeExpression(
"castDECIMAL",
Lists.newArrayList(int64f),
Field.nullable("invalid_dec", decimalType))));
});
assertEquals(
"Gandiva only supports decimals of upto 38 precision. Input precision : 0",
exception.getMessage());
}

@Test
public void testInvalidDecimalGt38() throws GandivaException {
exception.expect(IllegalArgumentException.class);
exception.expectMessage(
"Gandiva only supports decimals of upto 38 precision. Input precision" + " : 42");
Decimal decimalType = new Decimal(42, 0, 128);
Field int64f = Field.nullable("int64", int64);

Schema schema = new Schema(Lists.newArrayList(int64f));
Projector eval =
Projector.make(
schema,
Lists.newArrayList(
TreeBuilder.makeExpression(
"castDECIMAL",
Lists.newArrayList(int64f),
Field.nullable("invalid_dec", decimalType))));
IllegalArgumentException exception =
assertThrows(
IllegalArgumentException.class,
() -> {
Decimal decimalType = new Decimal(42, 0, 128);
Field int64f = Field.nullable("int64", int64);

Schema schema = new Schema(Lists.newArrayList(int64f));
Projector eval =
Projector.make(
schema,
Lists.newArrayList(
TreeBuilder.makeExpression(
"castDECIMAL",
Lists.newArrayList(int64f),
Field.nullable("invalid_dec", decimalType))));
});
assertEquals(
"Gandiva only supports decimals of upto 38 precision. Input precision : 42",
exception.getMessage());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertNotEquals;
import static org.junit.jupiter.api.Assertions.assertThrows;
import static org.junit.jupiter.api.Assertions.assertTrue;

import com.google.common.collect.Lists;
Expand Down Expand Up @@ -58,18 +59,14 @@
import org.apache.arrow.vector.types.pojo.ArrowType;
import org.apache.arrow.vector.types.pojo.Field;
import org.apache.arrow.vector.types.pojo.Schema;
import org.junit.Ignore;
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.ExpectedException;
import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.Test;

public class ProjectorTest extends BaseEvaluatorTest {

private Charset utf8Charset = Charset.forName("UTF-8");
private Charset utf16Charset = Charset.forName("UTF-16");

@Rule public ExpectedException thrown = ExpectedException.none();

List<ArrowBuf> varBufs(String[] strings, Charset charset) {
ArrowBuf offsetsBuffer = allocator.buffer((strings.length + 1) * 4);

Expand Down Expand Up @@ -160,7 +157,7 @@ public void testMakeProjectorParallel() throws Exception {
}

// Will be fixed by https://issues.apache.org/jira/browse/ARROW-4371
@Ignore
@Disabled
@Test
public void testMakeProjector() throws GandivaException {
Field a = Field.nullable("a", int64);
Expand Down Expand Up @@ -2146,7 +2143,7 @@ public void testCastInt() throws Exception {
releaseValueVectors(output);
}

@Test(expected = GandivaException.class)
@Test
public void testCastIntInvalidValue() throws Exception {
Field inField = Field.nullable("input", new ArrowType.Utf8());
TreeNode inNode = TreeBuilder.makeField(inField);
Expand All @@ -2173,13 +2170,18 @@ public void testCastIntInvalidValue() throws Exception {
intVector.allocateNew(numRows);
output.add(intVector);
}
try {
eval.evaluate(batch, output);
} finally {
eval.close();
releaseRecordBatch(batch);
releaseValueVectors(output);
}

assertThrows(
GandivaException.class,
() -> {
try {
eval.evaluate(batch, output);
} finally {
eval.close();
releaseRecordBatch(batch);
releaseValueVectors(output);
}
});
}

@Test
Expand Down Expand Up @@ -2266,7 +2268,7 @@ public void testCastFloatVarbinary() throws Exception {
releaseValueVectors(output);
}

@Test(expected = GandivaException.class)
@Test
public void testCastFloatInvalidValue() throws Exception {
Field inField = Field.nullable("input", new ArrowType.Utf8());
TreeNode inNode = TreeBuilder.makeField(inField);
Expand Down Expand Up @@ -2294,13 +2296,18 @@ public void testCastFloatInvalidValue() throws Exception {
float8Vector.allocateNew(numRows);
output.add(float8Vector);
}
try {
eval.evaluate(batch, output);
} finally {
eval.close();
releaseRecordBatch(batch);
releaseValueVectors(output);
}

assertThrows(
GandivaException.class,
() -> {
try {
eval.evaluate(batch, output);
} finally {
eval.close();
releaseRecordBatch(batch);
releaseValueVectors(output);
}
});
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
import static org.junit.jupiter.api.Assertions.assertNotEquals;
import static org.junit.jupiter.api.Assertions.assertTrue;

import org.junit.Test;
import org.junit.jupiter.api.Test;

public class TestJniLoader {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
import org.apache.arrow.vector.types.pojo.ArrowType;
import org.apache.arrow.vector.types.pojo.Field;
import org.apache.arrow.vector.types.pojo.Schema;
import org.junit.Test;
import org.junit.jupiter.api.Test;

public class ArrowTypeHelperTest {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
import org.apache.arrow.vector.types.FloatingPointPrecision;
import org.apache.arrow.vector.types.pojo.ArrowType;
import org.apache.arrow.vector.types.pojo.Field;
import org.junit.Test;
import org.junit.jupiter.api.Test;

public class TreeBuilderTest {

Expand Down

0 comments on commit a03b0b8

Please sign in to comment.