org.apache.arrow.vector.types.pojo.ArrowType.Interval Java Examples
The following examples show how to use
org.apache.arrow.vector.types.pojo.ArrowType.Interval.
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: SqlDisplaySizeVisitor.java From dremio-oss with Apache License 2.0 | 5 votes |
@Override public Integer visit(Interval paramInterval) { switch(paramInterval.getUnit()){ case DAY_TIME: return 0; case YEAR_MONTH: return 0; default: throw new IllegalStateException("unable to determine width for interval with unit " + paramInterval.getUnit()); } }
Example #2
Source File: SqlTypeNameVisitor.java From dremio-oss with Apache License 2.0 | 5 votes |
@Override public String visit(Interval paramInterval) { switch(paramInterval.getUnit()){ case DAY_TIME: return "INTERVAL DAY TO SECOND"; case YEAR_MONTH: return "INTERVAL YEAR TO MONTH"; default: throw new IllegalStateException("unable to determine sql type for interval with unit " + paramInterval.getUnit()); } }
Example #3
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 #4
Source File: AbstractArrowTypeVisitor.java From dremio-oss with Apache License 2.0 | 4 votes |
@Override public T visit(Interval type) { return visitGeneric(type); }
Example #5
Source File: Describer.java From dremio-oss with Apache License 2.0 | 4 votes |
@Override public String visit(Interval type) { return type.getUnit() == IntervalUnit.DAY_TIME ? "interval_day" : "interval_year"; }
Example #6
Source File: ParquetToMinorTypeConverter.java From dremio-oss with Apache License 2.0 | 4 votes |
private static TypeProtos.MinorType getMinorType(PrimitiveType.PrimitiveTypeName primitiveTypeName, int length, SchemaElement schemaElement, OptionManager options, Field arrowField, final boolean readInt96AsTimeStamp) { ConvertedType convertedType = schemaElement.getConverted_type(); switch (primitiveTypeName) { case BINARY: if (convertedType == null) { return TypeProtos.MinorType.VARBINARY; } switch (convertedType) { case UTF8: return TypeProtos.MinorType.VARCHAR; case DECIMAL: ParquetReaderUtility.checkDecimalTypeEnabled(options); return getDecimalType(schemaElement); default: return TypeProtos.MinorType.VARBINARY; } case INT64: if (convertedType == null) { return TypeProtos.MinorType.BIGINT; } switch(convertedType) { case DECIMAL: ParquetReaderUtility.checkDecimalTypeEnabled(options); return TypeProtos.MinorType.DECIMAL; // TODO - add this back if it is decided to be added upstream, was removed form our pull request July 2014 // case TIME_MICROS: // throw new UnsupportedOperationException(); case TIMESTAMP_MILLIS: return TypeProtos.MinorType.TIMESTAMP; default: throw new UnsupportedOperationException(String.format("unsupported type: %s %s", primitiveTypeName, convertedType)); } case INT32: if (convertedType == null) { return TypeProtos.MinorType.INT; } switch(convertedType) { case DECIMAL: ParquetReaderUtility.checkDecimalTypeEnabled(options); return TypeProtos.MinorType.DECIMAL; case DATE: return TypeProtos.MinorType.DATE; case TIME_MILLIS: return TypeProtos.MinorType.TIME; default: throw new UnsupportedOperationException(String.format("unsupported type: %s %s", primitiveTypeName, convertedType)); } case BOOLEAN: return TypeProtos.MinorType.BIT; case FLOAT: return TypeProtos.MinorType.FLOAT4; case DOUBLE: return TypeProtos.MinorType.FLOAT8; // TODO - Both of these are not supported by the parquet library yet (7/3/13), // but they are declared here for when they are implemented case INT96: if (readInt96AsTimeStamp) { return TypeProtos.MinorType.TIMESTAMP; } else { return TypeProtos.MinorType.VARBINARY; } case FIXED_LEN_BYTE_ARRAY: if (convertedType == null) { checkArgument(length > 0, "A length greater than zero must be provided for a FixedBinary type."); return TypeProtos.MinorType.VARBINARY; } else if (convertedType == ConvertedType.DECIMAL) { ParquetReaderUtility.checkDecimalTypeEnabled(options); return getDecimalType(schemaElement); } else if (convertedType == ConvertedType.INTERVAL) { if (arrowField != null) { if (arrowField.getType().getTypeID() == ArrowTypeID.Interval) { switch (((Interval)arrowField.getType()).getUnit()) { case DAY_TIME: return TypeProtos.MinorType.INTERVALDAY; case YEAR_MONTH: return TypeProtos.MinorType.INTERVALYEAR; } } throw new IllegalArgumentException("incompatible type " + arrowField); } // TODO: older versions of Drill generated this return TypeProtos.MinorType.VARBINARY; } default: throw new UnsupportedOperationException("Type not supported: " + primitiveTypeName); } }