Java Code Examples for org.apache.orc.TypeDescription#createByte()
The following examples show how to use
org.apache.orc.TypeDescription#createByte() .
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: OrcUtils.java From tajo with Apache License 2.0 | 5 votes |
public static TypeDescription convertTypeInfo(TypeDesc desc) { switch (desc.getDataType().getType()) { case BOOLEAN: return TypeDescription.createBoolean(); case BIT: return TypeDescription.createByte(); case INT2: return TypeDescription.createShort(); case INT4: return TypeDescription.createInt(); case INT8: return TypeDescription.createLong(); case FLOAT4: return TypeDescription.createFloat(); case FLOAT8: return TypeDescription.createDouble(); case TEXT: return TypeDescription.createString(); case DATE: return TypeDescription.createDate(); case TIMESTAMP: return TypeDescription.createTimestamp(); case BLOB: return TypeDescription.createBinary(); case CHAR: return TypeDescription.createChar() .withMaxLength(desc.getDataType().getLength()); case RECORD: { TypeDescription result = TypeDescription.createStruct(); for (Column eachColumn : desc.getNestedSchema().getRootColumns()) { result.addField(eachColumn.getQualifiedName(), convertTypeInfo(eachColumn.getTypeDesc())); } return result; } default: throw new TajoRuntimeException(new UnsupportedDataTypeException(desc.getDataType().getType().name())); } }
Example 2
Source File: OrcSchemaConverter.java From pentaho-hadoop-shims with Apache License 2.0 | 5 votes |
private TypeDescription determineOrcType( OrcSpec.DataType dataType ) { switch ( dataType ) { case BOOLEAN: return TypeDescription.createBoolean(); case TINYINT: return TypeDescription.createByte(); case SMALLINT: return TypeDescription.createShort(); case INTEGER: return TypeDescription.createInt(); case BIGINT: return TypeDescription.createLong(); case DATE: return TypeDescription.createDate(); case BINARY: return TypeDescription.createBinary(); case CHAR: return TypeDescription.createChar(); case VARCHAR: return TypeDescription.createVarchar(); case STRING: return TypeDescription.createString(); case FLOAT: return TypeDescription.createFloat(); case DOUBLE: return TypeDescription.createDouble(); case DECIMAL: return TypeDescription.createDecimal(); case TIMESTAMP: return TypeDescription.createTimestamp(); default: throw new RuntimeException( "Attempted to write an unsupported Orc type: " + dataType.getName() ); } }
Example 3
Source File: OrcSplitReaderUtil.java From flink with Apache License 2.0 | 4 votes |
/** * See {@code org.apache.flink.table.catalog.hive.util.HiveTypeUtil}. */ public static TypeDescription logicalTypeToOrcType(LogicalType type) { type = type.copy(true); switch (type.getTypeRoot()) { case CHAR: return TypeDescription.createChar().withMaxLength(((CharType) type).getLength()); case VARCHAR: int len = ((VarCharType) type).getLength(); if (len == VarCharType.MAX_LENGTH) { return TypeDescription.createString(); } else { return TypeDescription.createVarchar().withMaxLength(len); } case BOOLEAN: return TypeDescription.createBoolean(); case VARBINARY: if (type.equals(DataTypes.BYTES().getLogicalType())) { return TypeDescription.createBinary(); } else { throw new UnsupportedOperationException( "Not support other binary type: " + type); } case DECIMAL: DecimalType decimalType = (DecimalType) type; return TypeDescription.createDecimal() .withScale(decimalType.getScale()) .withPrecision(decimalType.getPrecision()); case TINYINT: return TypeDescription.createByte(); case SMALLINT: return TypeDescription.createShort(); case INTEGER: return TypeDescription.createInt(); case BIGINT: return TypeDescription.createLong(); case FLOAT: return TypeDescription.createFloat(); case DOUBLE: return TypeDescription.createDouble(); case DATE: return TypeDescription.createDate(); case TIMESTAMP_WITHOUT_TIME_ZONE: return TypeDescription.createTimestamp(); case ARRAY: ArrayType arrayType = (ArrayType) type; return TypeDescription.createList(logicalTypeToOrcType(arrayType.getElementType())); case MAP: MapType mapType = (MapType) type; return TypeDescription.createMap( logicalTypeToOrcType(mapType.getKeyType()), logicalTypeToOrcType(mapType.getValueType())); case ROW: RowType rowType = (RowType) type; TypeDescription struct = TypeDescription.createStruct(); for (int i = 0; i < rowType.getFieldCount(); i++) { struct.addField( rowType.getFieldNames().get(i), logicalTypeToOrcType(rowType.getChildren().get(i))); } return struct; default: throw new UnsupportedOperationException("Unsupported type: " + type); } }