@@ -168,7 +168,7 @@ void testCreateLakeEnabledTable() throws Exception {
168168 // for __bucket, __offset, __timestamp
169169 org .apache .paimon .types .DataTypes .INT (),
170170 org .apache .paimon .types .DataTypes .BIGINT (),
171- org .apache .paimon .types .DataTypes .TIMESTAMP_WITH_LOCAL_TIME_ZONE ()
171+ org .apache .paimon .types .DataTypes .TIMESTAMP_LTZ_MILLIS ()
172172 },
173173 new String [] {
174174 "log_c1" ,
@@ -206,7 +206,7 @@ void testCreateLakeEnabledTable() throws Exception {
206206 // for __bucket, __offset, __timestamp
207207 org .apache .paimon .types .DataTypes .INT (),
208208 org .apache .paimon .types .DataTypes .BIGINT (),
209- org .apache .paimon .types .DataTypes .TIMESTAMP_WITH_LOCAL_TIME_ZONE ()
209+ org .apache .paimon .types .DataTypes .TIMESTAMP_LTZ_MILLIS ()
210210 },
211211 new String [] {
212212 "log_c1" ,
@@ -245,7 +245,7 @@ void testCreateLakeEnabledTable() throws Exception {
245245 // for __bucket, __offset, __timestamp
246246 org .apache .paimon .types .DataTypes .INT (),
247247 org .apache .paimon .types .DataTypes .BIGINT (),
248- org .apache .paimon .types .DataTypes .TIMESTAMP_WITH_LOCAL_TIME_ZONE ()
248+ org .apache .paimon .types .DataTypes .TIMESTAMP_LTZ_MILLIS ()
249249 },
250250 new String [] {
251251 "pk_c1" ,
@@ -288,7 +288,7 @@ void testCreateLakeEnabledTable() throws Exception {
288288 // for __bucket, __offset, __timestamp
289289 org .apache .paimon .types .DataTypes .INT (),
290290 org .apache .paimon .types .DataTypes .BIGINT (),
291- org .apache .paimon .types .DataTypes .TIMESTAMP_WITH_LOCAL_TIME_ZONE ()
291+ org .apache .paimon .types .DataTypes .TIMESTAMP_LTZ_MILLIS ()
292292 },
293293 new String [] {
294294 "c1" ,
@@ -355,7 +355,7 @@ void testCreateLakeEnabledTableWithAllTypes() throws Exception {
355355 // for __bucket, __offset, __timestamp
356356 org .apache .paimon .types .DataTypes .INT (),
357357 org .apache .paimon .types .DataTypes .BIGINT (),
358- org .apache .paimon .types .DataTypes .TIMESTAMP_WITH_LOCAL_TIME_ZONE ()
358+ org .apache .paimon .types .DataTypes .TIMESTAMP_LTZ_MILLIS ()
359359 },
360360 new String [] {
361361 "log_c1" ,
@@ -456,8 +456,8 @@ void testCreateLakeEnableTableWithExistLakeTable() throws Exception {
456456 .isInstanceOf (LakeTableAlreadyExistException .class )
457457 .hasMessage (
458458 "The table `fluss`.`log_table_with_exist_lake_table` already exists in Paimon catalog, but the table schema is not compatible. "
459- + "Existing schema: UpdateSchema{fields=[`c1` STRING, `c2` INT, `__bucket` INT, `__offset` BIGINT, `__timestamp` TIMESTAMP(6 ) WITH LOCAL TIME ZONE], partitionKeys=[], primaryKeys=[], options={bucket=-1, fluss.table.replication.factor=1, fluss.table.datalake.enabled=true, fluss.table.datalake.format=paimon, partition.legacy-name=false, file.format=parquet, fluss.k1=v1}, comment=null}, "
460- + "new schema: UpdateSchema{fields=[`c1` STRING, `c2` INT, `__bucket` INT, `__offset` BIGINT, `__timestamp` TIMESTAMP(6 ) WITH LOCAL TIME ZONE], partitionKeys=[], primaryKeys=[], options={bucket=3, fluss.table.replication.factor=1, fluss.table.datalake.enabled=true, fluss.table.datalake.format=paimon, partition.legacy-name=false, bucket-key=c1,c2, file.format=parquet, fluss.k1=v1}, comment=null}. "
459+ + "Existing schema: UpdateSchema{fields=[`c1` STRING, `c2` INT, `__bucket` INT, `__offset` BIGINT, `__timestamp` TIMESTAMP(3 ) WITH LOCAL TIME ZONE], partitionKeys=[], primaryKeys=[], options={bucket=-1, fluss.table.replication.factor=1, fluss.table.datalake.enabled=true, fluss.table.datalake.format=paimon, partition.legacy-name=false, file.format=parquet, fluss.k1=v1}, comment=null}, "
460+ + "new schema: UpdateSchema{fields=[`c1` STRING, `c2` INT, `__bucket` INT, `__offset` BIGINT, `__timestamp` TIMESTAMP(3 ) WITH LOCAL TIME ZONE], partitionKeys=[], primaryKeys=[], options={bucket=3, fluss.table.replication.factor=1, fluss.table.datalake.enabled=true, fluss.table.datalake.format=paimon, partition.legacy-name=false, bucket-key=c1,c2, file.format=parquet, fluss.k1=v1}, comment=null}. "
461461 + "Please first drop the table in Paimon catalog or use a new table name." );
462462
463463 // create log table with different fields will throw exception
@@ -475,8 +475,8 @@ void testCreateLakeEnableTableWithExistLakeTable() throws Exception {
475475 .isInstanceOf (LakeTableAlreadyExistException .class )
476476 .hasMessage (
477477 "The table `fluss`.`log_table_with_exist_lake_table` already exists in Paimon catalog, but the table schema is not compatible. "
478- + "Existing schema: UpdateSchema{fields=[`c1` STRING, `c2` INT, `__bucket` INT, `__offset` BIGINT, `__timestamp` TIMESTAMP(6 ) WITH LOCAL TIME ZONE], partitionKeys=[], primaryKeys=[], options={bucket=-1, fluss.table.replication.factor=1, fluss.table.datalake.enabled=true, fluss.table.datalake.format=paimon, partition.legacy-name=false, file.format=parquet, fluss.k1=v1}, comment=null}, "
479- + "new schema: UpdateSchema{fields=[`c1` STRING, `c2` INT, `c3` STRING, `__bucket` INT, `__offset` BIGINT, `__timestamp` TIMESTAMP(6 ) WITH LOCAL TIME ZONE], partitionKeys=[], primaryKeys=[], options={bucket=-1, fluss.table.replication.factor=1, fluss.table.datalake.enabled=true, fluss.table.datalake.format=paimon, partition.legacy-name=false, file.format=parquet, fluss.k1=v1}, comment=null}. "
478+ + "Existing schema: UpdateSchema{fields=[`c1` STRING, `c2` INT, `__bucket` INT, `__offset` BIGINT, `__timestamp` TIMESTAMP(3 ) WITH LOCAL TIME ZONE], partitionKeys=[], primaryKeys=[], options={bucket=-1, fluss.table.replication.factor=1, fluss.table.datalake.enabled=true, fluss.table.datalake.format=paimon, partition.legacy-name=false, file.format=parquet, fluss.k1=v1}, comment=null}, "
479+ + "new schema: UpdateSchema{fields=[`c1` STRING, `c2` INT, `c3` STRING, `__bucket` INT, `__offset` BIGINT, `__timestamp` TIMESTAMP(3 ) WITH LOCAL TIME ZONE], partitionKeys=[], primaryKeys=[], options={bucket=-1, fluss.table.replication.factor=1, fluss.table.datalake.enabled=true, fluss.table.datalake.format=paimon, partition.legacy-name=false, file.format=parquet, fluss.k1=v1}, comment=null}. "
480480 + "Please first drop the table in Paimon catalog or use a new table name." );
481481
482482 // add an insignificant option to Paimon table will be ok
@@ -615,7 +615,7 @@ void testAlterLakeEnabledLogTable() throws Exception {
615615 // for __bucket, __offset, __timestamp
616616 org .apache .paimon .types .DataTypes .INT (),
617617 org .apache .paimon .types .DataTypes .BIGINT (),
618- org .apache .paimon .types .DataTypes .TIMESTAMP_WITH_LOCAL_TIME_ZONE ()
618+ org .apache .paimon .types .DataTypes .TIMESTAMP_LTZ_MILLIS ()
619619 },
620620 new String [] {
621621 "log_c1" ,
@@ -711,7 +711,7 @@ void testAlterLakeEnabledTableProperties() throws Exception {
711711 // for __bucket, __offset, __timestamp
712712 org .apache .paimon .types .DataTypes .INT (),
713713 org .apache .paimon .types .DataTypes .BIGINT (),
714- org .apache .paimon .types .DataTypes .TIMESTAMP_WITH_LOCAL_TIME_ZONE ()
714+ org .apache .paimon .types .DataTypes .TIMESTAMP_LTZ_MILLIS ()
715715 },
716716 new String [] {
717717 "c1" ,
@@ -742,7 +742,7 @@ void testAlterLakeEnabledTableProperties() throws Exception {
742742 // for __bucket, __offset, __timestamp
743743 org .apache .paimon .types .DataTypes .INT (),
744744 org .apache .paimon .types .DataTypes .BIGINT (),
745- org .apache .paimon .types .DataTypes .TIMESTAMP_WITH_LOCAL_TIME_ZONE ()
745+ org .apache .paimon .types .DataTypes .TIMESTAMP_LTZ_MILLIS ()
746746 },
747747 new String [] {
748748 "c1" ,
@@ -832,7 +832,7 @@ void testEnableLakeTableAfterAlterTableProperties() throws Exception {
832832 // for __bucket, __offset, __timestamp
833833 org .apache .paimon .types .DataTypes .INT (),
834834 org .apache .paimon .types .DataTypes .BIGINT (),
835- org .apache .paimon .types .DataTypes .TIMESTAMP_WITH_LOCAL_TIME_ZONE ()
835+ org .apache .paimon .types .DataTypes .TIMESTAMP_LTZ_MILLIS ()
836836 },
837837 new String [] {
838838 "c1" ,
@@ -885,7 +885,7 @@ void testAlterLakeEnabledTableSchema() throws Exception {
885885 // for __bucket, __offset, __timestamp
886886 org .apache .paimon .types .DataTypes .INT (),
887887 org .apache .paimon .types .DataTypes .BIGINT (),
888- org .apache .paimon .types .DataTypes .TIMESTAMP_WITH_LOCAL_TIME_ZONE ()
888+ org .apache .paimon .types .DataTypes .TIMESTAMP_LTZ_MILLIS ()
889889 },
890890 new String [] {
891891 "c1" ,
@@ -927,6 +927,50 @@ void testAlterLakeEnabledTableSchema() throws Exception {
927927 assertThat (alteredRowType .getField ("c3" ).description ()).isEqualTo ("c3 comment" );
928928 }
929929
930+ @ Test
931+ void testEnableLakeTableWithLegacySystemTimestampColumn () throws Exception {
932+ TablePath tablePath = TablePath .of (DATABASE , "timestamp_precision_compat" );
933+ TableDescriptor tableDescriptor =
934+ TableDescriptor .builder ()
935+ .schema (Schema .newBuilder ().column ("c1" , DataTypes .INT ()).build ())
936+ .property (ConfigOptions .TABLE_DATALAKE_ENABLED , true )
937+ .build ();
938+
939+ admin .createTable (tablePath , tableDescriptor , false ).get ();
940+
941+ Identifier paimonIdentifier = Identifier .create (DATABASE , tablePath .getTableName ());
942+
943+ // alter to TIMESTAMP_WITH_LOCAL_TIME_ZONE to mock the legacy behavior
944+ paimonCatalog .alterTable (
945+ paimonIdentifier ,
946+ SchemaChange .updateColumnType (
947+ TIMESTAMP_COLUMN_NAME ,
948+ org .apache .paimon .types .DataTypes .TIMESTAMP_WITH_LOCAL_TIME_ZONE ()),
949+ false );
950+
951+ // disable data lake
952+ admin .alterTable (
953+ tablePath ,
954+ Collections .singletonList (
955+ TableChange .set (
956+ ConfigOptions .TABLE_DATALAKE_ENABLED .key (), "false" )),
957+ false )
958+ .get ();
959+ assertThat (admin .getTableInfo (tablePath ).get ().getTableConfig ().isDataLakeEnabled ())
960+ .isFalse ();
961+
962+ // enable data lake again, should still enable it
963+ admin .alterTable (
964+ tablePath ,
965+ Collections .singletonList (
966+ TableChange .set (
967+ ConfigOptions .TABLE_DATALAKE_ENABLED .key (), "true" )),
968+ false )
969+ .get ();
970+ assertThat (admin .getTableInfo (tablePath ).get ().getTableConfig ().isDataLakeEnabled ())
971+ .isTrue ();
972+ }
973+
930974 private void verifyPaimonTable (
931975 Table paimonTable ,
932976 TableDescriptor flussTable ,
0 commit comments