Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion gandiva/src/main/cpp/expression_registry_helper.cc
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ void ArrowToProtobuf(DataTypePtr type, gandiva::types::ExtGandivaType* gandiva_d
break;
}
case arrow::Type::TIME64: {
gandiva_data_type->set_type(gandiva::types::GandivaType::TIME32);
gandiva_data_type->set_type(gandiva::types::GandivaType::TIME64);
std::shared_ptr<arrow::Time64Type> cast_time_64_type =
std::dynamic_pointer_cast<arrow::Time64Type>(type);
arrow::TimeUnit::type unit = cast_time_64_type->unit();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,13 @@
*/
package org.apache.arrow.gandiva.evaluator;

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

import com.google.common.collect.Lists;
import java.util.Set;
import org.apache.arrow.gandiva.exceptions.GandivaException;
import org.apache.arrow.vector.types.TimeUnit;
import org.apache.arrow.vector.types.pojo.ArrowType;
import org.junit.jupiter.api.Test;

Expand All @@ -33,6 +35,36 @@ public void testTypes() throws GandivaException {
assertTrue(types.contains(uint8));
}

@Test
public void testTimeTypesKeepBitWidth() throws GandivaException {
Set<ArrowType> types = ExpressionRegistry.getInstance().getSupportedTypes();
assertTrue(types.contains(new ArrowType.Time(TimeUnit.SECOND, 32)));
assertTrue(types.contains(new ArrowType.Time(TimeUnit.MILLISECOND, 32)));
assertTrue(types.contains(new ArrowType.Time(TimeUnit.MICROSECOND, 64)));
assertTrue(types.contains(new ArrowType.Time(TimeUnit.NANOSECOND, 64)));
// Time64 units used to be reported with a 32-bit width.
assertFalse(types.contains(new ArrowType.Time(TimeUnit.MICROSECOND, 32)));
assertFalse(types.contains(new ArrowType.Time(TimeUnit.NANOSECOND, 32)));
}

@Test
public void testTime64Functions() throws GandivaException {
// Time64 signatures are registered with MICROSECOND; NANOSECOND arguments match the
// same signature in Gandiva and are remapped at codegen time.
ArrowType.Time timeMicro = new ArrowType.Time(TimeUnit.MICROSECOND, 64);
ArrowType.Int int64 = new ArrowType.Int(64, true);
ArrowType.Bool bool = new ArrowType.Bool();
Set<FunctionSignature> functions = ExpressionRegistry.getInstance().getSupportedFunctions();
assertTrue(
functions.contains(
new FunctionSignature("extractHour", int64, Lists.newArrayList(timeMicro))));
assertTrue(
functions.contains(
new FunctionSignature("less_than", bool, Lists.newArrayList(timeMicro, timeMicro))));
assertTrue(
functions.contains(new FunctionSignature("isnull", bool, Lists.newArrayList(timeMicro))));
}

@Test
public void testFunctions() throws GandivaException {
ArrowType.Int uint8 = new ArrowType.Int(8, false);
Expand Down
Loading