@@ -23,7 +23,7 @@ import java.util.Date
23
23
import scala .collection .JavaConverters ._
24
24
25
25
// scalastyle:off import.ordering.noEmptyLine
26
- import org .apache .spark .sql .delta .DeltaTestUtils .BOOLEAN_DOMAIN
26
+ import org .apache .spark .sql .delta .DeltaTestUtils .{ modifyCommitTimestamp , BOOLEAN_DOMAIN }
27
27
import org .apache .spark .sql .delta .commands .cdc .CDCReader ._
28
28
import org .apache .spark .sql .delta .coordinatedcommits .CoordinatedCommitsBaseSuite
29
29
import org .apache .spark .sql .delta .sources .DeltaSQLConf
@@ -108,16 +108,6 @@ abstract class DeltaCDCSuiteBase
108
108
schemaMode : Option [DeltaBatchCDFSchemaMode ] = Some (BatchCDFSchemaLegacy ),
109
109
readerOptions : Map [String , String ] = Map .empty): DataFrame
110
110
111
- /** Modify timestamp for a delta commit, used to test timestamp querying */
112
- def modifyDeltaTimestamp (deltaLog : DeltaLog , version : Long , time : Long ): Unit = {
113
- val file = new File (FileNames .unsafeDeltaFile(deltaLog.logPath, version).toUri)
114
- file.setLastModified(time)
115
- val crc = new File (FileNames .checksumFile(deltaLog.logPath, version).toUri)
116
- if (crc.exists()) {
117
- crc.setLastModified(time)
118
- }
119
- }
120
-
121
111
/** Create table utility method */
122
112
def ctas (srcTbl : String , dstTbl : String , disableCDC : Boolean = false ): Unit = {
123
113
val readDf = cdcRead(new TableName (srcTbl), StartingVersion (" 0" ), EndingVersion (" 1" ))
@@ -252,14 +242,14 @@ abstract class DeltaCDCSuiteBase
252
242
253
243
// modify timestamps
254
244
// version 0
255
- modifyDeltaTimestamp (deltaLog, 0 , 0 )
245
+ modifyCommitTimestamp (deltaLog, 0 , 0 )
256
246
val tsAfterV0 = dateFormat.format(new Date (1 ))
257
247
258
248
// version 1
259
- modifyDeltaTimestamp (deltaLog, 1 , 1000 )
249
+ modifyCommitTimestamp (deltaLog, 1 , 1000 )
260
250
val tsAfterV1 = dateFormat.format(new Date (1001 ))
261
251
262
- modifyDeltaTimestamp (deltaLog, 2 , 2000 )
252
+ modifyCommitTimestamp (deltaLog, 2 , 2000 )
263
253
264
254
val readDf = cdcRead(
265
255
new TablePath (tempDir.getAbsolutePath),
@@ -278,9 +268,9 @@ abstract class DeltaCDCSuiteBase
278
268
createTblWithThreeVersions(path = Some (tempDir.getAbsolutePath))
279
269
val deltaLog = DeltaLog .forTable(spark, tempDir.getAbsolutePath)
280
270
281
- modifyDeltaTimestamp (deltaLog, 0 , 0 )
282
- modifyDeltaTimestamp (deltaLog, 1 , 10000 )
283
- modifyDeltaTimestamp (deltaLog, 2 , 20000 )
271
+ modifyCommitTimestamp (deltaLog, 0 , 0 )
272
+ modifyCommitTimestamp (deltaLog, 1 , 10000 )
273
+ modifyCommitTimestamp (deltaLog, 2 , 20000 )
284
274
285
275
val ts0 = dateFormat.format(new Date (2000 ))
286
276
val readDf = cdcRead(
@@ -299,9 +289,9 @@ abstract class DeltaCDCSuiteBase
299
289
createTblWithThreeVersions(path = Some (tempDir.getAbsolutePath))
300
290
val deltaLog = DeltaLog .forTable(spark, tempDir.getAbsolutePath)
301
291
302
- modifyDeltaTimestamp (deltaLog, 0 , 0 )
303
- modifyDeltaTimestamp (deltaLog, 1 , 1000 )
304
- modifyDeltaTimestamp (deltaLog, 2 , 2000 )
292
+ modifyCommitTimestamp (deltaLog, 0 , 0 )
293
+ modifyCommitTimestamp (deltaLog, 1 , 1000 )
294
+ modifyCommitTimestamp (deltaLog, 2 , 2000 )
305
295
306
296
val ts0 = dateFormat.format(new Date (0 ))
307
297
val readDf = cdcRead(
@@ -320,9 +310,9 @@ abstract class DeltaCDCSuiteBase
320
310
createTblWithThreeVersions(path = Some (tempDir.getAbsolutePath))
321
311
val deltaLog = DeltaLog .forTable(spark, tempDir.getAbsolutePath)
322
312
323
- modifyDeltaTimestamp (deltaLog, 0 , 4000 )
324
- modifyDeltaTimestamp (deltaLog, 1 , 8000 )
325
- modifyDeltaTimestamp (deltaLog, 2 , 12000 )
313
+ modifyCommitTimestamp (deltaLog, 0 , 4000 )
314
+ modifyCommitTimestamp (deltaLog, 1 , 8000 )
315
+ modifyCommitTimestamp (deltaLog, 2 , 12000 )
326
316
327
317
val ts0 = dateFormat.format(new Date (1000 ))
328
318
val ts1 = dateFormat.format(new Date (3000 ))
@@ -341,9 +331,9 @@ abstract class DeltaCDCSuiteBase
341
331
createTblWithThreeVersions(path = Some (tempDir.getAbsolutePath))
342
332
val deltaLog = DeltaLog .forTable(spark, tempDir.getAbsolutePath)
343
333
344
- modifyDeltaTimestamp (deltaLog, 0 , 0 )
345
- modifyDeltaTimestamp (deltaLog, 1 , 4000 )
346
- modifyDeltaTimestamp (deltaLog, 2 , 8000 )
334
+ modifyCommitTimestamp (deltaLog, 0 , 0 )
335
+ modifyCommitTimestamp (deltaLog, 1 , 4000 )
336
+ modifyCommitTimestamp (deltaLog, 2 , 8000 )
347
337
348
338
val ts0 = dateFormat.format(new Date (1000 ))
349
339
val ts1 = dateFormat.format(new Date (3000 ))
@@ -363,9 +353,9 @@ abstract class DeltaCDCSuiteBase
363
353
createTblWithThreeVersions(path = Some (tempDir.getAbsolutePath))
364
354
val deltaLog = DeltaLog .forTable(spark, tempDir.getAbsolutePath)
365
355
366
- modifyDeltaTimestamp (deltaLog, 0 , 0 )
367
- modifyDeltaTimestamp (deltaLog, 1 , 4000 )
368
- modifyDeltaTimestamp (deltaLog, 2 , 8000 )
356
+ modifyCommitTimestamp (deltaLog, 0 , 0 )
357
+ modifyCommitTimestamp (deltaLog, 1 , 4000 )
358
+ modifyCommitTimestamp (deltaLog, 2 , 8000 )
369
359
370
360
val ts0 = dateFormat.format(new Date (3000 ))
371
361
val ts1 = dateFormat.format(new Date (5000 ))
@@ -385,9 +375,9 @@ abstract class DeltaCDCSuiteBase
385
375
createTblWithThreeVersions(path = Some (tempDir.getAbsolutePath))
386
376
val deltaLog = DeltaLog .forTable(spark, tempDir.getAbsolutePath)
387
377
388
- modifyDeltaTimestamp (deltaLog, 0 , 0 )
389
- modifyDeltaTimestamp (deltaLog, 1 , 4000 )
390
- modifyDeltaTimestamp (deltaLog, 2 , 8000 )
378
+ modifyCommitTimestamp (deltaLog, 0 , 0 )
379
+ modifyCommitTimestamp (deltaLog, 1 , 4000 )
380
+ modifyCommitTimestamp (deltaLog, 2 , 8000 )
391
381
392
382
val ts0 = dateFormat.format(new Date (3000 ))
393
383
val ts1 = dateFormat.format(new Date (1000 ))
@@ -406,9 +396,9 @@ abstract class DeltaCDCSuiteBase
406
396
createTblWithThreeVersions(path = Some (tempDir.getAbsolutePath))
407
397
val deltaLog = DeltaLog .forTable(spark, tempDir.getAbsolutePath)
408
398
409
- modifyDeltaTimestamp (deltaLog, 0 , 0 )
410
- modifyDeltaTimestamp (deltaLog, 1 , 4000 )
411
- modifyDeltaTimestamp (deltaLog, 2 , 8000 )
399
+ modifyCommitTimestamp (deltaLog, 0 , 0 )
400
+ modifyCommitTimestamp (deltaLog, 1 , 4000 )
401
+ modifyCommitTimestamp (deltaLog, 2 , 8000 )
412
402
413
403
val ts0 = dateFormat.format(new Date (5000 ))
414
404
val ts1 = dateFormat.format(new Date (3000 ))
@@ -449,7 +439,7 @@ abstract class DeltaCDCSuiteBase
449
439
// Set commit time during Daylight savings time change.
450
440
val restoreDate = " 2022-11-06 01:42:44"
451
441
val timestamp = dateFormat.parse(s " $restoreDate -0800 " ).getTime
452
- modifyDeltaTimestamp (deltaLog, 0 , timestamp)
442
+ modifyCommitTimestamp (deltaLog, 0 , timestamp)
453
443
454
444
// Verify DST is respected.
455
445
val e = intercept[Exception ] {
@@ -558,9 +548,9 @@ abstract class DeltaCDCSuiteBase
558
548
createTblWithThreeVersions(path = Some (tempDir.getAbsolutePath))
559
549
val deltaLog = DeltaLog .forTable(spark, tempDir.getAbsolutePath)
560
550
561
- modifyDeltaTimestamp (deltaLog, 0 , 0 )
562
- modifyDeltaTimestamp (deltaLog, 1 , 1000 )
563
- modifyDeltaTimestamp (deltaLog, 2 , 2000 )
551
+ modifyCommitTimestamp (deltaLog, 0 , 0 )
552
+ modifyCommitTimestamp (deltaLog, 1 , 1000 )
553
+ modifyCommitTimestamp (deltaLog, 2 , 2000 )
564
554
565
555
val ts0 = dateFormat.format(new Date (2000 ))
566
556
val ts1 = dateFormat.format(new Date (1 ))
@@ -795,13 +785,13 @@ abstract class DeltaCDCSuiteBase
795
785
796
786
// modify timestamps
797
787
// version 0
798
- modifyDeltaTimestamp (deltaLog, 0 , 0 )
788
+ modifyCommitTimestamp (deltaLog, 0 , 0 )
799
789
800
790
// version 1
801
- modifyDeltaTimestamp (deltaLog, 1 , 1000 )
791
+ modifyCommitTimestamp (deltaLog, 1 , 1000 )
802
792
803
793
// version 2
804
- modifyDeltaTimestamp (deltaLog, 2 , 2000 )
794
+ modifyCommitTimestamp (deltaLog, 2 , 2000 )
805
795
val tsStart = dateFormat.format(new Date (3000 ))
806
796
val tsEnd = dateFormat.format(new Date (4000 ))
807
797
@@ -825,13 +815,13 @@ abstract class DeltaCDCSuiteBase
825
815
826
816
// modify timestamps
827
817
// version 0
828
- modifyDeltaTimestamp (deltaLog, 0 , 0 )
818
+ modifyCommitTimestamp (deltaLog, 0 , 0 )
829
819
830
820
// version 1
831
- modifyDeltaTimestamp (deltaLog, 1 , 1000 )
821
+ modifyCommitTimestamp (deltaLog, 1 , 1000 )
832
822
833
823
// version 2
834
- modifyDeltaTimestamp (deltaLog, 2 , 2000 )
824
+ modifyCommitTimestamp (deltaLog, 2 , 2000 )
835
825
836
826
val tsStart = dateFormat.format(new Date (0 ))
837
827
val tsEnd = dateFormat.format(new Date (4000 ))
@@ -1107,23 +1097,6 @@ class DeltaCDCScalaWithDeletionVectorsSuite extends DeltaCDCScalaSuite
1107
1097
}
1108
1098
1109
1099
class DeltaCDCScalaSuiteWithCoordinatedCommitsBatch10 extends DeltaCDCScalaSuite
1110
- with CoordinatedCommitsBaseSuite {
1111
-
1112
- /** Modify timestamp for a delta commit, used to test timestamp querying */
1113
- override def modifyDeltaTimestamp (deltaLog : DeltaLog , version : Long , time : Long ): Unit = {
1114
- val fileProvider = DeltaCommitFileProvider (deltaLog.snapshot)
1115
- val file = new File (fileProvider.deltaFile(version).toUri)
1116
- InCommitTimestampTestUtils .overwriteICTInDeltaFile(
1117
- deltaLog,
1118
- new Path (file.getPath),
1119
- Some (time))
1120
- file.setLastModified(time)
1121
- val crc = new File (FileNames .checksumFile(deltaLog.logPath, version).toUri)
1122
- if (crc.exists()) {
1123
- InCommitTimestampTestUtils .overwriteICTInCrc(deltaLog, version, Some (time))
1124
- crc.setLastModified(time)
1125
- }
1126
- }
1127
-
1100
+ with CoordinatedCommitsBaseSuite {
1128
1101
override def coordinatedCommitsBackfillBatchSize : Option [Int ] = Some (10 )
1129
1102
}
0 commit comments