Skip to content

Commit

Permalink
Add creationTime in mysql column (#248)
Browse files Browse the repository at this point in the history
  • Loading branch information
jiang95-dev authored Nov 6, 2024
1 parent 9be2378 commit 8e2cc7d
Show file tree
Hide file tree
Showing 7 changed files with 19 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ public abstract class HouseTableMapper {
@Autowired FileIOManager fileIOManager;

@Mapping(target = "lastModifiedTime", ignore = true)
@Mapping(target = "creationTime", ignore = true)
@Mapping(
target = "storageType",
expression = "java(fileIOManager.getStorage(fileIO).getType().getValue())")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,10 @@ public class UserTable {
@JsonProperty(value = "storageType")
private String storageType;

@Schema(description = "Creation time of the table.", example = "1651002318265")
@JsonProperty(value = "creationTime")
private Long creationTime;

public String toJson() {
return new Gson().toJson(this);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ public interface UserTablesMapper {
*/
@Mapping(target = "version", source = "userTable", qualifiedByName = "toVersion")
@Mapping(target = "storageType", source = "userTable.storageType", defaultValue = DEFAULT_STORAGE)
@Mapping(target = "creationTime", source = "userTable.creationTime")
UserTableRow toUserTableRow(
UserTable userTable, @Context Optional<UserTableRow> existingUserTableRow);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ public class UserTableDto {

String storageType;

Long creationTime;

/**
* Compare if a given {@link UserTable} matches the current one if all non-null fields are equal.
*
Expand All @@ -32,6 +34,7 @@ public boolean match(UserTableDto userTable) {
&& Utilities.fieldMatchCaseInsensitive(this.tableId, userTable.tableId)
&& Utilities.fieldMatch(this.metadataLocation, userTable.metadataLocation)
&& Utilities.fieldMatch(this.tableVersion, userTable.tableVersion)
&& Utilities.fieldMatch(this.storageType, userTable.storageType);
&& Utilities.fieldMatch(this.storageType, userTable.storageType)
&& Utilities.fieldMatch(this.creationTime, userTable.creationTime);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -30,4 +30,6 @@ public class UserTableRow {
String metadataLocation;

String storageType;

Long creationTime;
}
1 change: 1 addition & 0 deletions services/housetables/src/main/resources/schema.sql
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ CREATE TABLE IF NOT EXISTS user_table_row (
version BIGINT NOT NULL,
metadata_location VARCHAR (512) ,
storage_type VARCHAR (128) DEFAULT 'hdfs' NOT NULL,
creation_time BIGINT DEFAULT NULL,
last_modified_time TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
ETL_TS DATETIME(6) DEFAULT CURRENT_TIMESTAMP(6) ON UPDATE CURRENT_TIMESTAMP(6),
PRIMARY KEY (database_id, table_id)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ private TestHouseTableModelConstants() {

public static final String TEST_DEFAULT_STORAGE_TYPE = "hdfs";

public static final long TEST_CREATION_TIME = 123;

public static final UserTableDto TEST_USER_TABLE_DTO = TUPLE_0.get_userTableDto();
public static final UserTable TEST_USER_TABLE = TUPLE_0.get_userTable();

Expand All @@ -43,6 +45,7 @@ public static class TestTuple {
private final String databaseId;
private final String tableLoc;
private final String storageType;
private final long creationTime;

public TestTuple(int tbSeq) {
this(tbSeq, 0);
Expand All @@ -58,13 +61,15 @@ public TestTuple(int tbSeq, int dbSeq) {
.replace("$test_table", tableId)
.replace("$version", "v0");
this.storageType = TEST_DEFAULT_STORAGE_TYPE;
this.creationTime = TEST_CREATION_TIME;
this._userTable =
UserTable.builder()
.tableId(tableId)
.databaseId(databaseId)
.tableVersion(ver)
.metadataLocation(tableLoc)
.storageType(storageType)
.creationTime(TEST_CREATION_TIME)
.build();

this._userTableDto =
Expand All @@ -74,6 +79,7 @@ public TestTuple(int tbSeq, int dbSeq) {
.tableVersion(ver)
.metadataLocation(tableLoc)
.storageType(storageType)
.creationTime(TEST_CREATION_TIME)
.build();

this._userTableRow =
Expand All @@ -83,6 +89,7 @@ public TestTuple(int tbSeq, int dbSeq) {
.version(null)
.metadataLocation(tableLoc)
.storageType(storageType)
.creationTime(TEST_CREATION_TIME)
.build();
}
}
Expand Down

0 comments on commit 8e2cc7d

Please sign in to comment.