switch (primitiveTypeInfo.getPrimitiveCategory()) { case BOOLEAN: return Field.nullable(name, MinorType.BIT.getType()); case BYTE: return Field.nullable(name, MinorType.TINYINT.getType()); case SHORT: return Field.nullable(name, MinorType.SMALLINT.getType()); case INT: return Field.nullable(name, MinorType.INT.getType()); case LONG: return Field.nullable(name, MinorType.BIGINT.getType()); case FLOAT: return Field.nullable(name, MinorType.FLOAT4.getType()); case DOUBLE: return Field.nullable(name, MinorType.FLOAT8.getType()); case STRING: case VARCHAR: case CHAR: return Field.nullable(name, MinorType.VARCHAR.getType()); case DATE: return Field.nullable(name, MinorType.DATEDAY.getType()); case TIMESTAMP: return Field.nullable(name, MinorType.TIMESTAMPMILLI.getType()); case TIMESTAMPLOCALTZ: final TimestampLocalTZTypeInfo timestampLocalTZTypeInfo = (TimestampLocalTZTypeInfo) typeInfo; final String timeZone = timestampLocalTZTypeInfo.getTimeZone().toString(); return Field.nullable(name, new ArrowType.Timestamp(TimeUnit.MILLISECOND, timeZone)); case BINARY:
public static Field nullablePrimitive(String name, ArrowType.PrimitiveType type) { return nullable(name, type); }
public static List<Field> getChildrenForMajorType(MajorType majorType) { List<Field> children = new ArrayList<>(); switch (majorType.getMinorType()) { case UNION: for (TypeProtos.MinorType minorType : majorType.getSubTypeList()) { children.add(Field.nullable("", getArrowMinorType(minorType).getType())); } return children; default: return Collections.emptyList(); } }
/** Helper method which creates a union vector with no data */ private static UnionVector testEmptyUnionVector() { final UnionVector unionVector = new UnionVector("unionVector", ALLOCATOR, null); unionVector.initializeChildrenFromFields( asList( Field.nullable("intType", new ArrowType.Int(32, true)), Field.nullable("decimalType", new ArrowType.Decimal(4, 10)) ) ); return unionVector; }
@Test public void selectionIgnoresIncremental() { BatchSchema schema = mock(BatchSchema.class); when(schema.iterator()) .thenReturn(Lists.newArrayList(Field.nullable("a1", new ArrowType.Bool()), Field.nullable(IncrementalUpdateUtils.UPDATE_COLUMN, new ArrowType.Bool())).iterator()); assertTrue(EasyScanOperatorCreator.selectsAllColumns(schema, Lists.<SchemaPath>newArrayList(SchemaPath.getSimplePath("a1")))); }
@Test public void falseWhenAllColumnsAreNotSelected() { BatchSchema schema = mock(BatchSchema.class); when(schema.iterator()) .thenReturn(Lists.newArrayList(Field.nullable("a1", new ArrowType.Bool()), Field.nullable("a2", new ArrowType.Bool())).iterator()); assertFalse(EasyScanOperatorCreator.selectsAllColumns(schema, Lists.<SchemaPath>newArrayList(SchemaPath.getSimplePath("a1")))); }
@Test public void trueWhenAllColumnsAreSelected() { BatchSchema schema = mock(BatchSchema.class); when(schema.iterator()) .thenReturn(Lists.newArrayList(Field.nullable("a1", new ArrowType.Bool())).iterator()); assertTrue(EasyScanOperatorCreator.selectsAllColumns(schema, Lists.<SchemaPath>newArrayList(SchemaPath.getSimplePath("a1")))); }
@Test public void falseWhenChildrenAreSelected() { BatchSchema schema = mock(BatchSchema.class); when(schema.iterator()) .thenReturn(Lists.newArrayList( new Field("a1", new FieldType(true, new ArrowType.Struct(), null), Lists.newArrayList(Field.nullable("a2", new ArrowType.Bool()))), Field.nullable("a3", new ArrowType.Bool())).iterator()); assertFalse(EasyScanOperatorCreator.selectsAllColumns(schema, Lists.newArrayList(SchemaPath.getSimplePath("a1"), SchemaPath.getCompoundPath("a1", "a2"), SchemaPath.getSimplePath("a3")))); }