return TypeDescription.createShort(); case INT: return TypeDescription.createInt(); case LONG: return TypeDescription.createLong();
return TypeDescription.createShort(); case INT: return TypeDescription.createInt(); case LONG: return TypeDescription.createLong();
/** * @param typeDescr * @return ORC types for the ACID event based on the row's type description */ public static TypeDescription createEventSchema(TypeDescription typeDescr) { TypeDescription result = TypeDescription.createStruct() .addField("operation", TypeDescription.createInt()) .addField("originalTransaction", TypeDescription.createLong()) .addField("bucket", TypeDescription.createInt()) .addField("rowId", TypeDescription.createLong()) .addField("currentTransaction", TypeDescription.createLong()) .addField("row", typeDescr.clone()); return result; }
private static TypeDescription getSchema(Schema schema) { TypeDescription result = TypeDescription.createStruct(); for (String col : schema.getColumnNames()) { ColumnDescription cd = schema.getDescription(col); TypeDescription current; switch (cd.kind) { case None: default: throw new RuntimeException("Unexpected data type " + cd.kind); case String: case Json: current = TypeDescription.createString(); break; case Date: current = TypeDescription.createTimestamp(); break; case Integer: current = TypeDescription.createInt(); break; case Duration: case Double: current = TypeDescription.createDouble(); break; } result.addField(col, current); } return result; }
private static TypeDescription convertType(final DataType fieldType) { if (fieldType instanceof BooleanType) { return TypeDescription.createBoolean(); } else if (fieldType instanceof ByteType) { return TypeDescription.createByte(); } else if (fieldType instanceof ShortType) { return TypeDescription.createShort(); } else if (fieldType instanceof IntType) { return TypeDescription.createInt(); } else if (fieldType instanceof LongType) { return TypeDescription.createLong(); } else if (fieldType instanceof FloatType) { return TypeDescription.createFloat(); } else if (fieldType instanceof DoubleType) { return TypeDescription.createDouble(); } else if (fieldType instanceof StringType || fieldType instanceof ByteArrayType) { return TypeDescription.createString(); } else if (fieldType instanceof DateType) { return TypeDescription.createDate(); } else if (fieldType instanceof TimestampType) { return TypeDescription.createTimestamp(); } else if (fieldType instanceof DecimalType) { int precision = ((DecimalType) fieldType).precision(); int scale = ((DecimalType) fieldType).scale(); return TypeDescription.createDecimal().withPrecision(precision).withScale(scale); } else { throw new UnsupportedOperationException("Unsupported category: " + fieldType); } } }
return TypeDescription.createShort(); case INTEGER: return TypeDescription.createInt(); case BIGINT: return TypeDescription.createLong();
case INT4: case INET4: return TypeDescription.createInt(); case INT8: return TypeDescription.createLong();
return TypeDescription.createShort(); case INT4: return TypeDescription.createInt(); case INT8: return TypeDescription.createLong();
return TypeDescription.createShort(); case INT: return TypeDescription.createInt(); case LONG: return TypeDescription.createLong();