Skip to content

Commit

Permalink
Make type of logged values consistent for each logkey (#3883)
Browse files Browse the repository at this point in the history
<!--
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

Ensures that the types of logged values for each logkey are consistent.

## How was this patch tested?

Code compiles and existing tests pass.

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

No

Signed-off-by: Michael Zhang <[email protected]>
  • Loading branch information
michaelzhan-db authored Nov 18, 2024
1 parent ee87b77 commit 68275d1
Show file tree
Hide file tree
Showing 9 changed files with 19 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -128,8 +128,8 @@ trait MetadataCleanup extends DeltaLogging {
sidecarDeletionMetrics)
logInfo(log"Sidecar deletion metrics: ${MDC(DeltaLogKeys.METRICS, sidecarDeletionMetrics)}")
}
logInfo(log"Deleted ${MDC(DeltaLogKeys.NUM_FILES, numDeleted)} log files and " +
log"${MDC(DeltaLogKeys.NUM_FILES2, numDeletedUnbackfilled)} unbackfilled commit " +
logInfo(log"Deleted ${MDC(DeltaLogKeys.NUM_FILES, numDeleted.toLong)} log files and " +
log"${MDC(DeltaLogKeys.NUM_FILES2, numDeletedUnbackfilled.toLong)} unbackfilled commit " +
log"files older than ${MDC(DeltaLogKeys.DATE, formattedDate)}")
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1881,7 +1881,7 @@ trait OptimisticTransactionImpl extends TransactionalWrite

logInfo(log"Committed delta #${MDC(DeltaLogKeys.VERSION, attemptVersion)} to " +
log"${MDC(DeltaLogKeys.PATH, deltaLog.logPath)}. Wrote " +
log"${MDC(DeltaLogKeys.NUM_ACTIONS, commitSize)} actions.")
log"${MDC(DeltaLogKeys.NUM_ACTIONS, commitSize.toLong)} actions.")

deltaLog.checkpoint(currentSnapshot)
currentSnapshot
Expand Down Expand Up @@ -2044,7 +2044,7 @@ trait OptimisticTransactionImpl extends TransactionalWrite
|Detected mismatch in partition values between AddFile and table metadata but
|commit validation was turned off.
|To turn it back on set
|${MDC(DeltaLogKeys.CONFIG_KEY, DeltaSQLConf.DELTA_COMMIT_VALIDATION_ENABLED)}
|${MDC(DeltaLogKeys.CONFIG_KEY, DeltaSQLConf.DELTA_COMMIT_VALIDATION_ENABLED.key)}
|to "true"
""".stripMargin)
a
Expand Down Expand Up @@ -2284,7 +2284,7 @@ trait OptimisticTransactionImpl extends TransactionalWrite
val actions = currentTransactionInfo.finalActionsToCommit
logInfo(
log"Attempting to commit version ${MDC(DeltaLogKeys.VERSION, attemptVersion)} with " +
log"${MDC(DeltaLogKeys.NUM_ACTIONS, actions.size)} actions with " +
log"${MDC(DeltaLogKeys.NUM_ACTIONS, actions.size.toLong)} actions with " +
log"${MDC(DeltaLogKeys.ISOLATION_LEVEL, isolationLevel)} isolation level")

if (readVersion > -1 && metadata.id != snapshot.metadata.id) {
Expand Down Expand Up @@ -2588,7 +2588,7 @@ trait OptimisticTransactionImpl extends TransactionalWrite
log"${MDC(DeltaLogKeys.NUM_ACTIONS, adds)} adds, " +
log"${MDC(DeltaLogKeys.NUM_ACTIONS2, removes)} removes, " +
log"${MDC(DeltaLogKeys.NUM_PREDICATES, readPredicates.size)} read predicates, " +
log"${MDC(DeltaLogKeys.NUM_FILES, readFiles.size)} read files"
log"${MDC(DeltaLogKeys.NUM_FILES, readFiles.size.toLong)} read files"
}

logInfo(logPrefix +
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -311,7 +311,8 @@ abstract class ConvertToDeltaCommandBase(
_, txn.deltaLog.dataPath, fs, conf, Some(partitionSchema), deltaPath.isDefined))
if (shouldCollectStats) {
logInfo(
log"Collecting stats for a batch of ${MDC(DeltaLogKeys.NUM_FILES, batch.size)} files; " +
log"Collecting stats for a batch of " +
log"${MDC(DeltaLogKeys.NUM_FILES, batch.size.toLong)} files; " +
log"finished ${MDC(DeltaLogKeys.NUM_FILES2, numFiles)} so far"
)
numFiles += statsBatchSize
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ trait ReorgTableForUpgradeUniformHelper extends DeltaLogging {
log"at version ${MDC(DeltaLogKeys.VERSION, snapshot.version)}, there are " +
log"${MDC(DeltaLogKeys.NUM_FILES, numOfAddFiles)} addFiles, and " +
log"${MDC(DeltaLogKeys.NUM_FILES2, numOfAddFilesWithTag)} addFiles with " +
log"ICEBERG_COMPAT_VERSION=${MDC(DeltaLogKeys.VERSION2, icebergCompatVersion)} tag.")
log"ICEBERG_COMPAT_VERSION=${MDC(DeltaLogKeys.VERSION2, icebergCompatVersion.toLong)} tag.")
(numOfAddFiles, numOfAddFilesWithTag)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -423,10 +423,10 @@ object VacuumCommand extends VacuumCommandImpl with Serializable {
)

recordDeltaEvent(deltaLog, "delta.gc.stats", data = stats)
logInfo(log"Found ${MDC(DeltaLogKeys.NUM_FILES, numFiles)} files " +
logInfo(log"Found ${MDC(DeltaLogKeys.NUM_FILES, numFiles.toLong)} files " +
log"(${MDC(DeltaLogKeys.NUM_BYTES, sizeOfDataToDelete)} bytes) and directories in " +
log"a total of ${MDC(DeltaLogKeys.NUM_DIRS, dirCounts)} directories " +
log"that are safe to delete. Vacuum stats: ${MDC(DeltaLogKeys.STATS, stats)}")
log"that are safe to delete. Vacuum stats: ${MDC(DeltaLogKeys.VACUUM_STATS, stats)}")

return diffFiles.map(f => urlEncodedStringToPath(f).toString).toDF("path")
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,8 @@ trait BackfillBatch extends DeltaLogging {
)
}

logInfo(log"Batch ${MDC(DeltaLogKeys.BATCH_ID, batchId)} starting, committing " +
log"${MDC(DeltaLogKeys.NUM_FILES, filesInBatch.size)} candidate files")
logInfo(log"Batch ${MDC(DeltaLogKeys.BATCH_ID, batchId.toLong)} starting, committing " +
log"${MDC(DeltaLogKeys.NUM_FILES, filesInBatch.size.toLong)} candidate files")
// This step is necessary to mark all files in this batch as "read" in the
// child transaction object `txn` and to set the read transactions ids to be the same as the
// parent transaction object `origTxn`, for proper conflict checking.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -337,7 +337,7 @@ trait GenerateSymlinkManifestImpl extends PostCommitHook with DeltaLogging with
}

logInfo(log"Deleted manifest partitions [" +
log"${MDC(DeltaLogKeys.NUM_FILES, partitionRelativePathsToDelete.size)}]:\n\t" +
log"${MDC(DeltaLogKeys.NUM_FILES, partitionRelativePathsToDelete.size.toLong)}]:\n\t" +
log"${MDC(DeltaLogKeys.PATHS, partitionRelativePathsToDelete.mkString("\n\t"))}")
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,8 +93,8 @@ case class DeltaSink(
logInfo(
log"Committed transaction, batchId=${MDC(DeltaLogKeys.BATCH_ID, batchId)}, " +
log"duration=${MDC(DeltaLogKeys.DURATION, durationMs)} ms, " +
log"added ${MDC(DeltaLogKeys.NUM_FILES, newFiles.size)} files, " +
log"removed ${MDC(DeltaLogKeys.NUM_FILES2, deletedFiles.size)} files.")
log"added ${MDC(DeltaLogKeys.NUM_FILES, newFiles.size.toLong)} files, " +
log"removed ${MDC(DeltaLogKeys.NUM_FILES2, deletedFiles.size.toLong)} files.")
val executionId = sc.getLocalProperty(SQLExecution.EXECUTION_ID_KEY)
SQLMetrics.postDriverMetricUpdates(sc, executionId, metrics.values.toSeq)
}
Expand Down Expand Up @@ -153,8 +153,8 @@ case class DeltaSink(
val totalSize = newFiles.map(_.getFileSize).sum
val totalLogicalRecords = newFiles.map(_.numLogicalRecords.getOrElse(0L)).sum
logInfo(
log"Wrote ${MDC(DeltaLogKeys.NUM_FILES, newFiles.size)} files, with total size " +
log"${MDC(DeltaLogKeys.NUM_BYTES, totalSize)}, " +
log"Wrote ${MDC(DeltaLogKeys.NUM_FILES, newFiles.size.toLong)} files, " +
log"with total size ${MDC(DeltaLogKeys.NUM_BYTES, totalSize)}, " +
log"${MDC(DeltaLogKeys.NUM_RECORDS, totalLogicalRecords)} logical records, " +
log"duration=${MDC(DeltaLogKeys.DURATION, writeFilesTimeMs)} ms.")

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ object DeltaFileOperations extends DeltaLogging {
base: Int = 100,
jitter: Int = 1000): Unit = {
val sleepTime = Random.nextInt(jitter) + base
logWarning(log"Sleeping for ${MDC(DeltaLogKeys.TIME_MS, sleepTime)} ms to rate limit " +
logWarning(log"Sleeping for ${MDC(DeltaLogKeys.TIME_MS, sleepTime.toLong)} ms to rate limit " +
log"${MDC(DeltaLogKeys.OP_NAME, opName)}", t)
Thread.sleep(sleepTime)
}
Expand Down

0 comments on commit 68275d1

Please sign in to comment.