Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[GLUTEN-6604][CH] Fix mergetree partition with whitespace error #6605

Merged
merged 1 commit into from
Jul 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ object MergeTreePartsPartitionsUtil extends Logging {
partition =>
partition.files.map(
fs => {
val path = fs.getPath.toString
val path = fs.getPath.toUri.toString

val ret = ClickhouseSnapshot.pathToAddMTPCache.getIfPresent(path)
if (ret == null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -306,7 +306,8 @@ abstract class MergeTreeBaseDynamicPartitionDataWriter(
releaseCurrentWriter()
}

val partDir = partitionValues.map(getPartitionPath(_))
val partDir =
partitionValues.map(getPartitionPath(_)).map(str => new Path(str).toUri.toASCIIString)
partDir.foreach(updatedPartitions.add)

val bucketIdStr = bucketId.map(id => f"$id%05d").getOrElse("")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2022,5 +2022,33 @@ class GlutenClickHouseMergeTreeWriteSuite
|""".stripMargin
runTPCHQueryBySQL(6, sqlStr) { _ => }
}

test("test mergetree with partition with whitespace") {
spark.sql(s"""
|DROP TABLE IF EXISTS lineitem_mergetree_partition_with_whitespace;
|""".stripMargin)

spark.sql(s"""
|CREATE TABLE IF NOT EXISTS lineitem_mergetree_partition_with_whitespace
|(
| l_returnflag string,
| l_linestatus string
|)
|USING clickhouse
|PARTITIONED BY (l_returnflag)
|LOCATION '$basePath/lineitem_mergetree_partition_with_whitespace'
|""".stripMargin)

spark.sql(s"""
| insert into table lineitem_mergetree_partition_with_whitespace
| (l_returnflag, l_linestatus) values ('a A', 'abc')
|""".stripMargin)

val sqlStr =
s"""
|SELECT * from lineitem_mergetree_partition_with_whitespace
|""".stripMargin
runSql(sqlStr) { _ => }
}
}
// scalastyle:off line.size.limit
Loading