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(); } }
private InvalidAccessException newInvalidAccessException(String name) { return new InvalidAccessException( String.format( "Requesting value of type %s for an object of type %s:%s is not allowed.", name, getType().getMinorType().name(), getType().getMode().name())); } }
@Override public void init(OutputMutator output) throws SchemaChangeException { // MaterializedField mf = MajorTypeHelper.getFieldForNameAndMajorType(field.getName(), type); org.apache.arrow.vector.types.pojo.Field mf = new org.apache.arrow.vector.types.pojo.Field(field.getName(), true, getArrowMinorType(type.getMinorType()).getType(), null); @SuppressWarnings("unchecked") Class<V> valueVectorClass = (Class<V>) TypeHelper.getValueVectorClass(getArrowMinorType(type.getMinorType())); this.vector = output.addField(mf, valueVectorClass); }
public static boolean isStringScalarType(final MajorType type) { if (type.getMode() == REPEATED) { return false; } switch(type.getMinorType()) { case FIXEDCHAR: case FIXED16CHAR: case VARCHAR: case VAR16CHAR: return true; default: return false; } }
public static boolean isFixedWidthType(final MajorType type) { return isFixedWidthType(type.getMinorType()); }
public static boolean isUnion(MajorType toType) { return toType.getMinorType() == MinorType.UNION; }
@Test public void test() throws Exception { ElasticsearchCluster.ColumnData[] data = new ElasticsearchCluster.ColumnData[]{ new ElasticsearchCluster.ColumnData("column", TEXT, new Object[][]{ {"value"} }) }; elastic.load(schema, table, data); List<QueryDataBatch> results = testSqlWithResults(String.format("select * from elasticsearch.%s.%s limit 0", schema, table)); MajorType t = results.get(0).getHeader().getDef().getField(0).getMajorType(); Assert.assertEquals("Mismatched type", MinorType.VARCHAR, t.getMinorType()); Assert.assertEquals("Mismatched datamode", DataMode.OPTIONAL, t.getMode()); } }
public static boolean isDecimalType(TypeProtos.MajorType type) { return isDecimalType(type.getMinorType()); }
public static boolean isLateBind(final MajorType type) { return type.getMinorType() == MinorType.LATE; }
private PrimitiveType getPrimitiveType(Field field) { MajorType majorType = getMajorTypeForField(field); MinorType minorType = majorType.getMinorType(); String name = field.getName(); PrimitiveTypeName primitiveTypeName = ParquetTypeHelper.getPrimitiveTypeNameForMinorType(minorType); if (primitiveTypeName == null) { return null; } OriginalType originalType = ParquetTypeHelper.getOriginalTypeForMinorType(minorType); int length = ParquetTypeHelper.getLengthForMinorType(minorType); DecimalMetadata decimalMetadata = ParquetTypeHelper.getDecimalMetadataForField(majorType); return new PrimitiveType(OPTIONAL, primitiveTypeName, length, name, originalType, decimalMetadata, null); }
public static DecimalMetadata getDecimalMetadataForField(MajorType type) { switch(type.getMinorType()) { case DECIMAL: case DECIMAL9: case DECIMAL18: case DECIMAL28SPARSE: case DECIMAL28DENSE: case DECIMAL38SPARSE: case DECIMAL38DENSE: return new DecimalMetadata(type.getPrecision(), type.getScale()); default: return null; } }
public static MajorType overrideMode(final MajorType originalMajorType, final DataMode overrideMode) { return withScaleAndPrecision(originalMajorType.getMinorType(), overrideMode, originalMajorType.getScale(), originalMajorType.getPrecision()); }
@Override public CompleteType getCompleteType() { return CompleteType.fromMinorType(type.getMinorType()); }
private int getEstimatedRecordSize(MockColumn[] types) { int x = 0; for (int i = 0; i < types.length; i++) { x += TypeHelper.getSize(getArrowMinorType(types[i].getMajorType().getMinorType())); } return x; }
protected RelDataType getReturnDataType(final RelDataTypeFactory factory) { if (MinorType.BIT.equals(returnType.getMinorType())) { return factory.createSqlType(SqlTypeName.BOOLEAN); } return factory.createTypeWithNullability(factory.createSqlType(SqlTypeName.ANY), true); }
private VarBinaryVector getOrCreateColumnVector(StructVector sv, String qualifier) { int oldSize = sv.size(); VarBinaryVector v = sv.addOrGet(qualifier, FieldType.nullable(getArrowMinorType(COLUMN_TYPE.getMinorType()).getType()), VarBinaryVector.class); if (oldSize != sv.size()) { v.allocateNew(); } return v; }
public static boolean isBytesScalarType(final MajorType type) { if (type.getMode() == REPEATED) { return false; } switch(type.getMinorType()) { case FIXEDSIZEBINARY: case VARBINARY: return true; default: return false; } }
public static boolean isComplex(final MajorType type) { switch(type.getMinorType()) { case LIST: case STRUCT: return true; } return false; }
public <T extends ValueVector> T addOrGet(String name, MajorType type, Class<T> clazz) { Field field = new Field(name, true, getArrowMinorType(type.getMinorType()).getType(), null); return addOrGet(field); }
public static ArrowType getArrowTypeForMajorType(MajorType majorType) { if (majorType.getMinorType() == TypeProtos.MinorType.DECIMAL) { return new Decimal(majorType.getPrecision(), majorType.getScale()); } return getArrowMinorType(majorType.getMinorType()).getType(); }