formats.add("| %-" + columnWidth + "s"); Field field = vw.getValueVector().getField(); columns.add(field.getName() + "<" + getMajorTypeForField(field).getMinorType() + "(" + getMajorTypeForField(field).getMode() + ")" + ">"); columnIndex++;
@Override public void patch(SerializedField.Builder field, ByteBuf[] buffers, int bufferStart, int buffersLength, String parentName, String indent) { DataMode mode = field.getMajorType().getMode(); MinorType minor = field.getMajorType().getMinorType(); String name = field.getNamePart().getName(); final ArrowBuf decimalBuffer = (ArrowBuf)buffers[bufferStart + decimalBufferIndex]; if (decimalField.getMajorType().getMinorType() != DECIMAL || decimalField.getMajorType().getMode() != REQUIRED) { throw new IllegalStateException("Found incorrect decimal field: " + field.build());
public static MajorType overrideMinorType(final MajorType originalMajorType, final MinorType overrideMinorType) { switch (originalMajorType.getMode()) { case REPEATED: return repeated(overrideMinorType); case OPTIONAL: return optional(overrideMinorType); case REQUIRED: return required(overrideMinorType); default: throw new UnsupportedOperationException(); } }
if (type.getMode() == DataMode.REPEATED || type.getMinorType() == MinorType.LIST) { return "ARRAY";
public static int getJdbcDisplaySize(MajorType type) { if (type.getMode() == DataMode.REPEATED || type.getMinorType() == MinorType.LIST) { return 0;
setMode(other.getMode());
assert nullHandling != NullHandling.INTERNAL || returnValue.getOldType().getMode() == TypeProtos.DataMode.OPTIONAL : "Function [" + initializer.getClassName() + "] with INTERNAL null handling should use a Nullable output";
public static boolean isNumericType(final MajorType type) { if (type.getMode() == REPEATED) { return false; } switch(type.getMinorType()) { case BIGINT: case DECIMAL38SPARSE: case DECIMAL38DENSE: case DECIMAL28SPARSE: case DECIMAL28DENSE: case DECIMAL18: case DECIMAL9: case DECIMAL: case FLOAT4: case FLOAT8: case INT: case MONEY: case SMALLINT: case TINYINT: case UINT1: case UINT2: case UINT4: case UINT8: return true; default: return false; } }
public static boolean usesHolderForGet(final MajorType type) { if (type.getMode() == REPEATED) { return true; } switch(type.getMinorType()) { case BIGINT: case FLOAT4: case FLOAT8: case INT: case MONEY: case SMALLINT: case TINYINT: case UINT1: case UINT2: case UINT4: case UINT8: case INTERVALYEAR: case DATE: case TIME: case TIMESTAMP: return false; default: return true; } }
public static MajorTypeHolder get(MajorType mt) { MajorTypeHolder h = new MajorTypeHolder(); h.minorType = mt.getMinorType(); h.mode = mt.getMode(); if (mt.hasPrecision()) { h.precision = mt.getPrecision(); } if (mt.hasScale()) { h.scale = mt.getScale(); } if (mt.hasWidth()) { h.width = mt.getWidth(); } return h; } }
public static Comparability getComparability(final MajorType type) { if (type.getMode() == REPEATED) { return Comparability.NONE; } if (type.getMinorType() == MinorType.LATE) { return Comparability.UNKNOWN; } switch(type.getMinorType()) { case LATE: return Comparability.UNKNOWN; case STRUCT: return Comparability.NONE; case BIT: return Comparability.EQUAL; default: return Comparability.ORDERED; } }
public void writeTo(io.protostuff.Output output, com.dremio.common.types.TypeProtos.MajorType message) throws java.io.IOException { if(message.hasMinorType()) output.writeEnum(1, message.getMinorType().getNumber(), false); if(message.hasMode()) output.writeEnum(2, message.getMode().getNumber(), false); if(message.hasWidth()) output.writeInt32(3, message.getWidth(), false); if(message.hasPrecision()) output.writeInt32(4, message.getPrecision(), false); if(message.hasScale()) output.writeInt32(5, message.getScale(), false); if(message.hasTimeZone()) output.writeInt32(6, message.getTimeZone(), false); for(com.dremio.common.types.TypeProtos.MinorType subType : message.getSubTypeList()) output.writeEnum(7, subType.getNumber(), true); } public boolean isInitialized(com.dremio.common.types.TypeProtos.MajorType message)
public static boolean softEquals(final MajorType a, final MajorType b, final boolean allowNullSwap) { if (a.getMinorType() != b.getMinorType()) { return false; } if(allowNullSwap) { switch (a.getMode()) { case OPTIONAL: case REQUIRED: switch (b.getMode()) { case OPTIONAL: case REQUIRED: return true; } } } return a.getMode() == b.getMode(); }
@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 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 isRepeated(final MajorType type) { return type.getMode() == REPEATED ; }
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; } }
private void checkResult(RecordBatchLoader loader, List<QueryDataBatch> results) { loader.load(results.get(0).getHeader().getDef(), results.get(0).getData()); RecordBatchDef def = results.get(0).getHeader().getDef(); // the entire row is returned as a single column assertEquals(1, def.getFieldCount()); assertTrue(def.getField(0).getMajorType().getMode() == DataMode.OPTIONAL); loader.clear(); for(QueryDataBatch result : results) { result.release(); } client.close(); }
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())); } }