Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[HUDI-5161] add TIMESTAMP_LTZ #7156

Closed
wants to merge 5 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
import org.apache.flink.table.types.logical.TinyIntType;
import org.apache.flink.table.types.logical.VarBinaryType;
import org.apache.flink.table.types.logical.VarCharType;
import org.apache.flink.table.types.logical.LocalZonedTimestampType;
import org.apache.flink.table.types.logical.utils.LogicalTypeDefaultVisitor;
import org.apache.hadoop.hive.serde2.typeinfo.TypeInfo;
import org.apache.hadoop.hive.serde2.typeinfo.TypeInfoFactory;
Expand Down Expand Up @@ -144,6 +145,17 @@ public TypeInfo visit(TimestampType timestampType) {
}
}


@Override
public TypeInfo visit(LocalZonedTimestampType localZonedTimestampType) {
int precision = localZonedTimestampType.getPrecision();
if (precision >=0 && precision <= 9){
return TypeInfoFactory.timestampTypeInfo;
} else {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we add a test case in TestHoodieHiveCatalog.

Copy link
Contributor Author

@kaori-seasons kaori-seasons Nov 8, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok, I will refer to HUDI-4781 to construct related Schemas and add tests

return TypeInfoFactory.longTypeInfo;
}
}

@Override
public TypeInfo visit(ArrayType arrayType) {
LogicalType elementType = arrayType.getElementType();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ public class TestHoodieHiveCatalog {
.field("age", DataTypes.INT())
.field("par1", DataTypes.STRING())
.field("ts", DataTypes.BIGINT())
.field("update_time", DataTypes.TIMESTAMP_LTZ())
.primaryKey("uuid")
.build();
List<String> partitions = Collections.singletonList("par1");
Expand Down Expand Up @@ -132,7 +133,8 @@ public void testCreateAndGetHoodieTable(HoodieTableType tableType) throws Except
+ "uuid:int,"
+ "name:string,"
+ "age:int,"
+ "ts:bigint";
+ "ts:bigint,"
+ "update_time:timestamp";
assertEquals(expectedFieldSchema, fieldSchema);
String partitionSchema = hiveTable.getPartitionKeys().stream()
.map(f -> f.getName() + ":" + f.getType())
Expand All @@ -148,7 +150,7 @@ public void testCreateAndGetHoodieTable(HoodieTableType tableType) throws Except
String tableSchema = table1.getUnresolvedSchema().getColumns().stream()
.map(Schema.UnresolvedColumn::toString)
.collect(Collectors.joining(","));
String expectedTableSchema = "`uuid` INT NOT NULL,`name` STRING,`age` INT,`par1` STRING,`ts` BIGINT";
String expectedTableSchema = "`uuid` INT NOT NULL,`name` STRING,`age` INT,`par1` STRING,`ts` BIGINT,`update_time` TIMESTAMP_LTZ(6)";
assertEquals(expectedTableSchema, tableSchema);
assertEquals(Collections.singletonList("uuid"), table1.getUnresolvedSchema().getPrimaryKey().get().getColumnNames());
assertEquals(Collections.singletonList("par1"), ((CatalogTable) table1).getPartitionKeys());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -232,6 +232,8 @@ private static String convertField(final Type parquetType, boolean supportTimest
return field.append("DATE").toString();
} else if (supportTimestamp && originalType == OriginalType.TIMESTAMP_MICROS) {
return field.append("TIMESTAMP").toString();
} else if (supportTimestamp && originalType == OriginalType.TIMESTAMP_MILLIS) {
return field.append("TIMESTAMP_LTZ").toString();
}

// TODO - fix the method naming here
Expand Down