DecimalMetadata meta = decimalMetadata(); return new PrimitiveType(repetition, primitiveType, length, name, logicalTypeAnnotation, id, columnOrder); } else { return new PrimitiveType(repetition, primitiveType, length, name, getOriginalType(), meta, id, columnOrder);
extends Builder<THIS, P> { private static final Logger LOGGER = LoggerFactory.getLogger(BasePrimitiveBuilder.class); private static final long MAX_PRECISION_INT32 = maxPrecision(4); private static final long MAX_PRECISION_INT64 = maxPrecision(8); private static final String LOGICAL_TYPES_DOC_URL = "https://github.com/apache/parquet-format/blob/master/LogicalTypes.md";
/** * Adds the scale for a DECIMAL. * <p> * This value must be less than the maximum precision of the type and must * be a positive number. If not set, the default scale is 0. * <p> * The scale specifies the number of digits of the underlying unscaled * that are to the right of the decimal point. The decimal interpretation * of values in this column is: {@code value*10^(-scale)}. * * @param scale an int scale value for the DECIMAL * @return this builder for method chaining * * @deprecated use {@link #as(LogicalTypeAnnotation)} with the corresponding decimal type instead */ @Deprecated public THIS scale(int scale) { this.scale = scale; scaleAlreadySet = true; return self(); }
extends Builder<THIS, P> { private static final Logger LOGGER = LoggerFactory.getLogger(BasePrimitiveBuilder.class); private static final long MAX_PRECISION_INT32 = maxPrecision(4); private static final long MAX_PRECISION_INT64 = maxPrecision(8); private static final String LOGICAL_TYPES_DOC_URL = "https://github.com/apache/parquet-format/blob/master/LogicalTypes.md";
int bytes = ParquetHiveSerDe.PRECISION_TO_BYTE_COUNT[prec - 1]; if (repetition == Repetition.OPTIONAL) { return Types.optional(PrimitiveTypeName.FIXED_LEN_BYTE_ARRAY).length(bytes).as(OriginalType.DECIMAL).scale(scale).precision(prec).named(name); return Types.repeated(PrimitiveTypeName.FIXED_LEN_BYTE_ARRAY).length(bytes).as(OriginalType.DECIMAL).scale(scale).precision(prec).named(name);
int bytes = ParquetHiveSerDe.PRECISION_TO_BYTE_COUNT[prec - 1]; if (repetition == Repetition.OPTIONAL) { return Types.optional(PrimitiveTypeName.FIXED_LEN_BYTE_ARRAY).length(bytes).as(OriginalType.DECIMAL).scale(scale).precision(prec).named(name); return Types.repeated(PrimitiveTypeName.FIXED_LEN_BYTE_ARRAY).length(bytes).as(OriginalType.DECIMAL).scale(scale).precision(prec).named(name);
int bytes = ParquetHiveSerDe.PRECISION_TO_BYTE_COUNT[prec - 1]; if (repetition == Repetition.OPTIONAL) { return Types.optional(PrimitiveTypeName.FIXED_LEN_BYTE_ARRAY).length(bytes).as(OriginalType.DECIMAL).scale(scale).precision(prec).named(name); return Types.repeated(PrimitiveTypeName.FIXED_LEN_BYTE_ARRAY).length(bytes).as(OriginalType.DECIMAL).scale(scale).precision(prec).named(name);
int bytes = ParquetHiveSerDe.PRECISION_TO_BYTE_COUNT[prec - 1]; if (repetition == Repetition.OPTIONAL) { return Types.optional(PrimitiveTypeName.FIXED_LEN_BYTE_ARRAY).length(bytes).as(OriginalType.DECIMAL).scale(scale).precision(prec).named(name); return Types.repeated(PrimitiveTypeName.FIXED_LEN_BYTE_ARRAY).length(bytes).as(OriginalType.DECIMAL).scale(scale).precision(prec).named(name);
DecimalMetadata meta = decimalMetadata(); meta.getPrecision() <= maxPrecision(length), "FIXED(" + length + ") cannot store " + meta.getPrecision() + " digits (max " + maxPrecision(length) + ")");
case DECIMAL: if ( f.getAllowNull() ) { return Types.optional( PrimitiveType.PrimitiveTypeName.BINARY ).as( OriginalType.DECIMAL ).precision( f.getPrecision() ).scale( f.getScale() ).named( formatFieldName ); } else { return Types.required( PrimitiveType.PrimitiveTypeName.BINARY ).as( OriginalType.DECIMAL ).precision( f.getPrecision() ).scale( f.getScale() ).named( formatFieldName ); return Types.optional( PrimitiveType.PrimitiveTypeName.INT32 ).as( OriginalType.DECIMAL ).precision( f.getPrecision() ).scale( f.getScale() ).named( formatFieldName ); } else { return Types.required( PrimitiveType.PrimitiveTypeName.INT32 ).as( OriginalType.DECIMAL ).precision( f.getPrecision() ).scale( f.getScale() ).named( formatFieldName ); return Types.optional( PrimitiveType.PrimitiveTypeName.INT64 ).as( OriginalType.DECIMAL ).precision( f.getPrecision() ).scale( f.getScale() ).named( formatFieldName ); } else { return Types.required( PrimitiveType.PrimitiveTypeName.INT64 ).as( OriginalType.DECIMAL ).precision( f.getPrecision() ).scale( f.getScale() ).named( formatFieldName );
/** * Adds the precision for a DECIMAL. * <p> * This value is required for decimals and must be less than or equal to * the maximum number of base-10 digits in the underlying type. A 4-byte * fixed, for example, can store up to 9 base-10 digits. * * @param precision an int precision value for the DECIMAL * @return this builder for method chaining * * @deprecated use {@link #as(LogicalTypeAnnotation)} with the corresponding decimal type instead */ @Deprecated public THIS precision(int precision) { this.precision = precision; precisionAlreadySet = true; return self(); }
/** * Adds the scale for a DECIMAL. * <p> * This value must be less than the maximum precision of the type and must * be a positive number. If not set, the default scale is 0. * <p> * The scale specifies the number of digits of the underlying unscaled * that are to the right of the decimal point. The decimal interpretation * of values in this column is: {@code value*10^(-scale)}. * * @param scale an int scale value for the DECIMAL * @return this builder for method chaining */ public THIS scale(int scale) { this.scale = scale; return self(); }
/** * Adds the column order for the primitive type. * <p> * In case of not set the default column order is {@link ColumnOrderName#TYPE_DEFINED_ORDER} except the type * {@link PrimitiveTypeName#INT96} and the types annotated by {@link OriginalType#INTERVAL} where the default column * order is {@link ColumnOrderName#UNDEFINED}. * * @param columnOrder * the column order for the primitive type * @return this builder for method chaining */ public THIS columnOrder(ColumnOrder columnOrder) { this.columnOrder = columnOrder; return self(); }
/** * Adds the column order for the primitive type. * <p> * In case of not set the default column order is {@link ColumnOrderName#TYPE_DEFINED_ORDER} except the type * {@link PrimitiveTypeName#INT96} and the types annotated by {@link OriginalType#INTERVAL} where the default column * order is {@link ColumnOrderName#UNDEFINED}. * * @param columnOrder * the column order for the primitive type * @return this builder for method chaining */ public THIS columnOrder(ColumnOrder columnOrder) { this.columnOrder = columnOrder; return self(); }
/** * Adds the precision for a DECIMAL. * <p> * This value is required for decimals and must be less than or equal to * the maximum number of base-10 digits in the underlying type. A 4-byte * fixed, for example, can store up to 9 base-10 digits. * * @param precision an int precision value for the DECIMAL * @return this builder for method chaining */ public THIS precision(int precision) { this.precision = precision; return self(); }
/** * Adds the length for a FIXED_LEN_BYTE_ARRAY. * * @param length an int length * @return this builder for method chaining */ public THIS length(int length) { this.length = length; return self(); }
/** * Adds the length for a FIXED_LEN_BYTE_ARRAY. * * @param length an int length * @return this builder for method chaining */ public THIS length(int length) { this.length = length; return self(); }