InvisibleProgrammer commented on code in PR #5186: URL: https://github.com/apache/hive/pull/5186#discussion_r1558965679
########## standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/txn/TxnHandler.java: ########## @@ -705,12 +706,11 @@ public LockResponse lockMaterializationRebuild(String dbName, String tableName, public boolean heartbeatLockMaterializationRebuild(String dbName, String tableName, long txnId) throws MetaException { int result = jdbcResource.execute( "UPDATE \"MATERIALIZATION_REBUILD_LOCKS\"" + - " SET \"MRL_LAST_HEARTBEAT\" = " + Instant.now().toEpochMilli() + - " WHERE \"MRL_TXN_ID\" = " + txnId + - " AND \"MRL_DB_NAME\" = ?" + - " AND \"MRL_TBL_NAME\" = ?", + " SET \"MRL_LAST_HEARTBEAT\" = " + getEpochFn(jdbcResource.getDatabaseProduct()) + Review Comment: It provides different methods to get the timestamp, based on the different database providers. The original code, `Instant.now()` generates the timestamp in Java side. This method says the db engine will handle that. ```java new EnumMap<DatabaseProduct.DbType, String>(DatabaseProduct.DbType.class) {{ put(DbType.DERBY, "{ fn timestampdiff(sql_tsi_frac_second, timestamp('" + new Timestamp(0) + "'), current_timestamp) } / 1000000"); put(DbType.CUSTOM, "{ fn timestampdiff(sql_tsi_frac_second, timestamp('" + new Timestamp(0) + "'), current_timestamp) } / 1000000"); put(DbType.MYSQL, "round(unix_timestamp(now(3)) * 1000)"); put(DbType.POSTGRES, "round(extract(epoch from current_timestamp) * 1000)"); put(DbType.ORACLE, "(cast(systimestamp at time zone 'UTC' as date) - date '1970-01-01')*24*60*60*1000 " + "+ cast(mod( extract( second from systimestamp ), 1 ) * 1000 as int)"); put(DbType.SQLSERVER, "datediff_big(millisecond, '19700101', sysutcdatetime())"); ``` -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: gitbox-unsubscr...@hive.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: gitbox-unsubscr...@hive.apache.org For additional commands, e-mail: gitbox-h...@hive.apache.org