org.apache.arrow.vector.types.pojo.ArrowType.Int Java Examples
The following examples show how to use
org.apache.arrow.vector.types.pojo.ArrowType.Int.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: CompleteType.java From dremio-oss with Apache License 2.0 | 6 votes |
/** * Convert arrow type to the arrow type supported by dremio * @param arrowType original arrow type * @return the arrow type supported by dremio */ private static ArrowType convertToSupportedArrowType(ArrowType arrowType) { switch (arrowType.getTypeID()) { case Int: ArrowType.Int arrowInt = (ArrowType.Int)arrowType; return (arrowInt.getBitWidth() < 32) ? CompleteType.INT.getType() : arrowType; case Date: // We don't support DateDay, so we should convert it to DataMilli. return CompleteType.DATE.getType(); case Timestamp: // We always treat timezone as null. return CompleteType.TIMESTAMP.getType(); default: return arrowType; } }
Example #2
Source File: CompleteType.java From dremio-oss with Apache License 2.0 | 5 votes |
public boolean isNumeric() { switch(type.getTypeID()){ case Decimal: case FloatingPoint: case Int: return true; default: return false; } }
Example #3
Source File: SqlDisplaySizeVisitor.java From dremio-oss with Apache License 2.0 | 5 votes |
@Override public Integer visit(Int paramInt) { switch(paramInt.getBitWidth()){ case 8: return 4; // sign + 3 digit case 16: return 6; // sign + 5 digits case 32: return 11; // sign + 10 digits case 64: return 20; // sign + 19 digits } throw new IllegalStateException("Unknown int width " + paramInt.getBitWidth()); }
Example #4
Source File: SqlTypeNameVisitor.java From dremio-oss with Apache License 2.0 | 5 votes |
@Override public String visit(Int paramInt) { switch(paramInt.getBitWidth()){ case 8: return "TINYINT"; case 16: return "SMALLINT"; case 32: return "INTEGER"; case 64: return "BIGINT"; default: throw new IllegalStateException("unable to report sql type for integer of width " + paramInt.getBitWidth()); } }
Example #5
Source File: AbstractTestNamespaceService.java From dremio-oss with Apache License 2.0 | 5 votes |
@Test public void testDataSetSchema() throws Exception { Field field1 = new Field("a", true, new Int(32, true), null); Field child1 = new Field("c", true, Utf8.INSTANCE, null); Field field2 = new Field("b", true, Struct.INSTANCE, ImmutableList.of(child1)); Schema schema = new Schema(ImmutableList.of(field1, field2)); FlatBufferBuilder builder = new FlatBufferBuilder(); schema.getSchema(builder); builder.finish(schema.getSchema(builder)); NamespaceTestUtils.addSource(namespaceService, "s"); NamespaceTestUtils.addPhysicalDS(namespaceService, "s.foo", builder.sizedByteArray()); ByteBuffer bb = ByteBuffer.wrap(DatasetHelper.getSchemaBytes(namespaceService.getDataset(new NamespaceKey(PathUtils.parseFullPath("s.foo")))).toByteArray()); Schema returnedSchema = Schema.convertSchema(org.apache.arrow.flatbuf.Schema.getRootAsSchema(bb)); assertEquals(schema, returnedSchema); }
Example #6
Source File: SqlTypeNameToArrowType.java From dremio-flight-connector with Apache License 2.0 | 4 votes |
public static ArrowType toArrowType(UserProtos.ResultColumnMetadata type) { String typeName = type.getDataType(); switch (typeName) { case "NULL": return new Null(); case "MAP": return new ArrowType.Map(false); //todo inner type? case "ARRAY": return new ArrowType.List(); //todo inner type? case "UNION": throw new UnsupportedOperationException("have not implemented unions"); //return new Union(); //todo inner type? case "TINYINT": return new Int(8, true); case "SMALLINT": return new Int(16, true); case "INTEGER": return new Int(32, true); case "BIGINT": return new Int(64, true); case "FLOAT": return new FloatingPoint(FloatingPointPrecision.SINGLE); case "DOUBLE": return new FloatingPoint(FloatingPointPrecision.DOUBLE); case "CHARACTER VARYING": return new Utf8(); case "BINARY VARYING": return new Binary(); case "BOOLEAN": return new Bool(); case "DECIMAL": return new Decimal(type.getPrecision(), type.getScale()); case "DATE": return new Date(DateUnit.MILLISECOND); case "TIME": return new Time(TimeUnit.MICROSECOND, 64); case "TIMESTAMP": return new Timestamp(TimeUnit.MICROSECOND, "UTC"); case "INTERVAL DAY TO SECOND": return new Interval(IntervalUnit.DAY_TIME); case "INTERVAL YEAR TO MONTH": return new Interval(IntervalUnit.YEAR_MONTH); case "BINARY": return new ArrowType.FixedSizeBinary(50); default: throw new IllegalStateException("unable to find arrow type for " + typeName); } }
Example #7
Source File: AbstractArrowTypeVisitor.java From dremio-oss with Apache License 2.0 | 4 votes |
@Override public T visit(Int type) { return visitGeneric(type); }
Example #8
Source File: Describer.java From dremio-oss with Apache License 2.0 | 4 votes |
@Override public String visit(Int type) { return (type.getIsSigned() ? "" : "u") + "int" + type.getBitWidth(); }
Example #9
Source File: HiveSchemaConverter.java From dremio-oss with Apache License 2.0 | 4 votes |
public static Field getArrowFieldFromHivePrimitiveType(String name, TypeInfo typeInfo) { switch (typeInfo.getCategory()) { case PRIMITIVE: PrimitiveTypeInfo pTypeInfo = (PrimitiveTypeInfo) typeInfo; switch (pTypeInfo.getPrimitiveCategory()) { case BOOLEAN: return new Field(name, true, new Bool(), null); case BYTE: return new Field(name, true, new Int(32, true), null); case SHORT: return new Field(name, true, new Int(32, true), null); case INT: return new Field(name, true, new Int(32, true), null); case LONG: return new Field(name, true, new Int(64, true), null); case FLOAT: return new Field(name, true, new FloatingPoint(FloatingPointPrecision.SINGLE), null); case DOUBLE: return new Field(name, true, new FloatingPoint(FloatingPointPrecision.DOUBLE), null); case DATE: return new Field(name, true, new Date(DateUnit.MILLISECOND), null); case TIMESTAMP: return new Field(name, true, new Timestamp(TimeUnit.MILLISECOND, null), null); case BINARY: return new Field(name, true, new Binary(), null); case DECIMAL: { DecimalTypeInfo decimalTypeInfo = (DecimalTypeInfo) pTypeInfo; return new Field(name, true, new Decimal(decimalTypeInfo.getPrecision(), decimalTypeInfo.getScale()), null); } case STRING: case VARCHAR: case CHAR: { return new Field(name, true, new Utf8(), null); } case UNKNOWN: case VOID: default: // fall through. } default: } return null; }