Skip to content

Commit

Permalink
Revert "Skip getFileStatus call during iceberg to delta clone" (#3855)
Browse files Browse the repository at this point in the history
This reverts commit a2ba9e9. The
approach needs to be revisited and prepared in separate PR later.

<!--
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.
-->

## 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.
-->

## 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'.
-->
  • Loading branch information
lzlfred authored Nov 8, 2024
1 parent 6257799 commit f4dbc9b
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 28 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -109,16 +109,12 @@ class IcebergFileManifest(
spark.sessionState.conf.getConf(DeltaSQLConf.DELTA_CONVERT_ICEBERG_UNSAFE_MOR_TABLE_ENABLE)

var numFiles = 0L
val skipGetFileStatus = spark.sessionState.conf.getConf(
DeltaSQLConf.DELTA_CLONE_ICEBERG_SKIP_GETFILESTATUS)
val snapshotTimestamp: Option[Long] = Option(table.currentSnapshot()).map(_.timestampMillis())

val res = table.newScan().planFiles().iterator().asScala.grouped(schemaBatchSize).map { batch =>
logInfo(log"Getting file statuses for a batch of " +
log"${MDC(DeltaLogKeys.BATCH_SIZE, batch.size)} of files; " +
log"finished ${MDC(DeltaLogKeys.NUM_FILES, numFiles)} files so far")
numFiles += batch.length
val filePathWithPartValuesAndSize = batch.map { fileScanTask =>
val filePathWithPartValues = batch.map { fileScanTask =>
val filePath = fileScanTask.file().path().toString
// If an Iceberg table has deletion file associated with the data file (Supported in
// Iceberg V2, either position deletes or equality deletes), we could not convert directly.
Expand All @@ -133,23 +129,18 @@ class IcebergFileManifest(
Some(convertIcebergPartitionToPartitionValues(
fileScanTask.file().partition()))
} else None
(filePath, partitionValues, fileScanTask.file.fileSizeInBytes())
(filePath, partitionValues)
}
val numParallelism = Math.min(Math.max(filePathWithPartValuesAndSize.size, 1),
val numParallelism = Math.min(Math.max(filePathWithPartValues.size, 1),
spark.sparkContext.defaultParallelism)

val rdd = spark.sparkContext.parallelize(filePathWithPartValuesAndSize, numParallelism)
val rdd = spark.sparkContext.parallelize(filePathWithPartValues, numParallelism)
.mapPartitions { iterator =>
iterator.map { case (filePath, partValues, size) =>
val serializableFileStatus = (skipGetFileStatus, snapshotTimestamp) match {
case (true, Some(ts)) =>
SerializableFileStatus(filePath, size, isDir = false, ts)
case _ =>
val path = new Path(filePath)
val fs = path.getFileSystem(conf.value.value)
SerializableFileStatus.fromStatus(fs.getFileStatus(path))
}
ConvertTargetFile(serializableFileStatus, partValues)
iterator.map { case (filePath, partValues) =>
val path = new Path(filePath)
val fs = path.getFileSystem(conf.value.value)
val fileStatus = fs.getFileStatus(path)
ConvertTargetFile(SerializableFileStatus.fromStatus(fileStatus), partValues)
}
}
spark.createDataset(rdd)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,7 @@ abstract class CloneConvertedSource(spark: SparkSession) extends CloneSource {
val basePath = new Path(baseDir)
val fs = basePath.getFileSystem(conf.value.value)
targetFile.map(ConvertUtils.createAddFile(
_, basePath, fs, SQLConf.get, Some(partitionSchema), useAbsolutePath = true))
_, basePath, fs, SQLConf.get, Some(partitionSchema)))
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1717,15 +1717,6 @@ trait DeltaSQLConfBase {
.booleanConf
.createWithDefault(true)

val DELTA_CLONE_ICEBERG_SKIP_GETFILESTATUS = {
buildConf("clone.IcebergSkipGetFileStatus")
.internal()
.doc("If clone with Iceberg source can skip getFileStatus and " +
"use snapshot timestamp as the modificationTime for Delta AddFile")
.booleanConf
.createWithDefault(true)
}

val DELTA_OPTIMIZE_METADATA_QUERY_ENABLED =
buildConf("optimizeMetadataQuery.enabled")
.internal()
Expand Down

0 comments on commit f4dbc9b

Please sign in to comment.