Skip to content

Commit

Permalink
[Spark] Rename lastCommitTimestamp to lastCommitFileModificationTimes…
Browse files Browse the repository at this point in the history
…tamp (#2746)

<!--
Thanks for sending a pull request!  Here are some tips for you:
1. If this is your first time, please read our contributor guidelines:
https://github.com/delta-io/delta/blob/master/CONTRIBUTING.md
2. If the PR is unfinished, add '[WIP]' in your PR title, e.g., '[WIP]
Your PR title ...'.
  3. Be sure to keep the PR description updated to reflect all changes.
  4. Please write your PR title to summarize what this PR proposes.
5. If possible, provide a concise example to reproduce the issue for a
faster review.
6. If applicable, include the corresponding issue number in the PR title
and link it in the body.
-->

#### Which Delta project/connector is this regarding?
<!--
Please add the component selected below to the beginning of the pull
request title
For example: [Spark] Title of my pull request
-->

- [X] Spark
- [ ] Standalone
- [ ] Flink
- [ ] Kernel
- [ ] Other (fill in here)

## Description

<!--
- Describe what this PR changes.
- Describe why we need the change.
 
If this PR resolves an issue be sure to include "Resolves #XXX" to
correctly link and close the issue upon merge.
-->
Renames LogSegment.lastCommitTimestamp to
lastCommitFileModificationTimestamp so as to distinguish this file
timestamp from in-commit-timestamp.

## How was this patch tested?

<!--
If tests were added, say they were added here. Please make sure to test
the changes thoroughly including negative and positive cases if
possible.
If the changes were tested in any way other than unit tests, please
clarify how you tested step by step (ideally copy and paste-able, so
that other reviewers can test and check, and descendants can verify in
the future).
If the changes were not tested, please explain why.
-->
Related to #2532 . 

Name-only change.

## Does this PR introduce _any_ user-facing changes?

<!--
If yes, please clarify the previous behavior and the change this PR
proposes - provide the console output, description and/or an example to
show the behavior difference if possible.
If possible, please also clarify if this is a user-facing change
compared to the released Delta Lake versions or within the unreleased
branches such as master.
If no, write 'No'.
-->
No
  • Loading branch information
dhruvarya-db authored Mar 12, 2024
1 parent d0477bb commit 3ae99ae
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,8 @@ class Snapshot(
* is retrieved from the CommitInfo of the latest commit which
* can result in an IO operation.
*/
def timestamp: Long = getInCommitTimestampOpt.getOrElse(logSegment.lastCommitTimestamp)
def timestamp: Long =
getInCommitTimestampOpt.getOrElse(logSegment.lastCommitFileModificationTimestamp)

/**
* Returns the inCommitTimestamp if ICT is enabled, otherwise returns None.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1136,7 +1136,7 @@ object SnapshotManagement {
oldLogSegment.copy(
version = committedVersion,
deltas = oldLogSegment.deltas :+ commitFileStatus,
lastCommitTimestamp = commitFileStatus.getModificationTime)
lastCommitFileModificationTimestamp = commitFileStatus.getModificationTime)
}
}

Expand Down Expand Up @@ -1186,7 +1186,7 @@ object SerializableFileStatus {
* @param version The Snapshot version to generate
* @param deltas The delta commit files (.json) to read
* @param checkpointProvider provider to give information about Checkpoint files.
* @param lastCommitTimestamp The "unadjusted" file modification timestamp of the
* @param lastCommitFileModificationTimestamp The "unadjusted" file modification timestamp of the
* last commit within this segment. By unadjusted, we mean that the commit timestamps may
* not necessarily be monotonically increasing for the commits within this segment.
*/
Expand All @@ -1195,9 +1195,10 @@ case class LogSegment(
version: Long,
deltas: Seq[FileStatus],
checkpointProvider: UninitializedCheckpointProvider,
lastCommitTimestamp: Long) {
lastCommitFileModificationTimestamp: Long) {

override def hashCode(): Int = logPath.hashCode() * 31 + (lastCommitTimestamp % 10000).toInt
override def hashCode(): Int =
logPath.hashCode() * 31 + (lastCommitFileModificationTimestamp % 10000).toInt

/**
* An efficient way to check if a cached Snapshot's contents actually correspond to a new
Expand All @@ -1206,7 +1207,8 @@ case class LogSegment(
override def equals(obj: Any): Boolean = {
obj match {
case other: LogSegment =>
version == other.version && lastCommitTimestamp == other.lastCommitTimestamp &&
version == other.version &&
lastCommitFileModificationTimestamp == other.lastCommitFileModificationTimestamp &&
logPath == other.logPath && checkpointProvider.version == other.checkpointProvider.version
case _ => false
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -480,7 +480,7 @@ class DeltaLogSuite extends QueryTest

// Store these for later usage
val actions = deltaLog.snapshot.stateDS.collect()
val commitTimestamp = deltaLog.snapshot.logSegment.lastCommitTimestamp
val commitTimestamp = deltaLog.snapshot.logSegment.lastCommitFileModificationTimestamp

checkAnswer(
spark.read.format("delta").load(path),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ class InCommitTimestampSuite
// File timestamp should be the same as snapshot.getTimestamp when inCommitTimestamp is not
// enabled
assert(
ver1Snapshot.logSegment.lastCommitTimestamp == ver1Snapshot.timestamp)
ver1Snapshot.logSegment.lastCommitFileModificationTimestamp == ver1Snapshot.timestamp)

spark.sql(s"ALTER TABLE delta.`${tempDir.getAbsolutePath}`" +
s"SET TBLPROPERTIES ('${DeltaConfigs.IN_COMMIT_TIMESTAMPS_ENABLED.key}' = 'true')")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -432,15 +432,15 @@ class OptimisticTransactionSuite

// preCommitLogSegment should not get updated until a commit is triggered
assert(testTxn.preCommitLogSegment.version == 1)
assert(testTxn.preCommitLogSegment.lastCommitTimestamp < testTxnStartTs)
assert(testTxn.preCommitLogSegment.lastCommitFileModificationTimestamp < testTxnStartTs)
assert(testTxn.preCommitLogSegment.deltas.size == 2)
assert(testTxn.preCommitLogSegment.checkpointProvider.isEmpty)

testTxn.commit(Seq.empty, ManualUpdate)

// preCommitLogSegment should get updated to the version right before the txn commits
assert(testTxn.preCommitLogSegment.version == 12)
assert(testTxn.preCommitLogSegment.lastCommitTimestamp < testTxnEndTs)
assert(testTxn.preCommitLogSegment.lastCommitFileModificationTimestamp < testTxnEndTs)
assert(testTxn.preCommitLogSegment.deltas.size == 2)
assert(testTxn.preCommitLogSegment.checkpointProvider.version == 10)
}
Expand Down

0 comments on commit 3ae99ae

Please sign in to comment.