Skip to content

Commit

Permalink
[DELTA-OSS-EXTERNAL] Parse the partition structure using the delta_lo…
Browse files Browse the repository at this point in the history
…g as the base path

This allows converting a location that is under a path that looks like a partition value. For example, running the convert to delta command over a path like `s3://massive-events/year=2020/` would fail because the command will try to compare the partitions above the delta log base path.

Signed-off-by: Mike Dias <mike.rodrigues.dias@gmail.com>

Closes #510

Signed-off-by: liwensun <liwen.sun@databricks.com>

Author: Mike Dias <mike.rodrigues.dias@gmail.com>

#12643 is resolved by liwensun/4w7hocg4.

GitOrigin-RevId: 4dc2e55c97b47b3ce928a5a780b115324170e95d
  • Loading branch information
mikedias authored and brkyvz committed Oct 15, 2020
1 parent 140401d commit ca37b4a
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -395,7 +395,7 @@ abstract class ConvertToDeltaCommandBase(
val (partitionOpt, _) = PartitionUtils.parsePartition(
dir,
typeInference = false,
basePaths = Set.empty,
basePaths = Set(basePath),
userSpecifiedDataTypes = Map.empty,
validatePartitionColumns = false,
java.util.TimeZone.getDefault,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1036,4 +1036,19 @@ trait ConvertToDeltaHiveTableTests extends ConvertToDeltaTestUtils with SQLTestU
}
}
}

test("can convert a partition-like table path") {
withTempDir { dir =>
val path = dir.getCanonicalPath
writeFiles(path, simpleDF, partCols = Seq("key1", "key2"))

val basePath = s"$path/key1=1/"
convertToDelta(s"parquet.`$basePath`", Some("key2 string"))

checkAnswer(
sql(s"select id from delta.`$basePath` where key2 = '1'"),
simpleDF.filter("id % 2 == 1").filter("id % 3 == 1").select("id"))
}
}

}

0 comments on commit ca37b4a

Please sign in to comment.