in catalogs/catalog-lakehouse-iceberg/src/main/java/org/apache/gravitino/catalog/lakehouse/iceberg/converter/ToIcebergType.java [103:143]
public Type atomic(org.apache.gravitino.rel.types.Type.PrimitiveType primitive) {
if (primitive instanceof org.apache.gravitino.rel.types.Types.BooleanType) {
return Types.BooleanType.get();
} else if (primitive instanceof org.apache.gravitino.rel.types.Types.ByteType
|| primitive instanceof org.apache.gravitino.rel.types.Types.ShortType) {
throw new IllegalArgumentException(
"Iceberg do not support Byte and Short Type, use Integer instead");
} else if (primitive instanceof org.apache.gravitino.rel.types.Types.IntegerType) {
return Types.IntegerType.get();
} else if (primitive instanceof org.apache.gravitino.rel.types.Types.LongType) {
return Types.LongType.get();
} else if (primitive instanceof org.apache.gravitino.rel.types.Types.FloatType) {
return Types.FloatType.get();
} else if (primitive instanceof org.apache.gravitino.rel.types.Types.DoubleType) {
return Types.DoubleType.get();
} else if (primitive instanceof org.apache.gravitino.rel.types.Types.StringType) {
return Types.StringType.get();
} else if (primitive instanceof org.apache.gravitino.rel.types.Types.DateType) {
return Types.DateType.get();
} else if (primitive instanceof org.apache.gravitino.rel.types.Types.TimeType) {
return Types.TimeType.get();
} else if (primitive instanceof org.apache.gravitino.rel.types.Types.TimestampType) {
if (((org.apache.gravitino.rel.types.Types.TimestampType) primitive).hasTimeZone()) {
return Types.TimestampType.withZone();
} else {
return Types.TimestampType.withoutZone();
}
} else if (primitive instanceof org.apache.gravitino.rel.types.Types.DecimalType) {
return Types.DecimalType.of(
((org.apache.gravitino.rel.types.Types.DecimalType) primitive).precision(),
((org.apache.gravitino.rel.types.Types.DecimalType) primitive).scale());
} else if (primitive instanceof org.apache.gravitino.rel.types.Types.FixedType) {
return Types.FixedType.ofLength(
((org.apache.gravitino.rel.types.Types.FixedType) primitive).length());
} else if (primitive instanceof org.apache.gravitino.rel.types.Types.BinaryType) {
return Types.BinaryType.get();
} else if (primitive instanceof org.apache.gravitino.rel.types.Types.UUIDType) {
return Types.UUIDType.get();
}
throw new UnsupportedOperationException("Not a supported type: " + primitive.toString());
}