Java Code Examples for org.apache.parquet.schema.OriginalType#TIME_MILLIS

The following examples show how to use org.apache.parquet.schema.OriginalType#TIME_MILLIS . 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: AvroSchemaConverter190Int96Avro17.java    From datacollector with Apache License 2.0 7 votes vote down vote up
private OriginalType convertLogicalTypeStr(String logicalType) {
    if (logicalType == null) {
      return null;
    } else if (AvroTypeUtil.LOGICAL_TYPE_DECIMAL.equals(logicalType)) {
      return OriginalType.DECIMAL;
    } else if (AvroTypeUtil.LOGICAL_TYPE_DATE.equals(logicalType)) {
      return OriginalType.DATE;
    } else if (AvroTypeUtil.LOGICAL_TYPE_TIME_MILLIS.equals(logicalType)) {
      return OriginalType.TIME_MILLIS;
//    } else if (AvroTypeUtil.LOGICAL_TYPE_TIME_MICROS.equals(logicalType)) {
//      return OriginalType.TIME_MICROS;
    } else if (AvroTypeUtil.LOGICAL_TYPE_TIMESTAMP_MILLIS.equals(logicalType)) {
      return OriginalType.TIMESTAMP_MILLIS;
//    } else if (AvroTypeUtil.LOGICAL_TYPE_TIMESTAMP_MICROS.equals(logicalType)) {
//      return OriginalType.TIMESTAMP_MICROS;
    }
    return null;
  }
 
Example 2
Source File: AvroSchemaConverter190Int96Avro18.java    From datacollector with Apache License 2.0 6 votes vote down vote up
private OriginalType convertLogicalType(LogicalType logicalType) {
  if (logicalType == null) {
    return null;
  } else if (logicalType instanceof LogicalTypes.Decimal) {
    return OriginalType.DECIMAL;
  } else if (logicalType instanceof LogicalTypes.Date) {
    return OriginalType.DATE;
  } else if (logicalType instanceof LogicalTypes.TimeMillis) {
    return OriginalType.TIME_MILLIS;
  } else if (logicalType instanceof LogicalTypes.TimeMicros) {
    return OriginalType.TIME_MICROS;
  } else if (logicalType instanceof LogicalTypes.TimestampMillis) {
    return OriginalType.TIMESTAMP_MILLIS;
  } else if (logicalType instanceof LogicalTypes.TimestampMicros) {
    return OriginalType.TIMESTAMP_MICROS;
  }
  return null;
}
 
Example 3
Source File: AvroSchemaConverterLogicalTypesPre19.java    From datacollector with Apache License 2.0 6 votes vote down vote up
private OriginalType convertLogicalType(String logicalType) {
    if (logicalType == null) {
      return null;
    } else if (LOGICAL_TYPE_DECIMAL.equals(logicalType)) {
      return OriginalType.DECIMAL;
    } else if (LOGICAL_TYPE_DATE.equals(logicalType)) {
      return OriginalType.DATE;
    } else if (LOGICAL_TYPE_TIME_MILLIS.equals(logicalType)) {
      return OriginalType.TIME_MILLIS;
//    } else if (LOGICAL_TYPE_TIME_MICROS.equals(logicalType)) {
//      return OriginalType.TIME_MICROS;
    } else if (LOGICAL_TYPE_TIMESTAMP_MILLIS.equals(logicalType)) {
      return OriginalType.TIMESTAMP_MILLIS;
//    } else if (LOGICAL_TYPE_TIMESTAMP_MICROS.equals(logicalType)) {
//      return OriginalType.TIMESTAMP_MICROS;
    }
    return null;
  }
 
Example 4
Source File: MetadataReader.java    From presto with Apache License 2.0 4 votes vote down vote up
private static OriginalType getOriginalType(ConvertedType type)
{
    switch (type) {
        case UTF8:
            return OriginalType.UTF8;
        case MAP:
            return OriginalType.MAP;
        case MAP_KEY_VALUE:
            return OriginalType.MAP_KEY_VALUE;
        case LIST:
            return OriginalType.LIST;
        case ENUM:
            return OriginalType.ENUM;
        case DECIMAL:
            return OriginalType.DECIMAL;
        case DATE:
            return OriginalType.DATE;
        case TIME_MILLIS:
            return OriginalType.TIME_MILLIS;
        case TIMESTAMP_MILLIS:
            return OriginalType.TIMESTAMP_MILLIS;
        case INTERVAL:
            return OriginalType.INTERVAL;
        case INT_8:
            return OriginalType.INT_8;
        case INT_16:
            return OriginalType.INT_16;
        case INT_32:
            return OriginalType.INT_32;
        case INT_64:
            return OriginalType.INT_64;
        case UINT_8:
            return OriginalType.UINT_8;
        case UINT_16:
            return OriginalType.UINT_16;
        case UINT_32:
            return OriginalType.UINT_32;
        case UINT_64:
            return OriginalType.UINT_64;
        case JSON:
            return OriginalType.JSON;
        case BSON:
            return OriginalType.BSON;
        case TIMESTAMP_MICROS:
            return OriginalType.TIMESTAMP_MICROS;
        case TIME_MICROS:
            return OriginalType.TIME_MICROS;
        default:
            throw new IllegalArgumentException("Unknown converted type " + type);
    }
}
 
Example 5
Source File: ParquetTypeHelper.java    From dremio-oss with Apache License 2.0 4 votes vote down vote up
/**
 * Returns an arrow vector field for a parquet primitive field
 *
 * @param colPath       schema path of the column
 * @param primitiveType parquet primitive type
 * @param originalType  parquet original type
 * @param schemaHelper  schema helper used for type conversions
 * @return arrow vector field
 */
public static Field createField(SchemaPath colPath,
                                PrimitiveType primitiveType,
                                OriginalType originalType,
                                SchemaDerivationHelper schemaHelper) {
  final String colName = colPath.getAsNamePart().getName();
  switch (primitiveType.getPrimitiveTypeName()) {
    case BINARY:
    case FIXED_LEN_BYTE_ARRAY:
      if (originalType == OriginalType.UTF8) {
        return CompleteType.VARCHAR.toField(colName);
      }
      if (originalType == OriginalType.DECIMAL) {

        return CompleteType.fromDecimalPrecisionScale(primitiveType.getDecimalMetadata()
          .getPrecision(), primitiveType.getDecimalMetadata().getScale()).toField(colName);
      }
      if (schemaHelper.isVarChar(colPath)) {
        return CompleteType.VARCHAR.toField(colName);
      }
      return CompleteType.VARBINARY.toField(colName);
    case BOOLEAN:
      return CompleteType.BIT.toField(colName);
    case DOUBLE:
      return CompleteType.DOUBLE.toField(colName);
    case FLOAT:
      return CompleteType.FLOAT.toField(colName);
    case INT32:
      if (originalType == OriginalType.DATE) {
        return CompleteType.DATE.toField(colName);
      } else if (originalType == OriginalType.TIME_MILLIS) {
        return CompleteType.TIME.toField(colName);
      } else if (originalType == OriginalType.DECIMAL) {
        return CompleteType.fromDecimalPrecisionScale(primitiveType.getDecimalMetadata()
          .getPrecision(), primitiveType.getDecimalMetadata().getScale()).toField(colName);
      }
      return CompleteType.INT.toField(colName);
    case INT64:
      if (originalType == OriginalType.TIMESTAMP_MILLIS) {
        return CompleteType.TIMESTAMP.toField(colName);
      } else if (originalType == OriginalType.DECIMAL) {
        return CompleteType.fromDecimalPrecisionScale(primitiveType.getDecimalMetadata()
          .getPrecision(), primitiveType.getDecimalMetadata().getScale()).toField(colName);
      }
      return CompleteType.BIGINT.toField(colName);
    case INT96:
      if (schemaHelper.readInt96AsTimeStamp()) {
        return CompleteType.TIMESTAMP.toField(colName);
      }
      return CompleteType.VARBINARY.toField(colName);
    default:
      throw UserException.unsupportedError()
        .message("Parquet Primitive Type '%s', Original Type '%s' combination not supported. Column '%s'",
          primitiveType.toString(), originalType != null ? originalType : "Not Available", colName)
        .build();
  }
}