1
0

[HUDI-2495] Resolve inconsistent key generation for timestamp types by GenericRecord and Row (#3944)

This commit is contained in:
Yann Byron
2021-11-11 11:54:34 +08:00
committed by GitHub
parent 77b0440eb4
commit 90529aa552
3 changed files with 121 additions and 1 deletions

View File

@@ -57,6 +57,7 @@ import java.io.OutputStream;
import java.math.BigDecimal;
import java.nio.ByteBuffer;
import java.nio.charset.StandardCharsets;
import java.sql.Timestamp;
import java.time.LocalDate;
import java.util.ArrayList;
import java.util.Arrays;
@@ -539,6 +540,8 @@ public class HoodieAvroUtils {
private static Object convertValueForAvroLogicalTypes(Schema fieldSchema, Object fieldValue) {
if (fieldSchema.getLogicalType() == LogicalTypes.date()) {
return LocalDate.ofEpochDay(Long.parseLong(fieldValue.toString()));
} else if (fieldSchema.getLogicalType() == LogicalTypes.timestampMicros()) {
return new Timestamp(Long.parseLong(fieldValue.toString()) / 1000);
} else if (fieldSchema.getLogicalType() instanceof LogicalTypes.Decimal) {
Decimal dc = (Decimal) fieldSchema.getLogicalType();
DecimalConversion decimalConversion = new DecimalConversion();