You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hudi.apache.org by "SEPURI-SAI-KRISHNA (via GitHub)" <gi...@apache.org> on 2026/08/17 11:07:49 UTC
[PR] fix(spark): make slash-separated date partitioning work on the row writer path [hudi]
SEPURI-SAI-KRISHNA opened a new pull request, #19648:
URL: https://github.com/apache/hudi/pull/19648
### Describe the issue this Pull Request addresses
Closes #19647.
With `hoodie.datasource.write.slash.separated.date.partitioning=true`, every write that goes through
Spark's row writer (bulk insert, `INSERT INTO` with `hoodie.sql.bulk.insert.enable=true`, and any
path calling `SparkKeyGeneratorInterface#getPartitionPath(InternalRow, StructType)`) fails with:
```
java.lang.ClassCastException: class org.apache.spark.unsafe.types.UTF8String cannot be cast to
class java.lang.String
```
and a `null` value in the partition column fails with a `NullPointerException` on both the row
writer and the `Row` write paths.
`PartitionPathFormatterBase#combine` is generic over the string representation `S` it builds
(`String` for the Avro/`Row` write paths, `UTF8String` for the row writer), but the
slash-separated-date branch hard-casts to `java.lang.String`:
```java
if (slashSeparatedDatePartitioning) {
return ((S) ((String) toString(partitionPathParts[0])).replace('-', '/'));
} else {
return tryEncode(handleEmpty(toString(partitionPathParts[0])));
}
```
That branch also skips `handleEmpty` and `tryEncode`, so a null/empty partition value NPEs instead
of landing in `__HIVE_DEFAULT_PARTITION__`, and URL encoding is silently dropped.
The multi-field loop has the same hard-cast, and additionally applied the `-` -> `/` substitution to
*every* partition field, which the Avro write path
(`KeyGenUtils#getRecordPartitionPath`) does not do — it only substitutes when the table is
partitioned by a single column. The two write paths therefore derived different partition paths for
the same record.
The feature's existing coverage only exercises the Avro key-generator path
(`getKey(GenericRecord)`), which is why none of this was caught.
### Summary and Changelog
Slash-separated date partitioning now works on the Spark row-writer path and handles null partition
values, and both write paths derive the same partition path.
- `PartitionPathFormatterBase`: replaced the `(String)` hard-cast with a new abstract
`replaceDashesWithSlashes(S)` hook, so the substitution happens on the concrete string
representation the formatter operates on.
- `PartitionPathFormatterBase`: the single-field fast path now runs `handleEmpty` and `tryEncode`
before the substitution, matching the multi-field loop and `KeyGenUtils#getPartitionPath`.
- `PartitionPathFormatterBase`: dropped the substitution from the multi-field loop, aligning it with
`KeyGenUtils#getRecordPartitionPath` on the Avro write path (slash-separated date partitioning
only applies to a table partitioned by a single date column). Hive-style partitioning keeps
precedence exactly as before.
- `StringPartitionPathFormatter` / `UTF8StringPartitionPathFormatter`: implement the new hook
(`String#replace` and `UTF8String#replace` respectively).
- Tests: new `TestPartitionPathFormatter` covering both formatter flavors (single/multi field, null
and empty values, encoding, hive-style precedence); new row-writer and null-value cases in
`TestSimpleKeyGenerator`; new end-to-end row-writer case in `TestSlashSeparatedPartitionValue`.
Verified that each new test fails on `master` with the exact `ClassCastException` /
`NullPointerException` above and passes with the fix.
### Impact
Fixes a hard failure on the Spark row-writer write path for tables using
`hoodie.datasource.write.slash.separated.date.partitioning`. No public API change and no storage
format change.
Affects 1.2.0 and master: the feature landed in #17787, which is an ancestor of `release-1.2.0`.
Behavior change: for a table with **more than one** partition field and slash-separated date
partitioning enabled, the `Row`/`InternalRow` write paths no longer substitute `-` with `/` in the
partition path. This makes them agree with the Avro write path, which is the behavior the table was
already written with — the row-writer variant of that combination could not previously run at all
(it threw the `ClassCastException`).
### Risk Level
low
The change is confined to partition-path formatting for the row-writer paths of the key generators.
The previously broken paths threw before producing any output, and the newly aligned multi-field
behavior matches the Avro write path that existing tables were written with. Covered by 103
`hudi-spark-client` key-generator/bulk-insert tests and the `TestSlashSeparatedPartitionValue` and
`TestShowPartitions` Spark SQL suites, all green.
### Documentation Update
none — no new configs and no change to the documented behavior of
`hoodie.datasource.write.slash.separated.date.partitioning`.
### Contributor's checklist
- [x] Read through [contributor's guide](https://hudi.apache.org/contribute/how-to-contribute)
- [x] Enough context is provided in the sections above
- [x] Adequate tests were added if applicable
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@hudi.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] fix(spark): make slash-separated date partitioning work on the row writer path [hudi]
Posted by "voonhous (via GitHub)" <gi...@apache.org>.
voonhous commented on code in PR #19648:
URL: https://github.com/apache/hudi/pull/19648#discussion_r3819041736
##########
hudi-spark-datasource/hudi-spark/src/test/scala/org/apache/spark/sql/hudi/common/TestSlashSeparatedPartitionValue.scala:
##########
@@ -90,6 +90,113 @@ class TestSlashSeparatedPartitionValue extends HoodieSparkSqlTestBase {
}
}
+ test("Test slash separated date partitions written through the row writer") {
+ withSQLConf("hoodie.spark.sql.insert.into.operation" -> "bulk_insert") {
+ withTempDir { tmp =>
+ val targetTable = generateTableName
+ val tablePath = s"${tmp.getCanonicalPath}/$targetTable"
+
+ spark.sql(
+ s"""
+ |create table $targetTable (
+ | `id` string,
+ | `name` string,
+ | `ts` bigint,
+ | `datestr` STRING
+ |) using hudi
+ | tblproperties (
+ | 'primaryKey' = 'id',
+ | 'type' = 'COW',
+ | 'preCombineField'='ts',
+ | 'hoodie.datasource.write.slash.separated.date.partitioning'='true'
+ | )
+ | partitioned by (`datestr`)
+ | location '$tablePath'
+ """.stripMargin)
+
+ // NOTE: The row writer derives the partition path off of an [[InternalRow]], which used to
+ // blow up with a [[ClassCastException]]; a null partition value used to NPE
+ spark.sql(
+ s"""
+ | insert into $targetTable values
+ | (1, 'a1', 1000, "2026-01-05"),
+ | (2, 'a2', 2000, "2026-01-06"),
+ | (3, 'a3', 3000, null)
+ """.stripMargin)
+
+ checkAnswer(s"select id, name, ts, _hoodie_partition_path, datestr from $targetTable order by id")(
Review Comment:
Read-back passes here because the Spark-side `doParsePartitionColumnValues` handles the slash layout, but the engine-agnostic `PartitionPathParser#getPartitionValues` does not for a STRING partition column: `2026/01/05` parses to `2026`, since only time-typed fields go through `inferDateValue` and everything else takes `parts[0]`. Its lone consumer today is the bootstrap-merge read (`HoodieFileGroupReader.java:284`).
Optional, nothing to change in this PR: pre-existing and untouched by this change -- I will file the `PartitionPathParser` follow-up if you do not pick it up. Recorded here for context.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@hudi.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] fix(spark): make slash-separated date partitioning work on the row writer path [hudi]
Posted by "hudi-bot (via GitHub)" <gi...@apache.org>.
hudi-bot commented on PR #19648:
URL: https://github.com/apache/hudi/pull/19648#issuecomment-5395623575
<!--
Meta data
{
"version" : 1,
"metaDataEntries" : [ {
"hash" : "ce3ab56d080092972df722ab619a3cf71308b6c2",
"status" : "DELETED",
"url" : "https://dev.azure.com/apachehudi/a1a51da7-8592-47d4-88dc-fd67bed336bb/_build/results?buildId=16342",
"triggerID" : "ce3ab56d080092972df722ab619a3cf71308b6c2",
"triggerType" : "PUSH"
}, {
"hash" : "8d523937035c816ddf765ac61acad162e311b738",
"status" : "DELETED",
"url" : "https://dev.azure.com/apachehudi/a1a51da7-8592-47d4-88dc-fd67bed336bb/_build/results?buildId=16390",
"triggerID" : "8d523937035c816ddf765ac61acad162e311b738",
"triggerType" : "PUSH"
}, {
"hash" : "fdd04bfbf709f806768ae4b4b259a679b08e2aa4",
"status" : "DELETED",
"url" : "https://dev.azure.com/apachehudi/a1a51da7-8592-47d4-88dc-fd67bed336bb/_build/results?buildId=16413",
"triggerID" : "fdd04bfbf709f806768ae4b4b259a679b08e2aa4",
"triggerType" : "PUSH"
}, {
"hash" : "8f1cb373283c41cf6513e83b169e692902c91c4e",
"status" : "DELETED",
"url" : "https://dev.azure.com/apachehudi/a1a51da7-8592-47d4-88dc-fd67bed336bb/_build/results?buildId=16440",
"triggerID" : "8f1cb373283c41cf6513e83b169e692902c91c4e",
"triggerType" : "PUSH"
}, {
"hash" : "8ce9ad0a09e3fc8a889eefab03abc38f6a1e8aa5",
"status" : "DELETED",
"url" : "https://dev.azure.com/apachehudi/a1a51da7-8592-47d4-88dc-fd67bed336bb/_build/results?buildId=16477",
"triggerID" : "8ce9ad0a09e3fc8a889eefab03abc38f6a1e8aa5",
"triggerType" : "PUSH"
}, {
"hash" : "2d738376d122aa8b60243bd99f216f5b8b3fa217",
"status" : "DELETED",
"url" : "https://dev.azure.com/apachehudi/a1a51da7-8592-47d4-88dc-fd67bed336bb/_build/results?buildId=16484",
"triggerID" : "2d738376d122aa8b60243bd99f216f5b8b3fa217",
"triggerType" : "PUSH"
}, {
"hash" : "493712b3d69c542864eebf43d0c090276c55bfc6",
"status" : "SUCCESS",
"url" : "https://dev.azure.com/apachehudi/a1a51da7-8592-47d4-88dc-fd67bed336bb/_build/results?buildId=16505",
"triggerID" : "493712b3d69c542864eebf43d0c090276c55bfc6",
"triggerType" : "PUSH"
}, {
"hash" : "073f3ca3e82c84c1be52833f0b7078b8ecec3614",
"status" : "UNKNOWN",
"url" : "TBD",
"triggerID" : "073f3ca3e82c84c1be52833f0b7078b8ecec3614",
"triggerType" : "PUSH"
}, {
"hash" : "8cd021a924d18b1f761beb318d23dca5550d6eb8",
"status" : "PENDING",
"url" : "https://dev.azure.com/apachehudi/a1a51da7-8592-47d4-88dc-fd67bed336bb/_build/results?buildId=16506",
"triggerID" : "8cd021a924d18b1f761beb318d23dca5550d6eb8",
"triggerType" : "PUSH"
} ]
}-->
## CI report:
* 493712b3d69c542864eebf43d0c090276c55bfc6 Azure: [SUCCESS](https://dev.azure.com/apachehudi/a1a51da7-8592-47d4-88dc-fd67bed336bb/_build/results?buildId=16505)
* 073f3ca3e82c84c1be52833f0b7078b8ecec3614 UNKNOWN
* 8cd021a924d18b1f761beb318d23dca5550d6eb8 Azure: [PENDING](https://dev.azure.com/apachehudi/a1a51da7-8592-47d4-88dc-fd67bed336bb/_build/results?buildId=16506)
<details>
<summary>Bot commands</summary>
@hudi-bot supports the following commands:
- `@hudi-bot run azure` re-run the last Azure build
</details>
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@hudi.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] fix(spark): make slash-separated date partitioning work on the row writer path [hudi]
Posted by "hudi-bot (via GitHub)" <gi...@apache.org>.
hudi-bot commented on PR #19648:
URL: https://github.com/apache/hudi/pull/19648#issuecomment-5379326261
<!--
Meta data
{
"version" : 1,
"metaDataEntries" : [ {
"hash" : "ce3ab56d080092972df722ab619a3cf71308b6c2",
"status" : "DELETED",
"url" : "https://dev.azure.com/apachehudi/a1a51da7-8592-47d4-88dc-fd67bed336bb/_build/results?buildId=16342",
"triggerID" : "ce3ab56d080092972df722ab619a3cf71308b6c2",
"triggerType" : "PUSH"
}, {
"hash" : "8d523937035c816ddf765ac61acad162e311b738",
"status" : "DELETED",
"url" : "https://dev.azure.com/apachehudi/a1a51da7-8592-47d4-88dc-fd67bed336bb/_build/results?buildId=16390",
"triggerID" : "8d523937035c816ddf765ac61acad162e311b738",
"triggerType" : "PUSH"
}, {
"hash" : "fdd04bfbf709f806768ae4b4b259a679b08e2aa4",
"status" : "DELETED",
"url" : "https://dev.azure.com/apachehudi/a1a51da7-8592-47d4-88dc-fd67bed336bb/_build/results?buildId=16413",
"triggerID" : "fdd04bfbf709f806768ae4b4b259a679b08e2aa4",
"triggerType" : "PUSH"
}, {
"hash" : "8f1cb373283c41cf6513e83b169e692902c91c4e",
"status" : "DELETED",
"url" : "https://dev.azure.com/apachehudi/a1a51da7-8592-47d4-88dc-fd67bed336bb/_build/results?buildId=16440",
"triggerID" : "8f1cb373283c41cf6513e83b169e692902c91c4e",
"triggerType" : "PUSH"
}, {
"hash" : "8ce9ad0a09e3fc8a889eefab03abc38f6a1e8aa5",
"status" : "SUCCESS",
"url" : "https://dev.azure.com/apachehudi/a1a51da7-8592-47d4-88dc-fd67bed336bb/_build/results?buildId=16477",
"triggerID" : "8ce9ad0a09e3fc8a889eefab03abc38f6a1e8aa5",
"triggerType" : "PUSH"
} ]
}-->
## CI report:
* 8ce9ad0a09e3fc8a889eefab03abc38f6a1e8aa5 Azure: [SUCCESS](https://dev.azure.com/apachehudi/a1a51da7-8592-47d4-88dc-fd67bed336bb/_build/results?buildId=16477)
<details>
<summary>Bot commands</summary>
@hudi-bot supports the following commands:
- `@hudi-bot run azure` re-run the last Azure build
</details>
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@hudi.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] fix(spark): make slash-separated date partitioning work on the row writer path [hudi]
Posted by "hudi-bot (via GitHub)" <gi...@apache.org>.
hudi-bot commented on PR #19648:
URL: https://github.com/apache/hudi/pull/19648#issuecomment-5316357924
<!--
Meta data
{
"version" : 1,
"metaDataEntries" : [ {
"hash" : "bca4b97c14ab1bda65aeb7f3b8466a4fe60b6684",
"status" : "FAILURE",
"url" : "https://dev.azure.com/apachehudi/a1a51da7-8592-47d4-88dc-fd67bed336bb/_build/results?buildId=16339",
"triggerID" : "bca4b97c14ab1bda65aeb7f3b8466a4fe60b6684",
"triggerType" : "PUSH"
}, {
"hash" : "ce3ab56d080092972df722ab619a3cf71308b6c2",
"status" : "PENDING",
"url" : "https://dev.azure.com/apachehudi/a1a51da7-8592-47d4-88dc-fd67bed336bb/_build/results?buildId=16342",
"triggerID" : "ce3ab56d080092972df722ab619a3cf71308b6c2",
"triggerType" : "PUSH"
} ]
}-->
## CI report:
* bca4b97c14ab1bda65aeb7f3b8466a4fe60b6684 Azure: [FAILURE](https://dev.azure.com/apachehudi/a1a51da7-8592-47d4-88dc-fd67bed336bb/_build/results?buildId=16339)
* ce3ab56d080092972df722ab619a3cf71308b6c2 Azure: [PENDING](https://dev.azure.com/apachehudi/a1a51da7-8592-47d4-88dc-fd67bed336bb/_build/results?buildId=16342)
<details>
<summary>Bot commands</summary>
@hudi-bot supports the following commands:
- `@hudi-bot run azure` re-run the last Azure build
</details>
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@hudi.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] fix(spark): make slash-separated date partitioning work on the row writer path [hudi]
Posted by "SEPURI-SAI-KRISHNA (via GitHub)" <gi...@apache.org>.
SEPURI-SAI-KRISHNA commented on PR #19648:
URL: https://github.com/apache/hudi/pull/19648#issuecomment-5316184263
Thanks — both addressed.
Renamed the test parameter `unsafe` -> `useRowWriterPath`.
On hive-style + slash-separated: the facts are right, but that combination is rejected at table creation, so it is unreachable rather than divergent —
`HoodieCatalogTable#extraTableConfig` has `ValidationUtils.checkArgument(!(sqlOptions.contains(HIVE_STYLE_PARTITIONING_ENABLE.key) &&
sqlOptions.contains(SLASH_SEPARATED_DATE_PARTITIONING.key)), "Table configs cannot contain both ...")`, matching the config docs ("Cannot be used together with hive-style
partitioning").
I also would not want to mirror the Avro behavior here: it applies `replace(char, char)` to the whole `field=value` string, so a partition field named e.g. `order-date` yields
`order/date=2026/01/05` — an extra spurious directory level. Copying that would propagate a bug rather than remove a divergence.
Left the behavior as-is and added a comment on `testHiveStylePartitioningTakesPrecedence` recording that it pins pre-existing behavior for an unreachable combination, not a claim
about what that combination should produce.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@hudi.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] fix(spark): make slash-separated date partitioning work on the row writer path [hudi]
Posted by "voonhous (via GitHub)" <gi...@apache.org>.
voonhous commented on PR #19648:
URL: https://github.com/apache/hudi/pull/19648#issuecomment-5353902508
The azure failure is fixed in a separate PR, it's unrelated to this. Thanks.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@hudi.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] fix(spark): make slash-separated date partitioning work on the row writer path [hudi]
Posted by "hudi-bot (via GitHub)" <gi...@apache.org>.
hudi-bot commented on PR #19648:
URL: https://github.com/apache/hudi/pull/19648#issuecomment-5365723199
<!--
Meta data
{
"version" : 1,
"metaDataEntries" : [ {
"hash" : "ce3ab56d080092972df722ab619a3cf71308b6c2",
"status" : "DELETED",
"url" : "https://dev.azure.com/apachehudi/a1a51da7-8592-47d4-88dc-fd67bed336bb/_build/results?buildId=16342",
"triggerID" : "ce3ab56d080092972df722ab619a3cf71308b6c2",
"triggerType" : "PUSH"
}, {
"hash" : "8d523937035c816ddf765ac61acad162e311b738",
"status" : "DELETED",
"url" : "https://dev.azure.com/apachehudi/a1a51da7-8592-47d4-88dc-fd67bed336bb/_build/results?buildId=16390",
"triggerID" : "8d523937035c816ddf765ac61acad162e311b738",
"triggerType" : "PUSH"
}, {
"hash" : "fdd04bfbf709f806768ae4b4b259a679b08e2aa4",
"status" : "DELETED",
"url" : "https://dev.azure.com/apachehudi/a1a51da7-8592-47d4-88dc-fd67bed336bb/_build/results?buildId=16413",
"triggerID" : "fdd04bfbf709f806768ae4b4b259a679b08e2aa4",
"triggerType" : "PUSH"
}, {
"hash" : "8f1cb373283c41cf6513e83b169e692902c91c4e",
"status" : "FAILURE",
"url" : "https://dev.azure.com/apachehudi/a1a51da7-8592-47d4-88dc-fd67bed336bb/_build/results?buildId=16440",
"triggerID" : "8f1cb373283c41cf6513e83b169e692902c91c4e",
"triggerType" : "PUSH"
} ]
}-->
## CI report:
* 8f1cb373283c41cf6513e83b169e692902c91c4e Azure: [FAILURE](https://dev.azure.com/apachehudi/a1a51da7-8592-47d4-88dc-fd67bed336bb/_build/results?buildId=16440)
<details>
<summary>Bot commands</summary>
@hudi-bot supports the following commands:
- `@hudi-bot run azure` re-run the last Azure build
</details>
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@hudi.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] fix(spark): make slash-separated date partitioning work on the row writer path [hudi]
Posted by "hudi-bot (via GitHub)" <gi...@apache.org>.
hudi-bot commented on PR #19648:
URL: https://github.com/apache/hudi/pull/19648#issuecomment-5354436449
<!--
Meta data
{
"version" : 1,
"metaDataEntries" : [ {
"hash" : "ce3ab56d080092972df722ab619a3cf71308b6c2",
"status" : "DELETED",
"url" : "https://dev.azure.com/apachehudi/a1a51da7-8592-47d4-88dc-fd67bed336bb/_build/results?buildId=16342",
"triggerID" : "ce3ab56d080092972df722ab619a3cf71308b6c2",
"triggerType" : "PUSH"
}, {
"hash" : "8d523937035c816ddf765ac61acad162e311b738",
"status" : "FAILURE",
"url" : "https://dev.azure.com/apachehudi/a1a51da7-8592-47d4-88dc-fd67bed336bb/_build/results?buildId=16390",
"triggerID" : "8d523937035c816ddf765ac61acad162e311b738",
"triggerType" : "PUSH"
}, {
"hash" : "fdd04bfbf709f806768ae4b4b259a679b08e2aa4",
"status" : "PENDING",
"url" : "https://dev.azure.com/apachehudi/a1a51da7-8592-47d4-88dc-fd67bed336bb/_build/results?buildId=16413",
"triggerID" : "fdd04bfbf709f806768ae4b4b259a679b08e2aa4",
"triggerType" : "PUSH"
} ]
}-->
## CI report:
* 8d523937035c816ddf765ac61acad162e311b738 Azure: [FAILURE](https://dev.azure.com/apachehudi/a1a51da7-8592-47d4-88dc-fd67bed336bb/_build/results?buildId=16390)
* fdd04bfbf709f806768ae4b4b259a679b08e2aa4 Azure: [PENDING](https://dev.azure.com/apachehudi/a1a51da7-8592-47d4-88dc-fd67bed336bb/_build/results?buildId=16413)
<details>
<summary>Bot commands</summary>
@hudi-bot supports the following commands:
- `@hudi-bot run azure` re-run the last Azure build
</details>
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@hudi.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] fix(spark): make slash-separated date partitioning work on the row writer path [hudi]
Posted by "voonhous (via GitHub)" <gi...@apache.org>.
voonhous commented on code in PR #19648:
URL: https://github.com/apache/hudi/pull/19648#discussion_r3813358360
##########
hudi-client/hudi-spark-client/src/main/java/org/apache/hudi/keygen/PartitionPathFormatterBase.java:
##########
@@ -75,15 +75,11 @@ public final S combine(List<String> partitionPathFields, Object... partitionPath
if (useHiveStylePartitioning) {
Review Comment:
Strengthening this: "unreachable" holds only for SQL DDL. The guard is `HoodieCatalogTable#extraTableConfig:296-300` and inspects `sqlOptions` only; `HoodieWriterUtils`, `HoodieSparkSqlWriter` and `BaseKeyGenerator` have no equivalent, so `df.write.format("hudi")` and HoodieStreamer accept `hive_style_partitioning=true` + `slash.separated.date.partitioning=true`. With a single partition field that table gets `date_col=2026/01/05` from the Avro path and `date_col=2026-01-05` from the InternalRow path, and both are live (`HoodieCreateRecordUtils` AVRO vs SPARK record type, plus the row writer). The Avro layout is also not readable: `HoodieSparkUtils.doParsePartitionColumnValues:306-312` takes the `date_col=` prefix branch and never restores `/` -> `-`. Agree with not mirroring Avro.
**Ask:** drop the "this combination is unreachable" sentence from the `testHiveStylePartitioningTakesPrecedence` comment (`TestPartitionPathFormatter.java:98-102`) -- it pins a non-discriminating value and will mislead the next reader; either delete that test or keep it with the comment corrected. The all-write-paths mutual-exclusion check (e.g. `HoodieWriterUtils.validateTableConfig`) can be here or a linked follow-up.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@hudi.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] fix(spark): make slash-separated date partitioning work on the row writer path [hudi]
Posted by "hudi-bot (via GitHub)" <gi...@apache.org>.
hudi-bot commented on PR #19648:
URL: https://github.com/apache/hudi/pull/19648#issuecomment-5316295102
<!--
Meta data
{
"version" : 1,
"metaDataEntries" : [ {
"hash" : "bca4b97c14ab1bda65aeb7f3b8466a4fe60b6684",
"status" : "FAILURE",
"url" : "https://dev.azure.com/apachehudi/a1a51da7-8592-47d4-88dc-fd67bed336bb/_build/results?buildId=16339",
"triggerID" : "bca4b97c14ab1bda65aeb7f3b8466a4fe60b6684",
"triggerType" : "PUSH"
}, {
"hash" : "ce3ab56d080092972df722ab619a3cf71308b6c2",
"status" : "UNKNOWN",
"url" : "TBD",
"triggerID" : "ce3ab56d080092972df722ab619a3cf71308b6c2",
"triggerType" : "PUSH"
} ]
}-->
## CI report:
* bca4b97c14ab1bda65aeb7f3b8466a4fe60b6684 Azure: [FAILURE](https://dev.azure.com/apachehudi/a1a51da7-8592-47d4-88dc-fd67bed336bb/_build/results?buildId=16339)
* ce3ab56d080092972df722ab619a3cf71308b6c2 UNKNOWN
<details>
<summary>Bot commands</summary>
@hudi-bot supports the following commands:
- `@hudi-bot run azure` re-run the last Azure build
</details>
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@hudi.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] fix(spark): make slash-separated date partitioning work on the row writer path [hudi]
Posted by "SEPURI-SAI-KRISHNA (via GitHub)" <gi...@apache.org>.
SEPURI-SAI-KRISHNA commented on code in PR #19648:
URL: https://github.com/apache/hudi/pull/19648#discussion_r3836313740
##########
hudi-client/hudi-client-common/src/main/java/org/apache/hudi/keygen/KeyGenUtils.java:
##########
@@ -291,12 +292,30 @@ public static String getPartitionPath(GenericRecord record, String partitionPath
if (hiveStylePartitioning) {
partitionPath = partitionPathField + "=" + partitionPath;
}
+ // NOTE: See [[slashSeparateDateValue]] on why a leading dash suppresses the substitution
if (slashSeparatedDatePartitioning) {
- partitionPath = partitionPath.replace('-', '/');
+ partitionPath = slashSeparateDateValue(partitionPath);
Review Comment:
Applied at both call sites -- the substitution now runs before the `field=` prefix, so the guard inspects the bare value and the two write paths guard the same string.
You are right that it is otherwise behaviour-preserving: `"dt="` contains no dash, so for every value that is not guarded the result is identical either way.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@hudi.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] fix(spark): make slash-separated date partitioning work on the row writer path [hudi]
Posted by "voonhous (via GitHub)" <gi...@apache.org>.
voonhous merged PR #19648:
URL: https://github.com/apache/hudi/pull/19648
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@hudi.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] fix(spark): make slash-separated date partitioning work on the row writer path [hudi]
Posted by "SEPURI-SAI-KRISHNA (via GitHub)" <gi...@apache.org>.
SEPURI-SAI-KRISHNA commented on code in PR #19648:
URL: https://github.com/apache/hudi/pull/19648#discussion_r3820488582
##########
hudi-spark-datasource/hudi-spark/src/test/scala/org/apache/spark/sql/hudi/common/TestSlashSeparatedPartitionValue.scala:
##########
@@ -90,6 +90,113 @@ class TestSlashSeparatedPartitionValue extends HoodieSparkSqlTestBase {
}
}
+ test("Test slash separated date partitions written through the row writer") {
+ withSQLConf("hoodie.spark.sql.insert.into.operation" -> "bulk_insert") {
+ withTempDir { tmp =>
+ val targetTable = generateTableName
+ val tablePath = s"${tmp.getCanonicalPath}/$targetTable"
+
+ spark.sql(
+ s"""
+ |create table $targetTable (
+ | `id` string,
+ | `name` string,
+ | `ts` bigint,
+ | `datestr` STRING
+ |) using hudi
+ | tblproperties (
+ | 'primaryKey' = 'id',
+ | 'type' = 'COW',
+ | 'preCombineField'='ts',
+ | 'hoodie.datasource.write.slash.separated.date.partitioning'='true'
+ | )
+ | partitioned by (`datestr`)
+ | location '$tablePath'
+ """.stripMargin)
+
+ // NOTE: The row writer derives the partition path off of an [[InternalRow]], which used to
+ // blow up with a [[ClassCastException]]; a null partition value used to NPE
+ spark.sql(
+ s"""
+ | insert into $targetTable values
+ | (1, 'a1', 1000, "2026-01-05"),
+ | (2, 'a2', 2000, "2026-01-06"),
+ | (3, 'a3', 3000, null)
+ """.stripMargin)
+
+ checkAnswer(s"select id, name, ts, _hoodie_partition_path, datestr from $targetTable order by id")(
Review Comment:
Noted, thanks. `PartitionPathParser#getPartitionValues` taking `parts[0]` for anything that isn't time-typed does mean a STRING partition column reads back as `2026` — pre-existing and untouched here, and the Spark-side `doParsePartitionColumnValues` is what covers the read path this test exercises.
Leaving it as recorded context, same as above. Worth noting the bootstrap-merge read is a narrow enough consumer today that it may deserve its own issue if the engine-agnostic reader is going to take over more of the read path.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@hudi.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] fix(spark): make slash-separated date partitioning work on the row writer path [hudi]
Posted by "SEPURI-SAI-KRISHNA (via GitHub)" <gi...@apache.org>.
SEPURI-SAI-KRISHNA commented on PR #19648:
URL: https://github.com/apache/hudi/pull/19648#issuecomment-5316088005
CI: the only failure is `TestValidateHoodieSyncProcedure > "sync_validate record-count modes fail fast on an unreachable HiveServer2"`,
which fails identically on #19646 (a completely unrelated change) in the same phase, alongside `Free memory is lower than 5%` warnings. Looks pre-existing/flaky on master rather
than related to this PR. The tests added here all pass: `TestSlashSeparatedPartitionValue` ran 3/3 green in build 16339, including the new row-writer case.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@hudi.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] fix(spark): make slash-separated date partitioning work on the row writer path [hudi]
Posted by "voonhous (via GitHub)" <gi...@apache.org>.
voonhous commented on code in PR #19648:
URL: https://github.com/apache/hudi/pull/19648#discussion_r3813353926
##########
hudi-client/hudi-spark-client/src/main/java/org/apache/hudi/keygen/PartitionPathFormatterBase.java:
##########
@@ -75,15 +75,11 @@ public final S combine(List<String> partitionPathFields, Object... partitionPath
if (useHiveStylePartitioning) {
sb.appendJava(partitionPathFields.get(i))
- .appendJava("=")
- .append(partitionPathPartStr);
- } else if (slashSeparatedDatePartitioning) {
- String res = ((String) partitionPathPartStr).replace('-', '/');
- sb.append(((S) res));
- } else {
- sb.append(partitionPathPartStr);
+ .appendJava("=");
}
+ sb.append(partitionPathPartStr);
Review Comment:
The multi-field branch this rewrites is not reached by any write path: `getPartitionPath(Row)` has no production caller whose output lands on disk, and the `InternalRow` side threw on master. Its one production consumer is query-side pruning: `SparkHoodieTableFileIndex.composeRelativePartitionPath` (`:471-489`) builds a `StringPartitionPathFormatter` from table config and `combine`s only the bound *prefix* of partition columns (`:404`).
For a `(datestr, city)` slash table written by the Avro path (`2026-01-05/san-francisco`), `where datestr = '2026-01-05'` alone composes the single-part `2026/01/05`, `exists()` fails at `:444`, and the query silently returns zero rows. Same on master; this PR only fixes the all-columns-bound case (master composed `2026/01/05/san/francisco`). `ShowHoodieTablePartitionsCommand.scala:60-61` already `checkState`s "Only one partition field is allowed for SlashEncodedPartitioning".
Ask: (1) reject `slash.separated.date.partitioning=true` with more than one partition field at table creation and in writer config validation, next to the existing hive-style check (or file a follow-up issue and link it here); (2) reword the PR "Behavior change" section -- the multi-field change lands in file-index prefix pruning, not in any write path, and no existing table layout changes.
##########
hudi-client/hudi-spark-client/src/main/java/org/apache/hudi/keygen/PartitionPathFormatterBase.java:
##########
@@ -62,11 +62,11 @@ public final S combine(List<String> partitionPathFields, Object... partitionPath
// Avoid creating [[StringBuilder]] in case there's just one partition-path part,
// and Hive-style of partitioning is not required
if (!useHiveStylePartitioning && partitionPathParts.length == 1) {
- if (slashSeparatedDatePartitioning) {
- return ((S) ((String) toString(partitionPathParts[0])).replace('-', '/'));
- } else {
- return tryEncode(handleEmpty(toString(partitionPathParts[0])));
- }
+ S partitionPathPart = tryEncode(handleEmpty(toString(partitionPathParts[0])));
+ // NOTE: Slash-separated date partitioning only kicks in for a table partitioned by a single
Review Comment:
This NOTE is wrong for `CustomKeyGenerator`: it builds one single-field sub-keygen per partition field (`CustomKeyGenerator.java:82-101`), so each field takes this fast path and `date:simple,city:simple` yields `2026/01/05/san/francisco` on Avro, Row and InternalRow alike (Avro does the same via `KeyGenUtils#getPartitionPath`, which slashes unconditionally). This PR is also what un-breaks that InternalRow path (same CCE), and nothing tests it.
Ask: scope the NOTE to `SimpleKeyGenerator`/`ComplexKeyGenerator` and cite `KeyGenUtils#getPartitionPath` (the method governing the single-field case) alongside `getRecordPartitionPath`; add Row + InternalRow asserts to the existing `TestCustomKeyGenerator.testSlashSeparatedDatePartitioning`, which already builds the record.
##########
hudi-spark-datasource/hudi-spark/src/test/scala/org/apache/spark/sql/hudi/common/TestSlashSeparatedPartitionValue.scala:
##########
@@ -90,6 +90,61 @@ class TestSlashSeparatedPartitionValue extends HoodieSparkSqlTestBase {
}
}
+ test("Test slash separated date partitions written through the row writer") {
+ withSQLConf("hoodie.sql.bulk.insert.enable" -> "true", "hoodie.sql.insert.mode" -> "non-strict",
+ "hoodie.datasource.write.row.writer.enable" -> "true") {
+ withTempDir { tmp =>
+ val targetTable = generateTableName
+ val tablePath = s"${tmp.getCanonicalPath}/$targetTable"
+
+ spark.sql(
+ s"""
+ |create table $targetTable (
+ | `id` string,
+ | `name` string,
+ | `ts` bigint,
+ | `datestr` STRING
Review Comment:
Every slash test in the repo partitions on a STRING column pre-formatted `yyyy-MM-dd`; none uses the DATE/TIMESTAMP type the feature is documented for. DATE agrees on all three paths (`LocalDate.toString` via `BuiltinKeyGenerator.convertToLogicalDataType` and `HoodieAvroUtils.convertValueForAvroLogicalTypes`) but is unpinned. TIMESTAMP diverges: the slash arm at `SqlKeyGenerator.scala:164-166` (from #17787) sits ahead of the `TimestampType` normalization (cf. #12621) and shadows it, so the Avro path (default `consistent.logical.timestamp=false`) writes raw micros `1767607200000000` while the row writer now writes `2026/01/05 18:00:00.0` (it threw before this PR).
Ask: add a DATE column case to this suite (insert + bulk_insert, same directory, `datestr` reads back as `date'2026-01-05'`). For TIMESTAMP either move the slash arm inside `case _ =>` of the dataType match or reject TimestampType partition columns under slash -- a linked follow-up issue is fine.
##########
hudi-client/hudi-spark-client/src/test/java/org/apache/hudi/keygen/TestSimpleKeyGenerator.java:
##########
@@ -213,4 +213,34 @@ void testSlashSeparatedDatePartitioningWithAlreadyFormattedInput() {
Assertions.assertEquals("key1", key.getRecordKey());
Assertions.assertEquals("2026/01/01", key.getPartitionPath());
}
+
+ @Test
+ void testSlashSeparatedDatePartitioningOnRowWritingPaths() {
+ TypedProperties properties = getPropsWithSlashSeparatedDatePartitioning();
+ // NOTE: "ts_ms" is the string-typed field of the example schema, "timestamp" is a long
+ properties.put(KeyGeneratorOptions.PARTITIONPATH_FIELD_NAME.key(), "ts_ms");
+ SimpleKeyGenerator keyGenerator = new SimpleKeyGenerator(properties);
+
+ GenericRecord avroRecord = getRecord();
+ Assertions.assertEquals("2020/03/21", keyGenerator.getPartitionPath(avroRecord));
+
+ Row row = KeyGeneratorTestUtilities.getRow(avroRecord);
+ Assertions.assertEquals("2020/03/21", keyGenerator.getPartitionPath(row));
+
+ InternalRow internalRow = KeyGeneratorTestUtilities.getInternalRow(row);
+ Assertions.assertEquals(UTF8String.fromString("2020/03/21"),
+ keyGenerator.getPartitionPath(internalRow, row.schema()));
+ }
+
+ @Test
+ void testSlashSeparatedDatePartitioningWithNullValue() {
+ TypedProperties properties = getPropsWithSlashSeparatedDatePartitioning();
+ properties.put(KeyGeneratorOptions.PARTITIONPATH_FIELD_NAME.key(), "nested_col.prop1");
+ SimpleKeyGenerator keyGenerator = new SimpleKeyGenerator(properties);
+
+ GenericRecord avroRecord = getRecord(getNestedColRecord(null, 10L));
+
+ Row row = KeyGeneratorTestUtilities.getRow(avroRecord);
+ Assertions.assertEquals(HUDI_DEFAULT_PARTITION_PATH, keyGenerator.getPartitionPath(row));
Review Comment:
This only asserts the Row path; the InternalRow + null case (the row-writer NPE the PR describes) is asserted at no keygen level. The two extra lines below go red on master with the same NPE.
```suggestion
Assertions.assertEquals(HUDI_DEFAULT_PARTITION_PATH, keyGenerator.getPartitionPath(row));
InternalRow internalRow = KeyGeneratorTestUtilities.getInternalRow(row);
Assertions.assertEquals(UTF8String.fromString(HUDI_DEFAULT_PARTITION_PATH),
keyGenerator.getPartitionPath(internalRow, row.schema()));
```
##########
hudi-spark-datasource/hudi-spark/src/test/scala/org/apache/spark/sql/hudi/common/TestSlashSeparatedPartitionValue.scala:
##########
@@ -90,6 +90,61 @@ class TestSlashSeparatedPartitionValue extends HoodieSparkSqlTestBase {
}
}
+ test("Test slash separated date partitions written through the row writer") {
+ withSQLConf("hoodie.sql.bulk.insert.enable" -> "true", "hoodie.sql.insert.mode" -> "non-strict",
+ "hoodie.datasource.write.row.writer.enable" -> "true") {
+ withTempDir { tmp =>
+ val targetTable = generateTableName
+ val tablePath = s"${tmp.getCanonicalPath}/$targetTable"
+
+ spark.sql(
+ s"""
+ |create table $targetTable (
+ | `id` string,
+ | `name` string,
+ | `ts` bigint,
+ | `datestr` STRING
+ |) using hudi
+ | tblproperties (
+ | 'primaryKey' = 'id',
+ | 'type' = 'COW',
+ | 'preCombineField'='ts',
+ | 'hoodie.datasource.write.slash.separated.date.partitioning'='true'
+ | )
+ | partitioned by (`datestr`)
+ | location '$tablePath'
+ """.stripMargin)
+
+ // NOTE: The row writer derives the partition path off of an [[InternalRow]], which used to
+ // blow up with a [[ClassCastException]]; a null partition value used to NPE
+ spark.sql(
+ s"""
+ | insert into $targetTable values
+ | (1, 'a1', 1000, "2026-01-05"),
+ | (2, 'a2', 2000, "2026-01-06"),
+ | (3, 'a3', 3000, null)
+ """.stripMargin)
+
+ checkAnswer(s"select id, name, ts, _hoodie_partition_path from $targetTable order by id")(
+ Seq("1", "a1", 1000, "2026/01/05"),
+ Seq("2", "a2", 2000, "2026/01/06"),
+ Seq("3", "a3", 3000, "__HIVE_DEFAULT_PARTITION__")
Review Comment:
Siblings at `:62` and `:185` project `datestr`; this one does not, so the read-back through `HoodieSparkUtils.doParsePartitionColumnValues` for row-writer data and the null row is unasserted.
```suggestion
checkAnswer(s"select id, name, ts, _hoodie_partition_path, datestr from $targetTable order by id")(
Seq("1", "a1", 1000, "2026/01/05", "2026-01-05"),
Seq("2", "a2", 2000, "2026/01/06", "2026-01-06"),
Seq("3", "a3", 3000, "__HIVE_DEFAULT_PARTITION__", null)
```
##########
hudi-client/hudi-spark-client/src/test/java/org/apache/hudi/keygen/TestPartitionPathFormatter.java:
##########
@@ -0,0 +1,115 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.hudi.keygen;
+
+import org.apache.spark.unsafe.types.UTF8String;
+import org.junit.jupiter.params.ParameterizedTest;
+import org.junit.jupiter.params.provider.ValueSource;
+
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.List;
+
+import static org.apache.hudi.common.util.PartitionPathEncodeUtils.DEFAULT_PARTITION_PATH;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+
+/**
+ * Tests the partition-path formatters backing the key generators, making sure that both the
+ * {@link String} (Avro/{@link org.apache.spark.sql.Row} write path) and the {@link UTF8String}
+ * (row-writer/{@link org.apache.spark.sql.catalyst.InternalRow} write path) flavors produce
+ * identical partition paths.
+ */
+class TestPartitionPathFormatter {
+
+ private static final List<String> SINGLE_FIELD = Collections.singletonList("date_col");
+ private static final List<String> TWO_FIELDS = Arrays.asList("date_col", "city");
+
+ private String combine(boolean useRowWriterPath,
+ boolean hiveStylePartitioning,
+ boolean encode,
+ boolean slashSeparatedDatePartitioning,
+ List<String> fields,
+ Object... parts) {
+ if (useRowWriterPath) {
+ return new UTF8StringPartitionPathFormatter(
+ UTF8StringPartitionPathFormatter.UTF8StringBuilder::new, hiveStylePartitioning, encode,
+ slashSeparatedDatePartitioning).combine(fields, parts).toString();
+ }
+ return new StringPartitionPathFormatter(
+ StringPartitionPathFormatter.JavaStringBuilder::new, hiveStylePartitioning, encode,
+ slashSeparatedDatePartitioning).combine(fields, parts);
+ }
+
+ @ParameterizedTest
+ @ValueSource(booleans = {true, false})
+ void testSlashSeparatedDatePartitioningSingleField(boolean useRowWriterPath) {
Review Comment:
Delete: the only assert that fails on master is the UTF8 run of the first line (CCE), which `...EncodesValues`, `...OnlyAppliesToSingleFieldPartitioning` and `TestSimpleKeyGenerator.testSlashSeparatedDatePartitioningOnRowWritingPaths` already produce; the already-slashed input is a no-op `replace` duplicated by `testSlashSeparatedDatePartitioningWithAlreadyFormattedInput` in `TestSimpleKeyGenerator`, `TestComplexKeyGenerator`, `TestCustomKeyGenerator` and by `TestSlashSeparatedPartitionValue.scala:175`.
##########
hudi-client/hudi-spark-client/src/test/java/org/apache/hudi/keygen/TestPartitionPathFormatter.java:
##########
@@ -0,0 +1,115 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.hudi.keygen;
+
+import org.apache.spark.unsafe.types.UTF8String;
+import org.junit.jupiter.params.ParameterizedTest;
+import org.junit.jupiter.params.provider.ValueSource;
+
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.List;
+
+import static org.apache.hudi.common.util.PartitionPathEncodeUtils.DEFAULT_PARTITION_PATH;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+
+/**
+ * Tests the partition-path formatters backing the key generators, making sure that both the
+ * {@link String} (Avro/{@link org.apache.spark.sql.Row} write path) and the {@link UTF8String}
+ * (row-writer/{@link org.apache.spark.sql.catalyst.InternalRow} write path) flavors produce
+ * identical partition paths.
+ */
+class TestPartitionPathFormatter {
+
+ private static final List<String> SINGLE_FIELD = Collections.singletonList("date_col");
+ private static final List<String> TWO_FIELDS = Arrays.asList("date_col", "city");
+
+ private String combine(boolean useRowWriterPath,
+ boolean hiveStylePartitioning,
+ boolean encode,
+ boolean slashSeparatedDatePartitioning,
+ List<String> fields,
+ Object... parts) {
+ if (useRowWriterPath) {
+ return new UTF8StringPartitionPathFormatter(
+ UTF8StringPartitionPathFormatter.UTF8StringBuilder::new, hiveStylePartitioning, encode,
+ slashSeparatedDatePartitioning).combine(fields, parts).toString();
+ }
+ return new StringPartitionPathFormatter(
+ StringPartitionPathFormatter.JavaStringBuilder::new, hiveStylePartitioning, encode,
+ slashSeparatedDatePartitioning).combine(fields, parts);
+ }
+
+ @ParameterizedTest
+ @ValueSource(booleans = {true, false})
+ void testSlashSeparatedDatePartitioningSingleField(boolean useRowWriterPath) {
+ assertEquals("2026/01/05",
+ combine(useRowWriterPath, false, false, true, SINGLE_FIELD, "2026-01-05"));
+ // Input that is already slash-separated is left untouched
+ assertEquals("2026/01/05",
+ combine(useRowWriterPath, false, false, true, SINGLE_FIELD, "2026/01/05"));
+ }
+
+ @ParameterizedTest
+ @ValueSource(booleans = {true, false})
+ void testSlashSeparatedDatePartitioningOnlyAppliesToSingleFieldPartitioning(boolean useRowWriterPath) {
+ // NOTE: This mirrors [[KeyGenUtils#getRecordPartitionPath]] driving the Avro write-path
+ assertEquals("2026-01-05/san-francisco",
+ combine(useRowWriterPath, false, false, true, TWO_FIELDS, "2026-01-05", "san-francisco"));
+ }
+
+ @ParameterizedTest
+ @ValueSource(booleans = {true, false})
+ void testSlashSeparatedDatePartitioningHandlesNullAndEmptyValues(boolean useRowWriterPath) {
+ assertEquals(DEFAULT_PARTITION_PATH,
+ combine(useRowWriterPath, false, false, true, SINGLE_FIELD, new Object[] {null}));
+ assertEquals(DEFAULT_PARTITION_PATH,
+ combine(useRowWriterPath, false, false, true, SINGLE_FIELD, ""));
+ }
+
+ @ParameterizedTest
+ @ValueSource(booleans = {true, false})
+ void testSlashSeparatedDatePartitioningEncodesValues(boolean useRowWriterPath) {
+ // '?' has to be escaped, while the date separators are turned into directory separators
+ assertEquals("2026/01/05", combine(useRowWriterPath, false, true, true, SINGLE_FIELD, "2026-01-05"));
+ assertEquals("a%3Fb", combine(useRowWriterPath, false, true, true, SINGLE_FIELD, "a?b"));
Review Comment:
Pre-PR the slash branch skipped `tryEncode`, so the one input whose output actually changes under `urlencode=true` is an already slash-separated value (`2026/01/05` -> `2026%2F01%2F05`, matching `KeyGenUtils.getRecordPartitionPath:255-262` and fixing file-index prefix pruning on such tables). Both asserts here are no-ops for that change; pin it:
```suggestion
assertEquals("a%3Fb", combine(useRowWriterPath, false, true, true, SINGLE_FIELD, "a?b"));
// Encoding runs before the substitution (parity with KeyGenUtils), so an already slash-separated
// value is escaped rather than turned into directories
assertEquals("2026%2F01%2F05", combine(useRowWriterPath, false, true, true, SINGLE_FIELD, "2026/01/05"));
```
##########
hudi-client/hudi-spark-client/src/test/java/org/apache/hudi/keygen/TestPartitionPathFormatter.java:
##########
@@ -0,0 +1,115 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.hudi.keygen;
+
+import org.apache.spark.unsafe.types.UTF8String;
+import org.junit.jupiter.params.ParameterizedTest;
+import org.junit.jupiter.params.provider.ValueSource;
+
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.List;
+
+import static org.apache.hudi.common.util.PartitionPathEncodeUtils.DEFAULT_PARTITION_PATH;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+
+/**
+ * Tests the partition-path formatters backing the key generators, making sure that both the
+ * {@link String} (Avro/{@link org.apache.spark.sql.Row} write path) and the {@link UTF8String}
+ * (row-writer/{@link org.apache.spark.sql.catalyst.InternalRow} write path) flavors produce
+ * identical partition paths.
+ */
+class TestPartitionPathFormatter {
+
+ private static final List<String> SINGLE_FIELD = Collections.singletonList("date_col");
+ private static final List<String> TWO_FIELDS = Arrays.asList("date_col", "city");
+
+ private String combine(boolean useRowWriterPath,
+ boolean hiveStylePartitioning,
+ boolean encode,
+ boolean slashSeparatedDatePartitioning,
+ List<String> fields,
+ Object... parts) {
+ if (useRowWriterPath) {
+ return new UTF8StringPartitionPathFormatter(
+ UTF8StringPartitionPathFormatter.UTF8StringBuilder::new, hiveStylePartitioning, encode,
+ slashSeparatedDatePartitioning).combine(fields, parts).toString();
+ }
+ return new StringPartitionPathFormatter(
+ StringPartitionPathFormatter.JavaStringBuilder::new, hiveStylePartitioning, encode,
+ slashSeparatedDatePartitioning).combine(fields, parts);
+ }
+
+ @ParameterizedTest
+ @ValueSource(booleans = {true, false})
+ void testSlashSeparatedDatePartitioningSingleField(boolean useRowWriterPath) {
+ assertEquals("2026/01/05",
+ combine(useRowWriterPath, false, false, true, SINGLE_FIELD, "2026-01-05"));
+ // Input that is already slash-separated is left untouched
+ assertEquals("2026/01/05",
+ combine(useRowWriterPath, false, false, true, SINGLE_FIELD, "2026/01/05"));
+ }
+
+ @ParameterizedTest
+ @ValueSource(booleans = {true, false})
+ void testSlashSeparatedDatePartitioningOnlyAppliesToSingleFieldPartitioning(boolean useRowWriterPath) {
+ // NOTE: This mirrors [[KeyGenUtils#getRecordPartitionPath]] driving the Avro write-path
+ assertEquals("2026-01-05/san-francisco",
+ combine(useRowWriterPath, false, false, true, TWO_FIELDS, "2026-01-05", "san-francisco"));
+ }
+
+ @ParameterizedTest
+ @ValueSource(booleans = {true, false})
+ void testSlashSeparatedDatePartitioningHandlesNullAndEmptyValues(boolean useRowWriterPath) {
+ assertEquals(DEFAULT_PARTITION_PATH,
+ combine(useRowWriterPath, false, false, true, SINGLE_FIELD, new Object[] {null}));
+ assertEquals(DEFAULT_PARTITION_PATH,
+ combine(useRowWriterPath, false, false, true, SINGLE_FIELD, ""));
+ }
+
+ @ParameterizedTest
+ @ValueSource(booleans = {true, false})
+ void testSlashSeparatedDatePartitioningEncodesValues(boolean useRowWriterPath) {
+ // '?' has to be escaped, while the date separators are turned into directory separators
+ assertEquals("2026/01/05", combine(useRowWriterPath, false, true, true, SINGLE_FIELD, "2026-01-05"));
+ assertEquals("a%3Fb", combine(useRowWriterPath, false, true, true, SINGLE_FIELD, "a?b"));
+ }
+
+ @ParameterizedTest
+ @ValueSource(booleans = {true, false})
+ void testHiveStylePartitioningTakesPrecedence(boolean useRowWriterPath) {
+ // NOTE: Hive-style partitioning and slash-separated date partitioning are mutually exclusive --
+ // [[HoodieCatalogTable#extraTableConfig]] rejects a table configuring both -- so this
+ // combination is unreachable and the formatter deliberately leaves the value alone.
+ // This asserts the pre-existing behavior stays put, it is not a statement about what the
+ // combination *should* produce
+ assertEquals("date_col=2026-01-05",
+ combine(useRowWriterPath, true, false, true, SINGLE_FIELD, "2026-01-05"));
+ }
+
+ @ParameterizedTest
+ @ValueSource(booleans = {true, false})
+ void testPlainPartitioningIsUnaffected(boolean useRowWriterPath) {
Review Comment:
Delete: cannot fail on master, and both asserts are already pinned at Row and InternalRow level by `TestComplexKeyGenerator.testSingleValueKeyGenerator` (`:148/:151`) and `testMultipleValueKeyGenerator` (`:183/:187`).
##########
hudi-client/hudi-spark-client/src/test/java/org/apache/hudi/keygen/TestPartitionPathFormatter.java:
##########
@@ -0,0 +1,115 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.hudi.keygen;
+
+import org.apache.spark.unsafe.types.UTF8String;
+import org.junit.jupiter.params.ParameterizedTest;
+import org.junit.jupiter.params.provider.ValueSource;
+
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.List;
+
+import static org.apache.hudi.common.util.PartitionPathEncodeUtils.DEFAULT_PARTITION_PATH;
Review Comment:
nit, feel free to ignore: sibling tests in this package use `KeyGenUtils.HUDI_DEFAULT_PARTITION_PATH` (same constant, `KeyGenUtils.java:55`).
##########
hudi-spark-datasource/hudi-spark/src/test/scala/org/apache/spark/sql/hudi/common/TestSlashSeparatedPartitionValue.scala:
##########
@@ -90,6 +90,61 @@ class TestSlashSeparatedPartitionValue extends HoodieSparkSqlTestBase {
}
}
+ test("Test slash separated date partitions written through the row writer") {
+ withSQLConf("hoodie.sql.bulk.insert.enable" -> "true", "hoodie.sql.insert.mode" -> "non-strict",
+ "hoodie.datasource.write.row.writer.enable" -> "true") {
Review Comment:
`hoodie.sql.bulk.insert.enable` and `hoodie.sql.insert.mode` are `@Deprecated` / `deprecatedAfter("0.14.0")` (`DataSourceOptions.scala:569-584`) and `row.writer.enable=true` is the default; the single modern config below still routes to `bulkInsertAsRow` (verified red on master with the same CCE, green here).
```suggestion
withSQLConf("hoodie.spark.sql.insert.into.operation" -> "bulk_insert") {
```
nit, feel free to ignore: this is also the third copy of the DDL + metaClient block in this file -- folding into `"Test slash separated date partitions"` with `Seq("insert", "bulk_insert").foreach` plus the null row would drop ~40 lines.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@hudi.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] fix(spark): make slash-separated date partitioning work on the row writer path [hudi]
Posted by "SEPURI-SAI-KRISHNA (via GitHub)" <gi...@apache.org>.
SEPURI-SAI-KRISHNA commented on code in PR #19648:
URL: https://github.com/apache/hudi/pull/19648#discussion_r3815167448
##########
hudi-client/hudi-spark-client/src/test/java/org/apache/hudi/keygen/TestPartitionPathFormatter.java:
##########
@@ -0,0 +1,115 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.hudi.keygen;
+
+import org.apache.spark.unsafe.types.UTF8String;
+import org.junit.jupiter.params.ParameterizedTest;
+import org.junit.jupiter.params.provider.ValueSource;
+
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.List;
+
+import static org.apache.hudi.common.util.PartitionPathEncodeUtils.DEFAULT_PARTITION_PATH;
Review Comment:
Applied, switched to KeyGenUtils.HUDI_DEFAULT_PARTITION_PATH.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@hudi.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] fix(spark): make slash-separated date partitioning work on the row writer path [hudi]
Posted by "hudi-bot (via GitHub)" <gi...@apache.org>.
hudi-bot commented on PR #19648:
URL: https://github.com/apache/hudi/pull/19648#issuecomment-5378808123
<!--
Meta data
{
"version" : 1,
"metaDataEntries" : [ {
"hash" : "ce3ab56d080092972df722ab619a3cf71308b6c2",
"status" : "DELETED",
"url" : "https://dev.azure.com/apachehudi/a1a51da7-8592-47d4-88dc-fd67bed336bb/_build/results?buildId=16342",
"triggerID" : "ce3ab56d080092972df722ab619a3cf71308b6c2",
"triggerType" : "PUSH"
}, {
"hash" : "8d523937035c816ddf765ac61acad162e311b738",
"status" : "DELETED",
"url" : "https://dev.azure.com/apachehudi/a1a51da7-8592-47d4-88dc-fd67bed336bb/_build/results?buildId=16390",
"triggerID" : "8d523937035c816ddf765ac61acad162e311b738",
"triggerType" : "PUSH"
}, {
"hash" : "fdd04bfbf709f806768ae4b4b259a679b08e2aa4",
"status" : "DELETED",
"url" : "https://dev.azure.com/apachehudi/a1a51da7-8592-47d4-88dc-fd67bed336bb/_build/results?buildId=16413",
"triggerID" : "fdd04bfbf709f806768ae4b4b259a679b08e2aa4",
"triggerType" : "PUSH"
}, {
"hash" : "8f1cb373283c41cf6513e83b169e692902c91c4e",
"status" : "FAILURE",
"url" : "https://dev.azure.com/apachehudi/a1a51da7-8592-47d4-88dc-fd67bed336bb/_build/results?buildId=16440",
"triggerID" : "8f1cb373283c41cf6513e83b169e692902c91c4e",
"triggerType" : "PUSH"
}, {
"hash" : "8ce9ad0a09e3fc8a889eefab03abc38f6a1e8aa5",
"status" : "PENDING",
"url" : "https://dev.azure.com/apachehudi/a1a51da7-8592-47d4-88dc-fd67bed336bb/_build/results?buildId=16477",
"triggerID" : "8ce9ad0a09e3fc8a889eefab03abc38f6a1e8aa5",
"triggerType" : "PUSH"
} ]
}-->
## CI report:
* 8f1cb373283c41cf6513e83b169e692902c91c4e Azure: [FAILURE](https://dev.azure.com/apachehudi/a1a51da7-8592-47d4-88dc-fd67bed336bb/_build/results?buildId=16440)
* 8ce9ad0a09e3fc8a889eefab03abc38f6a1e8aa5 Azure: [PENDING](https://dev.azure.com/apachehudi/a1a51da7-8592-47d4-88dc-fd67bed336bb/_build/results?buildId=16477)
<details>
<summary>Bot commands</summary>
@hudi-bot supports the following commands:
- `@hudi-bot run azure` re-run the last Azure build
</details>
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@hudi.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] fix(spark): make slash-separated date partitioning work on the row writer path [hudi]
Posted by "hudi-agent (via GitHub)" <gi...@apache.org>.
hudi-agent commented on code in PR #19648:
URL: https://github.com/apache/hudi/pull/19648#discussion_r3831711761
##########
hudi-client/hudi-spark-client/src/main/java/org/apache/hudi/keygen/StringPartitionPathFormatter.java:
##########
@@ -56,6 +56,16 @@ protected String handleEmpty(String partitionPathPart) {
}
}
+ @Override
+ protected String replaceDashesWithSlashes(String partitionPathPart) {
+ return partitionPathPart.replace('-', '/');
+ }
+
+ @Override
+ protected boolean startsWithDash(String partitionPathPart) {
+ return !partitionPathPart.isEmpty() && partitionPathPart.charAt(0) == '-';
Review Comment:
🤖 nit: could you use `partitionPathPart.startsWith("-")` here? It reads more clearly and matches how `KeyGenUtils` does the same leading-dash check.
<sub><i>⚠️ AI-generated; verify before applying. React 👍/👎 to flag quality.</i></sub>
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@hudi.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] fix(spark): make slash-separated date partitioning work on the row writer path [hudi]
Posted by "hudi-bot (via GitHub)" <gi...@apache.org>.
hudi-bot commented on PR #19648:
URL: https://github.com/apache/hudi/pull/19648#issuecomment-5395215942
<!--
Meta data
{
"version" : 1,
"metaDataEntries" : [ {
"hash" : "ce3ab56d080092972df722ab619a3cf71308b6c2",
"status" : "DELETED",
"url" : "https://dev.azure.com/apachehudi/a1a51da7-8592-47d4-88dc-fd67bed336bb/_build/results?buildId=16342",
"triggerID" : "ce3ab56d080092972df722ab619a3cf71308b6c2",
"triggerType" : "PUSH"
}, {
"hash" : "8d523937035c816ddf765ac61acad162e311b738",
"status" : "DELETED",
"url" : "https://dev.azure.com/apachehudi/a1a51da7-8592-47d4-88dc-fd67bed336bb/_build/results?buildId=16390",
"triggerID" : "8d523937035c816ddf765ac61acad162e311b738",
"triggerType" : "PUSH"
}, {
"hash" : "fdd04bfbf709f806768ae4b4b259a679b08e2aa4",
"status" : "DELETED",
"url" : "https://dev.azure.com/apachehudi/a1a51da7-8592-47d4-88dc-fd67bed336bb/_build/results?buildId=16413",
"triggerID" : "fdd04bfbf709f806768ae4b4b259a679b08e2aa4",
"triggerType" : "PUSH"
}, {
"hash" : "8f1cb373283c41cf6513e83b169e692902c91c4e",
"status" : "DELETED",
"url" : "https://dev.azure.com/apachehudi/a1a51da7-8592-47d4-88dc-fd67bed336bb/_build/results?buildId=16440",
"triggerID" : "8f1cb373283c41cf6513e83b169e692902c91c4e",
"triggerType" : "PUSH"
}, {
"hash" : "8ce9ad0a09e3fc8a889eefab03abc38f6a1e8aa5",
"status" : "DELETED",
"url" : "https://dev.azure.com/apachehudi/a1a51da7-8592-47d4-88dc-fd67bed336bb/_build/results?buildId=16477",
"triggerID" : "8ce9ad0a09e3fc8a889eefab03abc38f6a1e8aa5",
"triggerType" : "PUSH"
}, {
"hash" : "2d738376d122aa8b60243bd99f216f5b8b3fa217",
"status" : "SUCCESS",
"url" : "https://dev.azure.com/apachehudi/a1a51da7-8592-47d4-88dc-fd67bed336bb/_build/results?buildId=16484",
"triggerID" : "2d738376d122aa8b60243bd99f216f5b8b3fa217",
"triggerType" : "PUSH"
}, {
"hash" : "493712b3d69c542864eebf43d0c090276c55bfc6",
"status" : "PENDING",
"url" : "https://dev.azure.com/apachehudi/a1a51da7-8592-47d4-88dc-fd67bed336bb/_build/results?buildId=16505",
"triggerID" : "493712b3d69c542864eebf43d0c090276c55bfc6",
"triggerType" : "PUSH"
}, {
"hash" : "073f3ca3e82c84c1be52833f0b7078b8ecec3614",
"status" : "UNKNOWN",
"url" : "TBD",
"triggerID" : "073f3ca3e82c84c1be52833f0b7078b8ecec3614",
"triggerType" : "PUSH"
}, {
"hash" : "8cd021a924d18b1f761beb318d23dca5550d6eb8",
"status" : "UNKNOWN",
"url" : "TBD",
"triggerID" : "8cd021a924d18b1f761beb318d23dca5550d6eb8",
"triggerType" : "PUSH"
} ]
}-->
## CI report:
* 2d738376d122aa8b60243bd99f216f5b8b3fa217 Azure: [SUCCESS](https://dev.azure.com/apachehudi/a1a51da7-8592-47d4-88dc-fd67bed336bb/_build/results?buildId=16484)
* 493712b3d69c542864eebf43d0c090276c55bfc6 Azure: [PENDING](https://dev.azure.com/apachehudi/a1a51da7-8592-47d4-88dc-fd67bed336bb/_build/results?buildId=16505)
* 073f3ca3e82c84c1be52833f0b7078b8ecec3614 UNKNOWN
* 8cd021a924d18b1f761beb318d23dca5550d6eb8 UNKNOWN
<details>
<summary>Bot commands</summary>
@hudi-bot supports the following commands:
- `@hudi-bot run azure` re-run the last Azure build
</details>
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@hudi.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] fix(spark): make slash-separated date partitioning work on the row writer path [hudi]
Posted by "SEPURI-SAI-KRISHNA (via GitHub)" <gi...@apache.org>.
SEPURI-SAI-KRISHNA commented on code in PR #19648:
URL: https://github.com/apache/hudi/pull/19648#discussion_r3827277764
##########
hudi-client/hudi-spark-client/src/main/java/org/apache/hudi/keygen/PartitionPathFormatterBase.java:
##########
@@ -62,11 +62,28 @@ public final S combine(List<String> partitionPathFields, Object... partitionPath
// Avoid creating [[StringBuilder]] in case there's just one partition-path part,
// and Hive-style of partitioning is not required
if (!useHiveStylePartitioning && partitionPathParts.length == 1) {
- if (slashSeparatedDatePartitioning) {
- return ((S) ((String) toString(partitionPathParts[0])).replace('-', '/'));
- } else {
- return tryEncode(handleEmpty(toString(partitionPathParts[0])));
- }
+ S partitionPathPart = tryEncode(handleEmpty(toString(partitionPathParts[0])));
+ // NOTE: For [[SimpleKeyGenerator]]/[[ComplexKeyGenerator]] slash-separated date partitioning
Review Comment:
Fair point, done. `combine()` now carries a two-line pointer instead of the block:
```java
S partitionPathPart = tryEncode(handleEmpty(toString(partitionPathParts[0])));
// NOTE: See [[replaceDashesWithSlashes]] on why the substitution is confined to this
// single-part branch, and [[startsWithDash]] on why a leading dash suppresses it
return slashSeparatedDatePartitioning && !startsWithDash(partitionPathPart)
? replaceDashesWithSlashes(partitionPathPart)
: partitionPathPart;
```
I split the rationale by which method it actually explains rather than moving it wholesale: the single-field/`CustomKeyGenerator` half is about when `combine()` routes a value into the substitution, so it went onto `replaceDashesWithSlashes`; the leading-dash half explains the guard itself, so it went onto `startsWithDash` — whose javadoc previously said "must not be applied to it" without saying why, which was the weaker of the two docs.
No behavior change, comments only.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@hudi.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] fix(spark): make slash-separated date partitioning work on the row writer path [hudi]
Posted by "hudi-bot (via GitHub)" <gi...@apache.org>.
hudi-bot commented on PR #19648:
URL: https://github.com/apache/hudi/pull/19648#issuecomment-5365329567
<!--
Meta data
{
"version" : 1,
"metaDataEntries" : [ {
"hash" : "ce3ab56d080092972df722ab619a3cf71308b6c2",
"status" : "DELETED",
"url" : "https://dev.azure.com/apachehudi/a1a51da7-8592-47d4-88dc-fd67bed336bb/_build/results?buildId=16342",
"triggerID" : "ce3ab56d080092972df722ab619a3cf71308b6c2",
"triggerType" : "PUSH"
}, {
"hash" : "8d523937035c816ddf765ac61acad162e311b738",
"status" : "DELETED",
"url" : "https://dev.azure.com/apachehudi/a1a51da7-8592-47d4-88dc-fd67bed336bb/_build/results?buildId=16390",
"triggerID" : "8d523937035c816ddf765ac61acad162e311b738",
"triggerType" : "PUSH"
}, {
"hash" : "fdd04bfbf709f806768ae4b4b259a679b08e2aa4",
"status" : "FAILURE",
"url" : "https://dev.azure.com/apachehudi/a1a51da7-8592-47d4-88dc-fd67bed336bb/_build/results?buildId=16413",
"triggerID" : "fdd04bfbf709f806768ae4b4b259a679b08e2aa4",
"triggerType" : "PUSH"
}, {
"hash" : "8f1cb373283c41cf6513e83b169e692902c91c4e",
"status" : "UNKNOWN",
"url" : "TBD",
"triggerID" : "8f1cb373283c41cf6513e83b169e692902c91c4e",
"triggerType" : "PUSH"
} ]
}-->
## CI report:
* fdd04bfbf709f806768ae4b4b259a679b08e2aa4 Azure: [FAILURE](https://dev.azure.com/apachehudi/a1a51da7-8592-47d4-88dc-fd67bed336bb/_build/results?buildId=16413)
* 8f1cb373283c41cf6513e83b169e692902c91c4e UNKNOWN
<details>
<summary>Bot commands</summary>
@hudi-bot supports the following commands:
- `@hudi-bot run azure` re-run the last Azure build
</details>
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@hudi.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] fix(spark): make slash-separated date partitioning work on the row writer path [hudi]
Posted by "voonhous (via GitHub)" <gi...@apache.org>.
voonhous commented on code in PR #19648:
URL: https://github.com/apache/hudi/pull/19648#discussion_r3829072959
##########
hudi-client/hudi-spark-client/src/main/java/org/apache/hudi/keygen/PartitionPathFormatterBase.java:
##########
@@ -75,15 +76,11 @@ public final S combine(List<String> partitionPathFields, Object... partitionPath
if (useHiveStylePartitioning) {
sb.appendJava(partitionPathFields.get(i))
- .appendJava("=")
- .append(partitionPathPartStr);
- } else if (slashSeparatedDatePartitioning) {
- String res = ((String) partitionPathPartStr).replace('-', '/');
- sb.append(((S) res));
- } else {
- sb.append(partitionPathPartStr);
+ .appendJava("=");
}
+ sb.append(partitionPathPartStr);
Review Comment:
Right for `ComplexKeyGenerator`, but a regression for `CustomKeyGenerator`: it builds one single-field sub-keygen per field (`CustomKeyGenerator.java:91`), so every field is slashed on disk -- `2026/01/05/NYC`.
`composeRelativePartitionPath` calls `combine` once with all N columns, so it lands here. It used to produce `2026/01/05/NYC` and the all-bound short circuit at `SparkHoodieTableFileIndex.scala:447` returned rows; now it produces `2026-01-05/NYC`, `exists()` fails at `:444`, and `:445` returns `Seq()`. Silent zero rows, not the `HoodieException` of #19666. Untested: `TestCustomKeyGenerator:419` is single-column.
**Ask:** add a two-column `CustomKeyGenerator` slash test with both columns bound, asserting non-zero rows. Then either make `composeRelativePartitionPath` keygen-aware, or fold this into #19666 and link it here.
##########
hudi-client/hudi-client-common/src/main/java/org/apache/hudi/keygen/KeyGenUtils.java:
##########
@@ -291,12 +292,30 @@ public static String getPartitionPath(GenericRecord record, String partitionPath
if (hiveStylePartitioning) {
partitionPath = partitionPathField + "=" + partitionPath;
}
+ // NOTE: See [[slashSeparateDateValue]] on why a leading dash suppresses the substitution
if (slashSeparatedDatePartitioning) {
- partitionPath = partitionPath.replace('-', '/');
+ partitionPath = slashSeparateDateValue(partitionPath);
}
return partitionPath;
}
+ /**
+ * Turns a {@code yyyy-MM-dd} formatted date value into the {@code yyyy/MM/dd} directory structure
+ * requested by {@code hoodie.datasource.write.slash.separated.date.partitioning}.
+ *
+ * <p>A value with a leading dash is returned as-is: substituting would make the partition path
+ * start with {@code "/"}, and an absolute relative-partition-path is resolved inconsistently --
+ * {@link org.apache.hudi.common.fs.FSUtils#constructAbsolutePath(String, String)} chops the
+ * leading {@code "/"} while the {@link org.apache.hudi.storage.StoragePath} overload used by
+ * {@code AbstractTableFileSystemView} lets it URI-resolve away the table base path (a value of
+ * {@code "-5"} lands the writer in {@code "<base>/5"} but the file-system view in {@code "/5"},
+ * and {@code "-"} resolves to the base path itself). Such a value is not a date to begin with,
+ * so nothing is lost by not slashing it.
+ */
+ private static String slashSeparateDateValue(String partitionPath) {
+ return partitionPath.startsWith("-") ? partitionPath : partitionPath.replace('-', '/');
Review Comment:
A trailing dash and a doubled dash break the same round trip. `StoragePath.normalize` (`StoragePath.java:300`) strips trailing slashes, `URI.normalize()` collapses inner `//`:
```
5- -> 5/ writes <base>/5 lists back 5
a--b -> a//b writes <base>/a/b lists back a/b
```
The writer records the raw string (`HoodieRowCreateHandle.java:132,278`) but resolves the directory normalized (`:303`). So `FSUtils.getFileName` slices at `partition.length()+1` (`FSUtils.java:615`) and `FilesIndexer.java:185` stores `xx.parquet` for `5/xxx.parquet` -- a corrupt metadata-table FILES entry.
Your compat argument holds unchanged: these outputs are already unreadable.
**Ask:** widen the predicate here,
```suggestion
return partitionPath.startsWith("-") || partitionPath.endsWith("-") || partitionPath.contains("--")
? partitionPath
: partitionPath.replace('-', '/');
```
and in both formatters -- rename `startsWithDash` and add `endsWith` / `contains`. Both exist on `UTF8String` in spark-unsafe 3.3.4 and up.
##########
hudi-client/hudi-spark-client/src/test/java/org/apache/hudi/keygen/TestPartitionPathFormatter.java:
##########
@@ -0,0 +1,118 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.hudi.keygen;
+
+import org.apache.spark.unsafe.types.UTF8String;
+import org.junit.jupiter.params.ParameterizedTest;
+import org.junit.jupiter.params.provider.ValueSource;
+
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.List;
+
+import static org.apache.hudi.keygen.KeyGenUtils.HUDI_DEFAULT_PARTITION_PATH;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+
+/**
+ * Tests the partition-path formatters backing the key generators, making sure that both the
+ * {@link String} (Avro/{@link org.apache.spark.sql.Row} write path) and the {@link UTF8String}
+ * (row-writer/{@link org.apache.spark.sql.catalyst.InternalRow} write path) flavors produce
+ * identical partition paths.
+ */
+class TestPartitionPathFormatter {
+
+ private static final List<String> SINGLE_FIELD = Collections.singletonList("date_col");
+ private static final List<String> TWO_FIELDS = Arrays.asList("date_col", "city");
+
+ private String combine(boolean useRowWriterPath,
+ boolean hiveStylePartitioning,
+ boolean encode,
+ boolean slashSeparatedDatePartitioning,
+ List<String> fields,
+ Object... parts) {
+ if (useRowWriterPath) {
+ return new UTF8StringPartitionPathFormatter(
+ UTF8StringPartitionPathFormatter.UTF8StringBuilder::new, hiveStylePartitioning, encode,
+ slashSeparatedDatePartitioning).combine(fields, parts).toString();
+ }
+ return new StringPartitionPathFormatter(
+ StringPartitionPathFormatter.JavaStringBuilder::new, hiveStylePartitioning, encode,
+ slashSeparatedDatePartitioning).combine(fields, parts);
+ }
+
+ @ParameterizedTest
+ @ValueSource(booleans = {true, false})
+ void testSlashSeparatedDatePartitioningOnlyAppliesToSingleFieldPartitioning(boolean useRowWriterPath) {
+ // NOTE: This mirrors [[KeyGenUtils#getRecordPartitionPath]] driving the Avro write-path
+ assertEquals("2026-01-05/san-francisco",
+ combine(useRowWriterPath, false, false, true, TWO_FIELDS, "2026-01-05", "san-francisco"));
+ }
+
+ @ParameterizedTest
+ @ValueSource(booleans = {true, false})
+ void testSlashSeparatedDatePartitioningHandlesNullAndEmptyValues(boolean useRowWriterPath) {
+ assertEquals(HUDI_DEFAULT_PARTITION_PATH,
+ combine(useRowWriterPath, false, false, true, SINGLE_FIELD, new Object[] {null}));
+ assertEquals(HUDI_DEFAULT_PARTITION_PATH,
+ combine(useRowWriterPath, false, false, true, SINGLE_FIELD, ""));
+ }
+
+ @ParameterizedTest
+ @ValueSource(booleans = {true, false})
+ void testSlashSeparatedDatePartitioningLeavesLeadingDashesAlone(boolean useRowWriterPath) {
+ // NOTE: Substituting here would yield a partition path starting with "/", which
+ // [[FSUtils#constructAbsolutePath(String, String)]] and the [[StoragePath]] overload used
+ // by [[AbstractTableFileSystemView]] resolve differently -- the former chops the leading
+ // "/", the latter URI-resolves the table base path away -- so the writer and the
+ // file-system view would disagree on where the partition lives
+ assertEquals("-5", combine(useRowWriterPath, false, false, true, SINGLE_FIELD, "-5"));
+ assertEquals("-", combine(useRowWriterPath, false, false, true, SINGLE_FIELD, "-"));
+ assertEquals("--5", combine(useRowWriterPath, false, false, true, SINGLE_FIELD, "--5"));
+ // A dash anywhere else is still a separator: only a leading one produces an absolute path
+ assertEquals("5/", combine(useRowWriterPath, false, false, true, SINGLE_FIELD, "5-"));
Review Comment:
This pins the broken shape, and the comment's invariant is false: `5-` gives `5/` (writes `<base>/5`, records `5/`) and `a--b` gives `a//b`. Both fail the round trip the guard exists to protect -- evidence in my comment on `slashSeparateDateValue`. A green test here means the follow-up has to argue with an assertion instead of a gap.
**Ask:** assert the guarded values. Goes green with the widened guard.
```suggestion
// A dash that would turn into a leading, trailing or doubled "/" is left alone as well
assertEquals("5-", combine(useRowWriterPath, false, false, true, SINGLE_FIELD, "5-"));
assertEquals("a--b", combine(useRowWriterPath, false, false, true, SINGLE_FIELD, "a--b"));
```
##########
hudi-client/hudi-client-common/src/main/java/org/apache/hudi/keygen/KeyGenUtils.java:
##########
@@ -291,12 +292,30 @@ public static String getPartitionPath(GenericRecord record, String partitionPath
if (hiveStylePartitioning) {
partitionPath = partitionPathField + "=" + partitionPath;
}
+ // NOTE: See [[slashSeparateDateValue]] on why a leading dash suppresses the substitution
if (slashSeparatedDatePartitioning) {
- partitionPath = partitionPath.replace('-', '/');
+ partitionPath = slashSeparateDateValue(partitionPath);
Review Comment:
By `:293` the value is already `dt=-5`, so `startsWith("-")` can never fire under hive-style: you get `dt=/5`, and `-` gives `dt=/`, whose directory is `<base>/dt=`. The formatter guards the bare value instead (`PartitionPathFormatterBase.java:68`), so the two write paths guard different strings. `df.write` and HoodieStreamer still reach this -- `HoodieCatalogTable.scala:296-300` only blocks the SQL DDL path (#19669).
**Ask:** move `slashSeparateDateValue(...)` before the `field=` prefix, here and at `:262`. Behaviour-preserving otherwise, since `"dt="` contains no dash.
##########
hudi-client/hudi-client-common/src/main/java/org/apache/hudi/keygen/KeyGenUtils.java:
##########
@@ -257,8 +257,9 @@ public static String getRecordPartitionPath(GenericRecord record,
if (hiveStylePartitioning) {
fieldVal = partitionPathField + "=" + fieldVal;
}
+ // NOTE: See [[slashSeparateDateValue]] on why a leading dash suppresses the substitution
if (partitionPathFields.size() == 1 && slashSeparatedDatePartitioning) {
- fieldVal = fieldVal.replace('-', '/');
+ fieldVal = slashSeparateDateValue(fieldVal);
Review Comment:
Untested. `SimpleAvroKeyGenerator.java:55` calls the other overload, so `TestSimpleKeyGenerator#...LeavesLeadingDashesAlone` covers `:297`, not this line. The only production caller here is `ComplexAvroKeyGenerator.java:53`, and neither slash test that reaches it (`TestComplexKeyGenerator.java:228`, `:248`) uses a leading-dash value.
**Ask:** add `testSlashSeparatedDatePartitioningLeavesLeadingDashesAlone` next to `TestComplexKeyGenerator:228` -- same props, `put("timestamp", "-5")`, assert `-5`. Three lines, and red without this guard.
##########
hudi-spark-datasource/hudi-spark/src/test/scala/org/apache/spark/sql/hudi/common/TestSlashSeparatedPartitionValue.scala:
##########
@@ -90,6 +90,113 @@ class TestSlashSeparatedPartitionValue extends HoodieSparkSqlTestBase {
}
}
+ test("Test slash separated date partitions written through the row writer") {
+ withSQLConf("hoodie.spark.sql.insert.into.operation" -> "bulk_insert") {
+ withTempDir { tmp =>
+ val targetTable = generateTableName
+ val tablePath = s"${tmp.getCanonicalPath}/$targetTable"
+
+ spark.sql(
+ s"""
+ |create table $targetTable (
+ | `id` string,
+ | `name` string,
+ | `ts` bigint,
+ | `datestr` STRING
+ |) using hudi
+ | tblproperties (
+ | 'primaryKey' = 'id',
+ | 'type' = 'COW',
+ | 'preCombineField'='ts',
+ | 'hoodie.datasource.write.slash.separated.date.partitioning'='true'
+ | )
+ | partitioned by (`datestr`)
+ | location '$tablePath'
+ """.stripMargin)
+
+ // NOTE: The row writer derives the partition path off of an [[InternalRow]], which used to
+ // blow up with a [[ClassCastException]]; a null partition value used to NPE
+ spark.sql(
+ s"""
+ | insert into $targetTable values
+ | (1, 'a1', 1000, "2026-01-05"),
+ | (2, 'a2', 2000, "2026-01-06"),
+ | (3, 'a3', 3000, null)
+ """.stripMargin)
+
+ checkAnswer(s"select id, name, ts, _hoodie_partition_path, datestr from $targetTable order by id")(
+ Seq("1", "a1", 1000, "2026/01/05", "2026-01-05"),
+ Seq("2", "a2", 2000, "2026/01/06", "2026-01-06"),
+ Seq("3", "a3", 3000, "__HIVE_DEFAULT_PARTITION__", null)
+ )
+
+ val metaClient = HoodieTableMetaClient.builder()
+ .setConf(HadoopFSUtils.getStorageConfWithCopy(spark.sparkContext.hadoopConfiguration))
+ .setBasePath(tablePath)
+ .build()
+ assertTrue(metaClient.getStorage.exists(new StoragePath(tablePath, "2026/01/05")),
+ s"Partition path 2026/01/05 should exist")
+ assertTrue(metaClient.getStorage.exists(new StoragePath(tablePath, "2026/01/06")),
+ s"Partition path 2026/01/06 should exist")
+ assertTrue(metaClient.getStorage.exists(new StoragePath(tablePath, "__HIVE_DEFAULT_PARTITION__")),
+ s"Partition path __HIVE_DEFAULT_PARTITION__ should exist")
Review Comment:
Both new tests drop the assertion that checks writer-name against metadata-table-name agreement, which is what this PR is about. The two pre-existing tests make it (`:80-88` and `:257-262`: `HoodieBackedTableMetadata.getAllPartitionPaths` contains `2026/01/05`). `_hoodie_partition_path` plus `storage.exists` still pass when the two disagree.
**Ask:** copy the block from `:80-88` into both new tests, asserting `2026/01/05`, `2026/01/06` and `__HIVE_DEFAULT_PARTITION__`.
##########
hudi-spark-datasource/hudi-spark/src/test/scala/org/apache/spark/sql/hudi/common/TestSlashSeparatedPartitionValue.scala:
##########
@@ -90,6 +90,113 @@ class TestSlashSeparatedPartitionValue extends HoodieSparkSqlTestBase {
}
}
+ test("Test slash separated date partitions written through the row writer") {
Review Comment:
Nothing in the repo upserts into a slash-partitioned table -- all four tests here are COW insert-only, and no slash test uses MOR (`git grep -n "slash.separated.date.partitioning" -- '*/test/*'`). That leaves index and file-system-view agreement on a slash partition path unexercised, which is where a mismatched partition string surfaces as duplicate records rather than an exception.
**Ask:** add one upsert case -- insert into `2026/01/05`, upsert the same key and partition value, assert the partition still holds one row and no second directory appeared.
##########
hudi-spark-datasource/hudi-spark/src/test/scala/org/apache/spark/sql/hudi/common/TestSlashSeparatedPartitionValue.scala:
##########
@@ -90,6 +90,113 @@ class TestSlashSeparatedPartitionValue extends HoodieSparkSqlTestBase {
}
}
+ test("Test slash separated date partitions written through the row writer") {
+ withSQLConf("hoodie.spark.sql.insert.into.operation" -> "bulk_insert") {
+ withTempDir { tmp =>
+ val targetTable = generateTableName
+ val tablePath = s"${tmp.getCanonicalPath}/$targetTable"
+
+ spark.sql(
+ s"""
+ |create table $targetTable (
+ | `id` string,
+ | `name` string,
+ | `ts` bigint,
+ | `datestr` STRING
+ |) using hudi
+ | tblproperties (
+ | 'primaryKey' = 'id',
+ | 'type' = 'COW',
+ | 'preCombineField'='ts',
+ | 'hoodie.datasource.write.slash.separated.date.partitioning'='true'
+ | )
+ | partitioned by (`datestr`)
+ | location '$tablePath'
+ """.stripMargin)
+
+ // NOTE: The row writer derives the partition path off of an [[InternalRow]], which used to
+ // blow up with a [[ClassCastException]]; a null partition value used to NPE
+ spark.sql(
+ s"""
+ | insert into $targetTable values
+ | (1, 'a1', 1000, "2026-01-05"),
+ | (2, 'a2', 2000, "2026-01-06"),
+ | (3, 'a3', 3000, null)
+ """.stripMargin)
+
+ checkAnswer(s"select id, name, ts, _hoodie_partition_path, datestr from $targetTable order by id")(
+ Seq("1", "a1", 1000, "2026/01/05", "2026-01-05"),
+ Seq("2", "a2", 2000, "2026/01/06", "2026-01-06"),
+ Seq("3", "a3", 3000, "__HIVE_DEFAULT_PARTITION__", null)
+ )
+
+ val metaClient = HoodieTableMetaClient.builder()
+ .setConf(HadoopFSUtils.getStorageConfWithCopy(spark.sparkContext.hadoopConfiguration))
+ .setBasePath(tablePath)
+ .build()
+ assertTrue(metaClient.getStorage.exists(new StoragePath(tablePath, "2026/01/05")),
+ s"Partition path 2026/01/05 should exist")
+ assertTrue(metaClient.getStorage.exists(new StoragePath(tablePath, "2026/01/06")),
+ s"Partition path 2026/01/06 should exist")
+ assertTrue(metaClient.getStorage.exists(new StoragePath(tablePath, "__HIVE_DEFAULT_PARTITION__")),
+ s"Partition path __HIVE_DEFAULT_PARTITION__ should exist")
+ }
+ }
+ }
+
+ test("Test slash separated date partitions on a DATE typed partition column") {
+ Seq("insert", "bulk_insert").foreach { operation =>
Review Comment:
The `insert` leg passes on master unchanged: `TestTypedPartitionValues.scala:28` (from #19652, an ancestor of this branch) already covers DATE plus slash on the default `insert` operation, asserts the same things, and adds partition pruning. Only `bulk_insert` discriminates the row-writer rendering this PR fixes.
**Ask:** keep only the leg that can fail.
```suggestion
Seq("bulk_insert").foreach { operation =>
```
Better still, drop the loop and pull in the pruning assertions from `TestTypedPartitionValues.scala:63-68`.
##########
hudi-spark-datasource/hudi-spark/src/test/scala/org/apache/spark/sql/hudi/common/TestSlashSeparatedPartitionValue.scala:
##########
@@ -90,6 +90,113 @@ class TestSlashSeparatedPartitionValue extends HoodieSparkSqlTestBase {
}
}
+ test("Test slash separated date partitions written through the row writer") {
+ withSQLConf("hoodie.spark.sql.insert.into.operation" -> "bulk_insert") {
+ withTempDir { tmp =>
+ val targetTable = generateTableName
+ val tablePath = s"${tmp.getCanonicalPath}/$targetTable"
+
+ spark.sql(
+ s"""
+ |create table $targetTable (
+ | `id` string,
+ | `name` string,
+ | `ts` bigint,
+ | `datestr` STRING
+ |) using hudi
+ | tblproperties (
+ | 'primaryKey' = 'id',
+ | 'type' = 'COW',
+ | 'preCombineField'='ts',
+ | 'hoodie.datasource.write.slash.separated.date.partitioning'='true'
+ | )
+ | partitioned by (`datestr`)
+ | location '$tablePath'
+ """.stripMargin)
+
+ // NOTE: The row writer derives the partition path off of an [[InternalRow]], which used to
+ // blow up with a [[ClassCastException]]; a null partition value used to NPE
+ spark.sql(
+ s"""
+ | insert into $targetTable values
+ | (1, 'a1', 1000, "2026-01-05"),
+ | (2, 'a2', 2000, "2026-01-06"),
+ | (3, 'a3', 3000, null)
+ """.stripMargin)
+
+ checkAnswer(s"select id, name, ts, _hoodie_partition_path, datestr from $targetTable order by id")(
+ Seq("1", "a1", 1000, "2026/01/05", "2026-01-05"),
+ Seq("2", "a2", 2000, "2026/01/06", "2026-01-06"),
+ Seq("3", "a3", 3000, "__HIVE_DEFAULT_PARTITION__", null)
+ )
+
+ val metaClient = HoodieTableMetaClient.builder()
+ .setConf(HadoopFSUtils.getStorageConfWithCopy(spark.sparkContext.hadoopConfiguration))
+ .setBasePath(tablePath)
+ .build()
+ assertTrue(metaClient.getStorage.exists(new StoragePath(tablePath, "2026/01/05")),
+ s"Partition path 2026/01/05 should exist")
+ assertTrue(metaClient.getStorage.exists(new StoragePath(tablePath, "2026/01/06")),
+ s"Partition path 2026/01/06 should exist")
+ assertTrue(metaClient.getStorage.exists(new StoragePath(tablePath, "__HIVE_DEFAULT_PARTITION__")),
+ s"Partition path __HIVE_DEFAULT_PARTITION__ should exist")
+ }
+ }
+ }
+
+ test("Test slash separated date partitions on a DATE typed partition column") {
+ Seq("insert", "bulk_insert").foreach { operation =>
+ withSQLConf("hoodie.spark.sql.insert.into.operation" -> operation) {
+ withTempDir { tmp =>
+ val targetTable = generateTableName
+ val tablePath = s"${tmp.getCanonicalPath}/$targetTable"
+
+ spark.sql(
Review Comment:
nit, feel free to ignore: fourth copy of this DDL block in the file, two of them added here. Post-PR there are 4 x 17 lines of `create table` (`:36`, `:99`, `:154`, `:206`), 4 x 4 lines of `metaClient.builder()`, and 9 `exists` asserts -- 102 lines that vary only by partition column type and property value.
**Ask:** extract `createSlashPartitionedTable`, `buildMetaClient` and `assertPartitionDirsExist`. About 31 lines of helper for 102 of copy-paste, and the next slash test costs three lines instead of forty.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@hudi.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] fix(spark): make slash-separated date partitioning work on the row writer path [hudi]
Posted by "SEPURI-SAI-KRISHNA (via GitHub)" <gi...@apache.org>.
SEPURI-SAI-KRISHNA commented on code in PR #19648:
URL: https://github.com/apache/hudi/pull/19648#discussion_r3836313076
##########
hudi-client/hudi-client-common/src/main/java/org/apache/hudi/keygen/KeyGenUtils.java:
##########
@@ -291,12 +292,30 @@ public static String getPartitionPath(GenericRecord record, String partitionPath
if (hiveStylePartitioning) {
partitionPath = partitionPathField + "=" + partitionPath;
}
+ // NOTE: See [[slashSeparateDateValue]] on why a leading dash suppresses the substitution
if (slashSeparatedDatePartitioning) {
- partitionPath = partitionPath.replace('-', '/');
+ partitionPath = slashSeparateDateValue(partitionPath);
}
return partitionPath;
}
+ /**
+ * Turns a {@code yyyy-MM-dd} formatted date value into the {@code yyyy/MM/dd} directory structure
+ * requested by {@code hoodie.datasource.write.slash.separated.date.partitioning}.
+ *
+ * <p>A value with a leading dash is returned as-is: substituting would make the partition path
+ * start with {@code "/"}, and an absolute relative-partition-path is resolved inconsistently --
+ * {@link org.apache.hudi.common.fs.FSUtils#constructAbsolutePath(String, String)} chops the
+ * leading {@code "/"} while the {@link org.apache.hudi.storage.StoragePath} overload used by
+ * {@code AbstractTableFileSystemView} lets it URI-resolve away the table base path (a value of
+ * {@code "-5"} lands the writer in {@code "<base>/5"} but the file-system view in {@code "/5"},
+ * and {@code "-"} resolves to the base path itself). Such a value is not a date to begin with,
+ * so nothing is lost by not slashing it.
+ */
+ private static String slashSeparateDateValue(String partitionPath) {
+ return partitionPath.startsWith("-") ? partitionPath : partitionPath.replace('-', '/');
Review Comment:
Applied, both cases confirmed. The predicate is widened and now lives in one place, `KeyGenUtils#hasPathBreakingDash`:
```java
public static boolean hasPathBreakingDash(String partitionPath) {
return partitionPath.startsWith("-") || partitionPath.endsWith("-") || partitionPath.contains("--");
}
```
`StringPartitionPathFormatter` delegates to it (which also answers the bot's `startsWith("-")` nit on the same file) and `UTF8StringPartitionPathFormatter` mirrors it with a `DOUBLE_DASH_UTF8` constant, since `startsWith`/`endsWith`/`contains` all exist on `UTF8String`. `startsWithDash` is gone from the base class and both subclasses.
The javadoc now records all three shapes and why each one breaks: the leading case as before, the trailing and doubled cases because the recorded partition string ends up longer than the directory it normalizes to, so `FSUtils#getFileName` slices at the wrong offset.
##########
hudi-client/hudi-spark-client/src/test/java/org/apache/hudi/keygen/TestPartitionPathFormatter.java:
##########
@@ -0,0 +1,118 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.hudi.keygen;
+
+import org.apache.spark.unsafe.types.UTF8String;
+import org.junit.jupiter.params.ParameterizedTest;
+import org.junit.jupiter.params.provider.ValueSource;
+
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.List;
+
+import static org.apache.hudi.keygen.KeyGenUtils.HUDI_DEFAULT_PARTITION_PATH;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+
+/**
+ * Tests the partition-path formatters backing the key generators, making sure that both the
+ * {@link String} (Avro/{@link org.apache.spark.sql.Row} write path) and the {@link UTF8String}
+ * (row-writer/{@link org.apache.spark.sql.catalyst.InternalRow} write path) flavors produce
+ * identical partition paths.
+ */
+class TestPartitionPathFormatter {
+
+ private static final List<String> SINGLE_FIELD = Collections.singletonList("date_col");
+ private static final List<String> TWO_FIELDS = Arrays.asList("date_col", "city");
+
+ private String combine(boolean useRowWriterPath,
+ boolean hiveStylePartitioning,
+ boolean encode,
+ boolean slashSeparatedDatePartitioning,
+ List<String> fields,
+ Object... parts) {
+ if (useRowWriterPath) {
+ return new UTF8StringPartitionPathFormatter(
+ UTF8StringPartitionPathFormatter.UTF8StringBuilder::new, hiveStylePartitioning, encode,
+ slashSeparatedDatePartitioning).combine(fields, parts).toString();
+ }
+ return new StringPartitionPathFormatter(
+ StringPartitionPathFormatter.JavaStringBuilder::new, hiveStylePartitioning, encode,
+ slashSeparatedDatePartitioning).combine(fields, parts);
+ }
+
+ @ParameterizedTest
+ @ValueSource(booleans = {true, false})
+ void testSlashSeparatedDatePartitioningOnlyAppliesToSingleFieldPartitioning(boolean useRowWriterPath) {
+ // NOTE: This mirrors [[KeyGenUtils#getRecordPartitionPath]] driving the Avro write-path
+ assertEquals("2026-01-05/san-francisco",
+ combine(useRowWriterPath, false, false, true, TWO_FIELDS, "2026-01-05", "san-francisco"));
+ }
+
+ @ParameterizedTest
+ @ValueSource(booleans = {true, false})
+ void testSlashSeparatedDatePartitioningHandlesNullAndEmptyValues(boolean useRowWriterPath) {
+ assertEquals(HUDI_DEFAULT_PARTITION_PATH,
+ combine(useRowWriterPath, false, false, true, SINGLE_FIELD, new Object[] {null}));
+ assertEquals(HUDI_DEFAULT_PARTITION_PATH,
+ combine(useRowWriterPath, false, false, true, SINGLE_FIELD, ""));
+ }
+
+ @ParameterizedTest
+ @ValueSource(booleans = {true, false})
+ void testSlashSeparatedDatePartitioningLeavesLeadingDashesAlone(boolean useRowWriterPath) {
+ // NOTE: Substituting here would yield a partition path starting with "/", which
+ // [[FSUtils#constructAbsolutePath(String, String)]] and the [[StoragePath]] overload used
+ // by [[AbstractTableFileSystemView]] resolve differently -- the former chops the leading
+ // "/", the latter URI-resolves the table base path away -- so the writer and the
+ // file-system view would disagree on where the partition lives
+ assertEquals("-5", combine(useRowWriterPath, false, false, true, SINGLE_FIELD, "-5"));
+ assertEquals("-", combine(useRowWriterPath, false, false, true, SINGLE_FIELD, "-"));
+ assertEquals("--5", combine(useRowWriterPath, false, false, true, SINGLE_FIELD, "--5"));
+ // A dash anywhere else is still a separator: only a leading one produces an absolute path
+ assertEquals("5/", combine(useRowWriterPath, false, false, true, SINGLE_FIELD, "5-"));
Review Comment:
Applied. `5-` and `a--b` are asserted as returned unchanged, replacing the `5/` line that pinned the broken shape, and the comment now states the real invariant -- leading, trailing and doubled all fail the round trip, for the two different reasons.
The single interior dash case stays as the positive control.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@hudi.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] fix(spark): make slash-separated date partitioning work on the row writer path [hudi]
Posted by "SEPURI-SAI-KRISHNA (via GitHub)" <gi...@apache.org>.
SEPURI-SAI-KRISHNA commented on code in PR #19648:
URL: https://github.com/apache/hudi/pull/19648#discussion_r3836377809
##########
hudi-spark-datasource/hudi-spark/src/test/scala/org/apache/spark/sql/hudi/common/TestSlashSeparatedPartitionValue.scala:
##########
@@ -90,6 +90,113 @@ class TestSlashSeparatedPartitionValue extends HoodieSparkSqlTestBase {
}
}
+ test("Test slash separated date partitions written through the row writer") {
Review Comment:
Applied -- `Test upsert into a slash separated date partition`, parameterized over COW and MOR since neither had any slash coverage.
It inserts one record into `2026/01/05`, then `merge into` on the same key and partition value, and asserts a single row survives, that the metadata table still lists the partition, and that no second `2026-01-05` directory appeared beside `2026/01/05` -- the shape a mismatched partition string would take.
Passes on both table types with the fix in place.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@hudi.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] fix(spark): make slash-separated date partitioning work on the row writer path [hudi]
Posted by "hudi-bot (via GitHub)" <gi...@apache.org>.
hudi-bot commented on PR #19648:
URL: https://github.com/apache/hudi/pull/19648#issuecomment-5381447827
<!--
Meta data
{
"version" : 1,
"metaDataEntries" : [ {
"hash" : "ce3ab56d080092972df722ab619a3cf71308b6c2",
"status" : "DELETED",
"url" : "https://dev.azure.com/apachehudi/a1a51da7-8592-47d4-88dc-fd67bed336bb/_build/results?buildId=16342",
"triggerID" : "ce3ab56d080092972df722ab619a3cf71308b6c2",
"triggerType" : "PUSH"
}, {
"hash" : "8d523937035c816ddf765ac61acad162e311b738",
"status" : "DELETED",
"url" : "https://dev.azure.com/apachehudi/a1a51da7-8592-47d4-88dc-fd67bed336bb/_build/results?buildId=16390",
"triggerID" : "8d523937035c816ddf765ac61acad162e311b738",
"triggerType" : "PUSH"
}, {
"hash" : "fdd04bfbf709f806768ae4b4b259a679b08e2aa4",
"status" : "DELETED",
"url" : "https://dev.azure.com/apachehudi/a1a51da7-8592-47d4-88dc-fd67bed336bb/_build/results?buildId=16413",
"triggerID" : "fdd04bfbf709f806768ae4b4b259a679b08e2aa4",
"triggerType" : "PUSH"
}, {
"hash" : "8f1cb373283c41cf6513e83b169e692902c91c4e",
"status" : "DELETED",
"url" : "https://dev.azure.com/apachehudi/a1a51da7-8592-47d4-88dc-fd67bed336bb/_build/results?buildId=16440",
"triggerID" : "8f1cb373283c41cf6513e83b169e692902c91c4e",
"triggerType" : "PUSH"
}, {
"hash" : "8ce9ad0a09e3fc8a889eefab03abc38f6a1e8aa5",
"status" : "DELETED",
"url" : "https://dev.azure.com/apachehudi/a1a51da7-8592-47d4-88dc-fd67bed336bb/_build/results?buildId=16477",
"triggerID" : "8ce9ad0a09e3fc8a889eefab03abc38f6a1e8aa5",
"triggerType" : "PUSH"
}, {
"hash" : "2d738376d122aa8b60243bd99f216f5b8b3fa217",
"status" : "SUCCESS",
"url" : "https://dev.azure.com/apachehudi/a1a51da7-8592-47d4-88dc-fd67bed336bb/_build/results?buildId=16484",
"triggerID" : "2d738376d122aa8b60243bd99f216f5b8b3fa217",
"triggerType" : "PUSH"
} ]
}-->
## CI report:
* 2d738376d122aa8b60243bd99f216f5b8b3fa217 Azure: [SUCCESS](https://dev.azure.com/apachehudi/a1a51da7-8592-47d4-88dc-fd67bed336bb/_build/results?buildId=16484)
<details>
<summary>Bot commands</summary>
@hudi-bot supports the following commands:
- `@hudi-bot run azure` re-run the last Azure build
</details>
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@hudi.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] fix(spark): make slash-separated date partitioning work on the row writer path [hudi]
Posted by "voonhous (via GitHub)" <gi...@apache.org>.
voonhous commented on code in PR #19648:
URL: https://github.com/apache/hudi/pull/19648#discussion_r3819041736
##########
hudi-spark-datasource/hudi-spark/src/test/scala/org/apache/spark/sql/hudi/common/TestSlashSeparatedPartitionValue.scala:
##########
@@ -90,6 +90,113 @@ class TestSlashSeparatedPartitionValue extends HoodieSparkSqlTestBase {
}
}
+ test("Test slash separated date partitions written through the row writer") {
+ withSQLConf("hoodie.spark.sql.insert.into.operation" -> "bulk_insert") {
+ withTempDir { tmp =>
+ val targetTable = generateTableName
+ val tablePath = s"${tmp.getCanonicalPath}/$targetTable"
+
+ spark.sql(
+ s"""
+ |create table $targetTable (
+ | `id` string,
+ | `name` string,
+ | `ts` bigint,
+ | `datestr` STRING
+ |) using hudi
+ | tblproperties (
+ | 'primaryKey' = 'id',
+ | 'type' = 'COW',
+ | 'preCombineField'='ts',
+ | 'hoodie.datasource.write.slash.separated.date.partitioning'='true'
+ | )
+ | partitioned by (`datestr`)
+ | location '$tablePath'
+ """.stripMargin)
+
+ // NOTE: The row writer derives the partition path off of an [[InternalRow]], which used to
+ // blow up with a [[ClassCastException]]; a null partition value used to NPE
+ spark.sql(
+ s"""
+ | insert into $targetTable values
+ | (1, 'a1', 1000, "2026-01-05"),
+ | (2, 'a2', 2000, "2026-01-06"),
+ | (3, 'a3', 3000, null)
+ """.stripMargin)
+
+ checkAnswer(s"select id, name, ts, _hoodie_partition_path, datestr from $targetTable order by id")(
Review Comment:
Read-back passes here because the Spark-side `doParsePartitionColumnValues` handles the slash layout, but the engine-agnostic `PartitionPathParser#getPartitionValues` does not for a STRING partition column: `2026/01/05` parses to `2026`, since only time-typed fields go through `inferDateValue` and everything else takes `parts[0]`. Its lone consumer today is the bootstrap-merge read (`HoodieFileGroupReader.java:284`).
Optional, nothing to change in this PR: pre-existing and untouched by this change. Recorded here for context.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@hudi.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] fix(spark): make slash-separated date partitioning work on the row writer path [hudi]
Posted by "SEPURI-SAI-KRISHNA (via GitHub)" <gi...@apache.org>.
SEPURI-SAI-KRISHNA commented on code in PR #19648:
URL: https://github.com/apache/hudi/pull/19648#discussion_r3820484825
##########
hudi-spark-datasource/hudi-spark/src/test/scala/org/apache/spark/sql/hudi/common/TestSlashSeparatedPartitionValue.scala:
##########
@@ -90,6 +90,113 @@ class TestSlashSeparatedPartitionValue extends HoodieSparkSqlTestBase {
}
}
+ test("Test slash separated date partitions written through the row writer") {
+ withSQLConf("hoodie.spark.sql.insert.into.operation" -> "bulk_insert") {
+ withTempDir { tmp =>
+ val targetTable = generateTableName
+ val tablePath = s"${tmp.getCanonicalPath}/$targetTable"
+
+ spark.sql(
+ s"""
+ |create table $targetTable (
+ | `id` string,
+ | `name` string,
+ | `ts` bigint,
+ | `datestr` STRING
+ |) using hudi
+ | tblproperties (
+ | 'primaryKey' = 'id',
+ | 'type' = 'COW',
+ | 'preCombineField'='ts',
+ | 'hoodie.datasource.write.slash.separated.date.partitioning'='true'
+ | )
+ | partitioned by (`datestr`)
+ | location '$tablePath'
+ """.stripMargin)
+
+ // NOTE: The row writer derives the partition path off of an [[InternalRow]], which used to
+ // blow up with a [[ClassCastException]]; a null partition value used to NPE
+ spark.sql(
+ s"""
+ | insert into $targetTable values
+ | (1, 'a1', 1000, "2026-01-05"),
+ | (2, 'a2', 2000, "2026-01-06"),
+ | (3, 'a3', 3000, null)
+ """.stripMargin)
+
+ checkAnswer(s"select id, name, ts, _hoodie_partition_path, datestr from $targetTable order by id")(
+ Seq("1", "a1", 1000, "2026/01/05", "2026-01-05"),
+ Seq("2", "a2", 2000, "2026/01/06", "2026-01-06"),
+ Seq("3", "a3", 3000, "__HIVE_DEFAULT_PARTITION__", null)
+ )
+
+ val metaClient = HoodieTableMetaClient.builder()
+ .setConf(HadoopFSUtils.getStorageConfWithCopy(spark.sparkContext.hadoopConfiguration))
+ .setBasePath(tablePath)
+ .build()
+ assertTrue(metaClient.getStorage.exists(new StoragePath(tablePath, "2026/01/05")),
Review Comment:
Thanks for digging that up — confirmed `HoodieSqlCommonUtils#makePartitionPath` reads hive-style and urlencode from table config but never `getSlashSeparatedDatePartitioning`, so the DDL commands compose a dashed path against slash-separated directories.
Agreed it's out of scope here, and I'd rather not widen this PR further. Leaving it as you suggested, on record next to the tests that create such tables. Happy to file it separately if you'd like it tracked alongside #19666/#19668/#19669 rather than living in this thread.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@hudi.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] fix(spark): make slash-separated date partitioning work on the row writer path [hudi]
Posted by "hudi-bot (via GitHub)" <gi...@apache.org>.
hudi-bot commented on PR #19648:
URL: https://github.com/apache/hudi/pull/19648#issuecomment-5394587178
<!--
Meta data
{
"version" : 1,
"metaDataEntries" : [ {
"hash" : "ce3ab56d080092972df722ab619a3cf71308b6c2",
"status" : "DELETED",
"url" : "https://dev.azure.com/apachehudi/a1a51da7-8592-47d4-88dc-fd67bed336bb/_build/results?buildId=16342",
"triggerID" : "ce3ab56d080092972df722ab619a3cf71308b6c2",
"triggerType" : "PUSH"
}, {
"hash" : "8d523937035c816ddf765ac61acad162e311b738",
"status" : "DELETED",
"url" : "https://dev.azure.com/apachehudi/a1a51da7-8592-47d4-88dc-fd67bed336bb/_build/results?buildId=16390",
"triggerID" : "8d523937035c816ddf765ac61acad162e311b738",
"triggerType" : "PUSH"
}, {
"hash" : "fdd04bfbf709f806768ae4b4b259a679b08e2aa4",
"status" : "DELETED",
"url" : "https://dev.azure.com/apachehudi/a1a51da7-8592-47d4-88dc-fd67bed336bb/_build/results?buildId=16413",
"triggerID" : "fdd04bfbf709f806768ae4b4b259a679b08e2aa4",
"triggerType" : "PUSH"
}, {
"hash" : "8f1cb373283c41cf6513e83b169e692902c91c4e",
"status" : "DELETED",
"url" : "https://dev.azure.com/apachehudi/a1a51da7-8592-47d4-88dc-fd67bed336bb/_build/results?buildId=16440",
"triggerID" : "8f1cb373283c41cf6513e83b169e692902c91c4e",
"triggerType" : "PUSH"
}, {
"hash" : "8ce9ad0a09e3fc8a889eefab03abc38f6a1e8aa5",
"status" : "DELETED",
"url" : "https://dev.azure.com/apachehudi/a1a51da7-8592-47d4-88dc-fd67bed336bb/_build/results?buildId=16477",
"triggerID" : "8ce9ad0a09e3fc8a889eefab03abc38f6a1e8aa5",
"triggerType" : "PUSH"
}, {
"hash" : "2d738376d122aa8b60243bd99f216f5b8b3fa217",
"status" : "SUCCESS",
"url" : "https://dev.azure.com/apachehudi/a1a51da7-8592-47d4-88dc-fd67bed336bb/_build/results?buildId=16484",
"triggerID" : "2d738376d122aa8b60243bd99f216f5b8b3fa217",
"triggerType" : "PUSH"
}, {
"hash" : "493712b3d69c542864eebf43d0c090276c55bfc6",
"status" : "PENDING",
"url" : "https://dev.azure.com/apachehudi/a1a51da7-8592-47d4-88dc-fd67bed336bb/_build/results?buildId=16505",
"triggerID" : "493712b3d69c542864eebf43d0c090276c55bfc6",
"triggerType" : "PUSH"
} ]
}-->
## CI report:
* 2d738376d122aa8b60243bd99f216f5b8b3fa217 Azure: [SUCCESS](https://dev.azure.com/apachehudi/a1a51da7-8592-47d4-88dc-fd67bed336bb/_build/results?buildId=16484)
* 493712b3d69c542864eebf43d0c090276c55bfc6 Azure: [PENDING](https://dev.azure.com/apachehudi/a1a51da7-8592-47d4-88dc-fd67bed336bb/_build/results?buildId=16505)
<details>
<summary>Bot commands</summary>
@hudi-bot supports the following commands:
- `@hudi-bot run azure` re-run the last Azure build
</details>
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@hudi.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] fix(spark): make slash-separated date partitioning work on the row writer path [hudi]
Posted by "hudi-bot (via GitHub)" <gi...@apache.org>.
hudi-bot commented on PR #19648:
URL: https://github.com/apache/hudi/pull/19648#issuecomment-5315901573
<!--
Meta data
{
"version" : 1,
"metaDataEntries" : [ {
"hash" : "bca4b97c14ab1bda65aeb7f3b8466a4fe60b6684",
"status" : "FAILURE",
"url" : "https://dev.azure.com/apachehudi/a1a51da7-8592-47d4-88dc-fd67bed336bb/_build/results?buildId=16339",
"triggerID" : "bca4b97c14ab1bda65aeb7f3b8466a4fe60b6684",
"triggerType" : "PUSH"
} ]
}-->
## CI report:
* bca4b97c14ab1bda65aeb7f3b8466a4fe60b6684 Azure: [FAILURE](https://dev.azure.com/apachehudi/a1a51da7-8592-47d4-88dc-fd67bed336bb/_build/results?buildId=16339)
<details>
<summary>Bot commands</summary>
@hudi-bot supports the following commands:
- `@hudi-bot run azure` re-run the last Azure build
</details>
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@hudi.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] fix(spark): make slash-separated date partitioning work on the row writer path [hudi]
Posted by "hudi-bot (via GitHub)" <gi...@apache.org>.
hudi-bot commented on PR #19648:
URL: https://github.com/apache/hudi/pull/19648#issuecomment-5317139143
<!--
Meta data
{
"version" : 1,
"metaDataEntries" : [ {
"hash" : "ce3ab56d080092972df722ab619a3cf71308b6c2",
"status" : "FAILURE",
"url" : "https://dev.azure.com/apachehudi/a1a51da7-8592-47d4-88dc-fd67bed336bb/_build/results?buildId=16342",
"triggerID" : "ce3ab56d080092972df722ab619a3cf71308b6c2",
"triggerType" : "PUSH"
} ]
}-->
## CI report:
* ce3ab56d080092972df722ab619a3cf71308b6c2 Azure: [FAILURE](https://dev.azure.com/apachehudi/a1a51da7-8592-47d4-88dc-fd67bed336bb/_build/results?buildId=16342)
<details>
<summary>Bot commands</summary>
@hudi-bot supports the following commands:
- `@hudi-bot run azure` re-run the last Azure build
</details>
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@hudi.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] fix(spark): make slash-separated date partitioning work on the row writer path [hudi]
Posted by "hudi-bot (via GitHub)" <gi...@apache.org>.
hudi-bot commented on PR #19648:
URL: https://github.com/apache/hudi/pull/19648#issuecomment-5394524326
<!--
Meta data
{
"version" : 1,
"metaDataEntries" : [ {
"hash" : "ce3ab56d080092972df722ab619a3cf71308b6c2",
"status" : "DELETED",
"url" : "https://dev.azure.com/apachehudi/a1a51da7-8592-47d4-88dc-fd67bed336bb/_build/results?buildId=16342",
"triggerID" : "ce3ab56d080092972df722ab619a3cf71308b6c2",
"triggerType" : "PUSH"
}, {
"hash" : "8d523937035c816ddf765ac61acad162e311b738",
"status" : "DELETED",
"url" : "https://dev.azure.com/apachehudi/a1a51da7-8592-47d4-88dc-fd67bed336bb/_build/results?buildId=16390",
"triggerID" : "8d523937035c816ddf765ac61acad162e311b738",
"triggerType" : "PUSH"
}, {
"hash" : "fdd04bfbf709f806768ae4b4b259a679b08e2aa4",
"status" : "DELETED",
"url" : "https://dev.azure.com/apachehudi/a1a51da7-8592-47d4-88dc-fd67bed336bb/_build/results?buildId=16413",
"triggerID" : "fdd04bfbf709f806768ae4b4b259a679b08e2aa4",
"triggerType" : "PUSH"
}, {
"hash" : "8f1cb373283c41cf6513e83b169e692902c91c4e",
"status" : "DELETED",
"url" : "https://dev.azure.com/apachehudi/a1a51da7-8592-47d4-88dc-fd67bed336bb/_build/results?buildId=16440",
"triggerID" : "8f1cb373283c41cf6513e83b169e692902c91c4e",
"triggerType" : "PUSH"
}, {
"hash" : "8ce9ad0a09e3fc8a889eefab03abc38f6a1e8aa5",
"status" : "DELETED",
"url" : "https://dev.azure.com/apachehudi/a1a51da7-8592-47d4-88dc-fd67bed336bb/_build/results?buildId=16477",
"triggerID" : "8ce9ad0a09e3fc8a889eefab03abc38f6a1e8aa5",
"triggerType" : "PUSH"
}, {
"hash" : "2d738376d122aa8b60243bd99f216f5b8b3fa217",
"status" : "SUCCESS",
"url" : "https://dev.azure.com/apachehudi/a1a51da7-8592-47d4-88dc-fd67bed336bb/_build/results?buildId=16484",
"triggerID" : "2d738376d122aa8b60243bd99f216f5b8b3fa217",
"triggerType" : "PUSH"
}, {
"hash" : "493712b3d69c542864eebf43d0c090276c55bfc6",
"status" : "UNKNOWN",
"url" : "TBD",
"triggerID" : "493712b3d69c542864eebf43d0c090276c55bfc6",
"triggerType" : "PUSH"
} ]
}-->
## CI report:
* 2d738376d122aa8b60243bd99f216f5b8b3fa217 Azure: [SUCCESS](https://dev.azure.com/apachehudi/a1a51da7-8592-47d4-88dc-fd67bed336bb/_build/results?buildId=16484)
* 493712b3d69c542864eebf43d0c090276c55bfc6 UNKNOWN
<details>
<summary>Bot commands</summary>
@hudi-bot supports the following commands:
- `@hudi-bot run azure` re-run the last Azure build
</details>
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@hudi.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] fix(spark): make slash-separated date partitioning work on the row writer path [hudi]
Posted by "hudi-bot (via GitHub)" <gi...@apache.org>.
hudi-bot commented on PR #19648:
URL: https://github.com/apache/hudi/pull/19648#issuecomment-5395145991
<!--
Meta data
{
"version" : 1,
"metaDataEntries" : [ {
"hash" : "ce3ab56d080092972df722ab619a3cf71308b6c2",
"status" : "DELETED",
"url" : "https://dev.azure.com/apachehudi/a1a51da7-8592-47d4-88dc-fd67bed336bb/_build/results?buildId=16342",
"triggerID" : "ce3ab56d080092972df722ab619a3cf71308b6c2",
"triggerType" : "PUSH"
}, {
"hash" : "8d523937035c816ddf765ac61acad162e311b738",
"status" : "DELETED",
"url" : "https://dev.azure.com/apachehudi/a1a51da7-8592-47d4-88dc-fd67bed336bb/_build/results?buildId=16390",
"triggerID" : "8d523937035c816ddf765ac61acad162e311b738",
"triggerType" : "PUSH"
}, {
"hash" : "fdd04bfbf709f806768ae4b4b259a679b08e2aa4",
"status" : "DELETED",
"url" : "https://dev.azure.com/apachehudi/a1a51da7-8592-47d4-88dc-fd67bed336bb/_build/results?buildId=16413",
"triggerID" : "fdd04bfbf709f806768ae4b4b259a679b08e2aa4",
"triggerType" : "PUSH"
}, {
"hash" : "8f1cb373283c41cf6513e83b169e692902c91c4e",
"status" : "DELETED",
"url" : "https://dev.azure.com/apachehudi/a1a51da7-8592-47d4-88dc-fd67bed336bb/_build/results?buildId=16440",
"triggerID" : "8f1cb373283c41cf6513e83b169e692902c91c4e",
"triggerType" : "PUSH"
}, {
"hash" : "8ce9ad0a09e3fc8a889eefab03abc38f6a1e8aa5",
"status" : "DELETED",
"url" : "https://dev.azure.com/apachehudi/a1a51da7-8592-47d4-88dc-fd67bed336bb/_build/results?buildId=16477",
"triggerID" : "8ce9ad0a09e3fc8a889eefab03abc38f6a1e8aa5",
"triggerType" : "PUSH"
}, {
"hash" : "2d738376d122aa8b60243bd99f216f5b8b3fa217",
"status" : "SUCCESS",
"url" : "https://dev.azure.com/apachehudi/a1a51da7-8592-47d4-88dc-fd67bed336bb/_build/results?buildId=16484",
"triggerID" : "2d738376d122aa8b60243bd99f216f5b8b3fa217",
"triggerType" : "PUSH"
}, {
"hash" : "493712b3d69c542864eebf43d0c090276c55bfc6",
"status" : "PENDING",
"url" : "https://dev.azure.com/apachehudi/a1a51da7-8592-47d4-88dc-fd67bed336bb/_build/results?buildId=16505",
"triggerID" : "493712b3d69c542864eebf43d0c090276c55bfc6",
"triggerType" : "PUSH"
}, {
"hash" : "073f3ca3e82c84c1be52833f0b7078b8ecec3614",
"status" : "UNKNOWN",
"url" : "TBD",
"triggerID" : "073f3ca3e82c84c1be52833f0b7078b8ecec3614",
"triggerType" : "PUSH"
} ]
}-->
## CI report:
* 2d738376d122aa8b60243bd99f216f5b8b3fa217 Azure: [SUCCESS](https://dev.azure.com/apachehudi/a1a51da7-8592-47d4-88dc-fd67bed336bb/_build/results?buildId=16484)
* 493712b3d69c542864eebf43d0c090276c55bfc6 Azure: [PENDING](https://dev.azure.com/apachehudi/a1a51da7-8592-47d4-88dc-fd67bed336bb/_build/results?buildId=16505)
* 073f3ca3e82c84c1be52833f0b7078b8ecec3614 UNKNOWN
<details>
<summary>Bot commands</summary>
@hudi-bot supports the following commands:
- `@hudi-bot run azure` re-run the last Azure build
</details>
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@hudi.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] fix(spark): make slash-separated date partitioning work on the row writer path [hudi]
Posted by "codecov-commenter (via GitHub)" <gi...@apache.org>.
codecov-commenter commented on PR #19648:
URL: https://github.com/apache/hudi/pull/19648#issuecomment-5346556196
## [Codecov](https://app.codecov.io/gh/apache/hudi/pull/19648?dropdown=coverage&src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) Report
:white_check_mark: All modified and coverable lines are covered by tests.
:white_check_mark: Project coverage is 77.83%. Comparing base ([`5a11a4f`](https://app.codecov.io/gh/apache/hudi/commit/5a11a4fce20620afac143358bc771dfe2d14d3c8?dropdown=coverage&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)) to head ([`8d52393`](https://app.codecov.io/gh/apache/hudi/commit/8d523937035c816ddf765ac61acad162e311b738?dropdown=coverage&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)).
<details><summary>Additional details and impacted files</summary>
```diff
@@ Coverage Diff @@
## master #19648 +/- ##
=========================================
Coverage 77.83% 77.83%
Complexity 33140 33140
=========================================
Files 2527 2527
Lines 139942 139932 -10
Branches 16849 16847 -2
=========================================
- Hits 108926 108920 -6
+ Misses 23396 23393 -3
+ Partials 7620 7619 -1
```
| [Components](https://app.codecov.io/gh/apache/hudi/pull/19648/components?src=pr&el=components&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | Coverage Δ | |
|---|---|---|
| [hudi-common](https://app.codecov.io/gh/apache/hudi/pull/19648/components?src=pr&el=component&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `83.35% <ø> (+<0.01%)` | :arrow_up: |
| [hudi-client](https://app.codecov.io/gh/apache/hudi/pull/19648/components?src=pr&el=component&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `82.83% <ø> (+<0.01%)` | :arrow_up: |
| [hudi-flink](https://app.codecov.io/gh/apache/hudi/pull/19648/components?src=pr&el=component&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `85.75% <ø> (ø)` | |
| [hudi-spark-datasource](https://app.codecov.io/gh/apache/hudi/pull/19648/components?src=pr&el=component&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `72.27% <ø> (ø)` | |
| [hudi-utilities](https://app.codecov.io/gh/apache/hudi/pull/19648/components?src=pr&el=component&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `74.04% <ø> (ø)` | |
| [hudi-cli](https://app.codecov.io/gh/apache/hudi/pull/19648/components?src=pr&el=component&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `15.06% <ø> (ø)` | |
| [hudi-hadoop](https://app.codecov.io/gh/apache/hudi/pull/19648/components?src=pr&el=component&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `69.09% <ø> (ø)` | |
| [hudi-sync](https://app.codecov.io/gh/apache/hudi/pull/19648/components?src=pr&el=component&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `75.58% <ø> (ø)` | |
| [hudi-io](https://app.codecov.io/gh/apache/hudi/pull/19648/components?src=pr&el=component&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `79.85% <ø> (ø)` | |
| [hudi-timeline-service](https://app.codecov.io/gh/apache/hudi/pull/19648/components?src=pr&el=component&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `83.44% <ø> (ø)` | |
| [hudi-cloud](https://app.codecov.io/gh/apache/hudi/pull/19648/components?src=pr&el=component&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `64.33% <ø> (ø)` | |
| [hudi-kafka-connect](https://app.codecov.io/gh/apache/hudi/pull/19648/components?src=pr&el=component&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `53.20% <ø> (ø)` | |
| [Flag](https://app.codecov.io/gh/apache/hudi/pull/19648/flags?src=pr&el=flags&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | Coverage Δ | |
|---|---|---|
| [hadoop-mr-java-client](https://app.codecov.io/gh/apache/hudi/pull/19648/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `43.91% <ø> (-0.01%)` | :arrow_down: |
Flags with carried forward coverage won't be shown. [Click here](https://docs.codecov.io/docs/carryforward-flags?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#carryforward-flags-in-the-pull-request-comment) to find out more.
| [Files with missing lines](https://app.codecov.io/gh/apache/hudi/pull/19648?dropdown=coverage&src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | Coverage Δ | |
|---|---|---|
| [...apache/hudi/keygen/PartitionPathFormatterBase.java](https://app.codecov.io/gh/apache/hudi/pull/19648?src=pr&el=tree&filepath=hudi-client%2Fhudi-spark-client%2Fsrc%2Fmain%2Fjava%2Forg%2Fapache%2Fhudi%2Fkeygen%2FPartitionPathFormatterBase.java&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#diff-aHVkaS1jbGllbnQvaHVkaS1zcGFyay1jbGllbnQvc3JjL21haW4vamF2YS9vcmcvYXBhY2hlL2h1ZGkva2V5Z2VuL1BhcnRpdGlvblBhdGhGb3JtYXR0ZXJCYXNlLmphdmE=) | `94.44% <ø> (+19.44%)` | :arrow_up: |
| [...ache/hudi/keygen/StringPartitionPathFormatter.java](https://app.codecov.io/gh/apache/hudi/pull/19648?src=pr&el=tree&filepath=hudi-client%2Fhudi-spark-client%2Fsrc%2Fmain%2Fjava%2Forg%2Fapache%2Fhudi%2Fkeygen%2FStringPartitionPathFormatter.java&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#diff-aHVkaS1jbGllbnQvaHVkaS1zcGFyay1jbGllbnQvc3JjL21haW4vamF2YS9vcmcvYXBhY2hlL2h1ZGkva2V5Z2VuL1N0cmluZ1BhcnRpdGlvblBhdGhGb3JtYXR0ZXIuamF2YQ==) | `100.00% <ø> (ø)` | |
| [.../hudi/keygen/UTF8StringPartitionPathFormatter.java](https://app.codecov.io/gh/apache/hudi/pull/19648?src=pr&el=tree&filepath=hudi-client%2Fhudi-spark-client%2Fsrc%2Fmain%2Fjava%2Forg%2Fapache%2Fhudi%2Fkeygen%2FUTF8StringPartitionPathFormatter.java&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#diff-aHVkaS1jbGllbnQvaHVkaS1zcGFyay1jbGllbnQvc3JjL21haW4vamF2YS9vcmcvYXBhY2hlL2h1ZGkva2V5Z2VuL1VURjhTdHJpbmdQYXJ0aXRpb25QYXRoRm9ybWF0dGVyLmphdmE=) | `100.00% <ø> (ø)` | |
... and [3 files with indirect coverage changes](https://app.codecov.io/gh/apache/hudi/pull/19648/indirect-changes?src=pr&el=tree-more&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)
</details>
<details><summary> :rocket: New features to boost your workflow: </summary>
- :snowflake: [Test Analytics](https://docs.codecov.com/docs/test-analytics): Detect flaky tests, report on failures, and find test suite problems.
- :package: [JS Bundle Analysis](https://docs.codecov.com/docs/javascript-bundle-analysis): Save yourself from yourself by tracking and limiting bundle sizes in JS merges.
</details>
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@hudi.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] fix(spark): make slash-separated date partitioning work on the row writer path [hudi]
Posted by "SEPURI-SAI-KRISHNA (via GitHub)" <gi...@apache.org>.
SEPURI-SAI-KRISHNA commented on code in PR #19648:
URL: https://github.com/apache/hudi/pull/19648#discussion_r3836264173
##########
hudi-client/hudi-spark-client/src/main/java/org/apache/hudi/keygen/PartitionPathFormatterBase.java:
##########
@@ -75,15 +76,11 @@ public final S combine(List<String> partitionPathFields, Object... partitionPath
if (useHiveStylePartitioning) {
sb.appendJava(partitionPathFields.get(i))
- .appendJava("=")
- .append(partitionPathPartStr);
- } else if (slashSeparatedDatePartitioning) {
- String res = ((String) partitionPathPartStr).replace('-', '/');
- sb.append(((S) res));
- } else {
- sb.append(partitionPathPartStr);
+ .appendJava("=");
}
+ sb.append(partitionPathPartStr);
Review Comment:
Confirmed, and fixed by restoring the old behaviour rather than by teaching the file index about key generators.
I traced both sides. `CustomKeyGenerator#getPartitionKeyGenerators` builds one single-field sub-keygen per field and `getPartitionPath` appends each result joined by `/`, so every field takes the single-part branch and the writer lands in `2026/01/05/NYC`. `composeRelativePartitionPath` builds a `StringPartitionPathFormatter` and calls `combine` once over all N columns, so it lands in the multi-part branch. Before this PR that branch substituted every part too -- via the `(String)` cast that is the `ClassCastException` -- so the two agreed. Dropping the substitution there is what makes the prefix miss.
So the multi-part branch now substitutes every part again, but through `replaceDashesWithSlashes` and the guard instead of the cast:
```java
} else if (slashSeparatedDatePartitioning && !hasPathBreakingDash(partitionPathPartStr)) {
sb.append(replaceDashesWithSlashes(partitionPathPartStr));
}
```
That keeps this PR to the `ClassCastException`/NPE fix it is named for, with no behaviour change on the multi-field path, and leaves whether such a layout should exist at all to #19666.
Test added as asked -- `Test slash separated date partitions with a multi-field CustomKeyGenerator`: two columns, both bound in the predicate so the read takes the all-bound short circuit at `:446-448`, asserting the row comes back. With the substitution neutralized it fails exactly as you described, silently:
```
Expected Array([1,a1]), but got Array()
```
Worth noting the short circuit builds the `PartitionPath` from the bound values without parsing the directory, which is why this is reachable at all on a multi-field slash table -- `doParsePartitionColumnValues` would not survive the extra fragments.
This also corrects something I agreed to too quickly in the last round: I accepted that the multi-part branch was unreachable. That holds for the write paths, but not for the read side.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@hudi.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] fix(spark): make slash-separated date partitioning work on the row writer path [hudi]
Posted by "SEPURI-SAI-KRISHNA (via GitHub)" <gi...@apache.org>.
SEPURI-SAI-KRISHNA commented on code in PR #19648:
URL: https://github.com/apache/hudi/pull/19648#discussion_r3836358993
##########
hudi-client/hudi-client-common/src/main/java/org/apache/hudi/keygen/KeyGenUtils.java:
##########
@@ -257,8 +257,9 @@ public static String getRecordPartitionPath(GenericRecord record,
if (hiveStylePartitioning) {
fieldVal = partitionPathField + "=" + fieldVal;
}
+ // NOTE: See [[slashSeparateDateValue]] on why a leading dash suppresses the substitution
if (partitionPathFields.size() == 1 && slashSeparatedDatePartitioning) {
- fieldVal = fieldVal.replace('-', '/');
+ fieldVal = slashSeparateDateValue(fieldVal);
Review Comment:
Applied -- `testSlashSeparatedDatePartitioningLeavesLeadingDashesAlone` added next to the existing slash tests in `TestComplexKeyGenerator`, with `timestamp` set to `-5` and asserting `-5`.
Confirmed your reading of the call graph: this is the only production caller of that overload, so the guard on that line had no coverage.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@hudi.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] fix(spark): make slash-separated date partitioning work on the row writer path [hudi]
Posted by "voonhous (via GitHub)" <gi...@apache.org>.
voonhous commented on code in PR #19648:
URL: https://github.com/apache/hudi/pull/19648#discussion_r3829072959
##########
hudi-client/hudi-spark-client/src/main/java/org/apache/hudi/keygen/PartitionPathFormatterBase.java:
##########
@@ -75,15 +76,11 @@ public final S combine(List<String> partitionPathFields, Object... partitionPath
if (useHiveStylePartitioning) {
sb.appendJava(partitionPathFields.get(i))
- .appendJava("=")
- .append(partitionPathPartStr);
- } else if (slashSeparatedDatePartitioning) {
- String res = ((String) partitionPathPartStr).replace('-', '/');
- sb.append(((S) res));
- } else {
- sb.append(partitionPathPartStr);
+ .appendJava("=");
}
+ sb.append(partitionPathPartStr);
Review Comment:
Dropping the substitution from this branch is right for `ComplexKeyGenerator`, but for `CustomKeyGenerator` it is a regression that turns a working query into a silent empty result.
`CustomKeyGenerator` builds one single-field `SimpleKeyGenerator` per partition field (`CustomKeyGenerator.java:91`, assembled at `:130-149`; Avro mirror at `CustomAvroKeyGenerator.java:156-164`), so every field takes the single-field fast path above and *is* slash-separated on disk. A `dt:simple,city:simple` table lands in `2026/01/05/NYC` on the Avro, Row and InternalRow paths alike -- your own javadoc on `replaceDashesWithSlashes` says exactly this.
The query side does not decompose that way. `SparkHoodieTableFileIndex.composeRelativePartitionPath` (`:471-489`) calls `combine` once with all N partition columns, so it lands here in the multi-field branch:
* before this PR it produced `2026/01/05/NYC`, `exists()` at `SparkHoodieTableFileIndex.scala:444` passed, and the all-columns-bound short circuit at `:447-448` returned the partition directly, without ever parsing the path;
* after this PR it produces `2026-01-05/NYC`, `exists()` is false, and `:445` returns `Seq()`.
So `select ... where dt = '2026-01-05' and city = 'NYC'` on a `CustomKeyGenerator` slash table goes from returning rows to returning nothing, with no error. This is distinct from #19666: that one is about the listing path, whereas this short circuit never parses the partition path and therefore worked end to end before this change. Nothing covers it -- `TestCustomKeyGenerator:419-448` is single-column, and every table in `TestSlashSeparatedPartitionValue.scala` is `partitioned by (datestr)`.
One `combine` call cannot serve both generators: `KeyGenUtils.java:261` guards the Avro multi-field path on `size() == 1`, while `CustomKeyGenerator` decomposes into single-field sub-generators that each slash.
**Ask:** add a regression test that writes a two-column `CustomKeyGenerator` slash table and reads it back with both partition columns bound in equality predicates, asserting a non-zero row count. Then either make `composeRelativePartitionPath` key-generator aware (one `combine` per column, joined, when the table's key generator is `CustomKeyGenerator`), or, if you would rather let #19666 reject the combination outright, say so in the PR description and link it here. Silently converting rows into an empty result is worse than the hard `HoodieException` #19666 describes.
##########
hudi-client/hudi-client-common/src/main/java/org/apache/hudi/keygen/KeyGenUtils.java:
##########
@@ -291,12 +292,30 @@ public static String getPartitionPath(GenericRecord record, String partitionPath
if (hiveStylePartitioning) {
partitionPath = partitionPathField + "=" + partitionPath;
}
+ // NOTE: See [[slashSeparateDateValue]] on why a leading dash suppresses the substitution
if (slashSeparatedDatePartitioning) {
- partitionPath = partitionPath.replace('-', '/');
+ partitionPath = slashSeparateDateValue(partitionPath);
}
return partitionPath;
}
+ /**
+ * Turns a {@code yyyy-MM-dd} formatted date value into the {@code yyyy/MM/dd} directory structure
+ * requested by {@code hoodie.datasource.write.slash.separated.date.partitioning}.
+ *
+ * <p>A value with a leading dash is returned as-is: substituting would make the partition path
+ * start with {@code "/"}, and an absolute relative-partition-path is resolved inconsistently --
+ * {@link org.apache.hudi.common.fs.FSUtils#constructAbsolutePath(String, String)} chops the
+ * leading {@code "/"} while the {@link org.apache.hudi.storage.StoragePath} overload used by
+ * {@code AbstractTableFileSystemView} lets it URI-resolve away the table base path (a value of
+ * {@code "-5"} lands the writer in {@code "<base>/5"} but the file-system view in {@code "/5"},
+ * and {@code "-"} resolves to the base path itself). Such a value is not a date to begin with,
+ * so nothing is lost by not slashing it.
+ */
+ private static String slashSeparateDateValue(String partitionPath) {
+ return partitionPath.startsWith("-") ? partitionPath : partitionPath.replace('-', '/');
Review Comment:
The leading-dash guard covers one of three value shapes that produce a partition path nothing agrees on. A trailing dash and a doubled dash are equally broken, and the damage is worse than the leading-dash case.
The invariant that matters is that the recorded partition-path string survives `FSUtils.getRelativePartitionPath(base, constructAbsolutePath(base, p))`. `StoragePath.normalize` (`StoragePath.java:300`) strips trailing slashes and `java.net.URI.normalize()` collapses an inner `//`:
```
value slashed directory listed back round-trips
2026-01-05 2026/01/05 <base>/2026/01/05 2026/01/05 yes
-5 -5 (guarded) <base>/-5 -5 yes
5- 5/ <base>/5 5 NO
a--b a//b <base>/a/b a/b NO
2026-01-05- 2026/01/05/ <base>/2026/01/05 2026/01/05 NO (collides with 2026-01-05)
```
The writer resolves the directory with normalization but records the raw string: `HoodieRowCreateHandle.java:303` builds the path via `new StoragePath(basePath, partitionPath)`, while `:132` and `:278` store `5/` into `WriteStatus` and `HoodieWriteStat.partitionPath`. Two concrete consequences:
1. `FilesIndexer.java:185` calls `FSUtils.getFileName(stat.getPath(), partitionStatName)`, which slices at `partition.length() + 1` (`FSUtils.java:615-618`). With partition `5/` and path `5/xxx.parquet` that returns `xx.parquet` -- the metadata-table FILES record stores a filename missing its first character.
2. On the read side `"5/".split("/")` yields a single fragment, so `HoodieSparkUtils.doParsePartitionColumnValues` takes the equal-length branch at `:344` and never applies `replace('/', '-')`; the value reads back as `5`, not `5-`.
Your own compatibility argument for preferring this guard over a `yyyy-MM-dd` match applies unchanged: these are values whose current output is already unreadable, so no layout that works today moves.
**Ask:** widen the predicate in all three write paths.
```suggestion
return partitionPath.startsWith("-") || partitionPath.endsWith("-") || partitionPath.contains("--")
? partitionPath
: partitionPath.replace('-', '/');
```
and correspondingly in the formatter: rename `startsWithDash` to something like `hasUnslashableDash` and implement it as `startsWith(DASH) || endsWith(DASH) || contains(DOUBLE_DASH)` in both `StringPartitionPathFormatter:65` and `UTF8StringPartitionPathFormatter:71`. `UTF8String.endsWith` and `UTF8String.contains` are present in spark-unsafe 3.3.4 through 3.5.5 (I checked the bytecode), so no version gate is needed. The javadoc above and the one on `PartitionPathFormatterBase:125-136` need the same widening.
##########
hudi-client/hudi-client-common/src/main/java/org/apache/hudi/keygen/KeyGenUtils.java:
##########
@@ -291,12 +292,30 @@ public static String getPartitionPath(GenericRecord record, String partitionPath
if (hiveStylePartitioning) {
partitionPath = partitionPathField + "=" + partitionPath;
}
+ // NOTE: See [[slashSeparateDateValue]] on why a leading dash suppresses the substitution
if (slashSeparatedDatePartitioning) {
- partitionPath = partitionPath.replace('-', '/');
+ partitionPath = slashSeparateDateValue(partitionPath);
Review Comment:
The guard runs after the hive-style prefix has been prepended, so `startsWith("-")` can never fire when `hiveStylePartitioning` is on: by `:293` the value has already become `dt=-5`, and `slashSeparateDateValue` returns `dt=/5`. The formatter checks the bare value instead (`PartitionPathFormatterBase.java:68`, before any prefix is added), so the two write paths apply the same guard to different strings.
`dt=/5` is a two-level directory for a single-column table, and a value of `-` gives `dt=/`, whose directory is `<base>/dt=` -- so the recorded string stops round-tripping to its own directory, which is the same failure `FSUtils.getFileName` mis-slices on. `HoodieCatalogTable.scala:296-300` blocks hive-style plus slash on the SQL DDL path only, so `df.write.format("hudi")` and HoodieStreamer still reach this (the gap you filed as #19669).
**Ask:** move `slashSeparateDateValue(...)` so it runs on the bare field value before the `field=` prefix is prepended, here and at `:262`. It is behaviour-preserving for every value the guard does not catch, since `"dt=" + "2026-01-05".replace('-','/')` equals `("dt=2026-01-05").replace('-','/')`, and it makes the guard actually fire under hive-style partitioning.
##########
hudi-client/hudi-client-common/src/main/java/org/apache/hudi/keygen/KeyGenUtils.java:
##########
@@ -257,8 +257,9 @@ public static String getRecordPartitionPath(GenericRecord record,
if (hiveStylePartitioning) {
fieldVal = partitionPathField + "=" + fieldVal;
}
+ // NOTE: See [[slashSeparateDateValue]] on why a leading dash suppresses the substitution
if (partitionPathFields.size() == 1 && slashSeparatedDatePartitioning) {
- fieldVal = fieldVal.replace('-', '/');
+ fieldVal = slashSeparateDateValue(fieldVal);
Review Comment:
This new guard has no test. `SimpleAvroKeyGenerator.java:55` calls the *other* overload, so `TestSimpleKeyGenerator#testSlashSeparatedDatePartitioningLeavesLeadingDashesAlone` exercises `:297`, not this line. The only production caller of `getRecordPartitionPath` is `ComplexAvroKeyGenerator.java:53`, and neither slash test that reaches it uses a leading-dash value:
```
git grep -n "getRecordPartitionPath" -- '*.java' | grep -v /test/
grep -n "slash\|Slash" hudi-client/hudi-spark-client/src/test/java/org/apache/hudi/keygen/TestComplexKeyGenerator.java
```
That leaves half of the new `KeyGenUtils` guard shipping unexercised.
**Ask:** add `testSlashSeparatedDatePartitioningLeavesLeadingDashesAlone` to `TestComplexKeyGenerator` next to the existing `:228` -- same props, `avroRecord.put("timestamp", "-5")`, assert `key.getPartitionPath()` equals `-5`. It is three lines off the existing test and goes red without this guard (`/5`), so it is a real regression guard rather than another characterization test.
##########
hudi-client/hudi-spark-client/src/test/java/org/apache/hudi/keygen/TestPartitionPathFormatter.java:
##########
@@ -0,0 +1,118 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.hudi.keygen;
+
+import org.apache.spark.unsafe.types.UTF8String;
+import org.junit.jupiter.params.ParameterizedTest;
+import org.junit.jupiter.params.provider.ValueSource;
+
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.List;
+
+import static org.apache.hudi.keygen.KeyGenUtils.HUDI_DEFAULT_PARTITION_PATH;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+
+/**
+ * Tests the partition-path formatters backing the key generators, making sure that both the
+ * {@link String} (Avro/{@link org.apache.spark.sql.Row} write path) and the {@link UTF8String}
+ * (row-writer/{@link org.apache.spark.sql.catalyst.InternalRow} write path) flavors produce
+ * identical partition paths.
+ */
+class TestPartitionPathFormatter {
+
+ private static final List<String> SINGLE_FIELD = Collections.singletonList("date_col");
+ private static final List<String> TWO_FIELDS = Arrays.asList("date_col", "city");
+
+ private String combine(boolean useRowWriterPath,
+ boolean hiveStylePartitioning,
+ boolean encode,
+ boolean slashSeparatedDatePartitioning,
+ List<String> fields,
+ Object... parts) {
+ if (useRowWriterPath) {
+ return new UTF8StringPartitionPathFormatter(
+ UTF8StringPartitionPathFormatter.UTF8StringBuilder::new, hiveStylePartitioning, encode,
+ slashSeparatedDatePartitioning).combine(fields, parts).toString();
+ }
+ return new StringPartitionPathFormatter(
+ StringPartitionPathFormatter.JavaStringBuilder::new, hiveStylePartitioning, encode,
+ slashSeparatedDatePartitioning).combine(fields, parts);
+ }
+
+ @ParameterizedTest
+ @ValueSource(booleans = {true, false})
+ void testSlashSeparatedDatePartitioningOnlyAppliesToSingleFieldPartitioning(boolean useRowWriterPath) {
+ // NOTE: This mirrors [[KeyGenUtils#getRecordPartitionPath]] driving the Avro write-path
+ assertEquals("2026-01-05/san-francisco",
+ combine(useRowWriterPath, false, false, true, TWO_FIELDS, "2026-01-05", "san-francisco"));
+ }
+
+ @ParameterizedTest
+ @ValueSource(booleans = {true, false})
+ void testSlashSeparatedDatePartitioningHandlesNullAndEmptyValues(boolean useRowWriterPath) {
+ assertEquals(HUDI_DEFAULT_PARTITION_PATH,
+ combine(useRowWriterPath, false, false, true, SINGLE_FIELD, new Object[] {null}));
+ assertEquals(HUDI_DEFAULT_PARTITION_PATH,
+ combine(useRowWriterPath, false, false, true, SINGLE_FIELD, ""));
+ }
+
+ @ParameterizedTest
+ @ValueSource(booleans = {true, false})
+ void testSlashSeparatedDatePartitioningLeavesLeadingDashesAlone(boolean useRowWriterPath) {
+ // NOTE: Substituting here would yield a partition path starting with "/", which
+ // [[FSUtils#constructAbsolutePath(String, String)]] and the [[StoragePath]] overload used
+ // by [[AbstractTableFileSystemView]] resolve differently -- the former chops the leading
+ // "/", the latter URI-resolves the table base path away -- so the writer and the
+ // file-system view would disagree on where the partition lives
+ assertEquals("-5", combine(useRowWriterPath, false, false, true, SINGLE_FIELD, "-5"));
+ assertEquals("-", combine(useRowWriterPath, false, false, true, SINGLE_FIELD, "-"));
+ assertEquals("--5", combine(useRowWriterPath, false, false, true, SINGLE_FIELD, "--5"));
+ // A dash anywhere else is still a separator: only a leading one produces an absolute path
+ assertEquals("5/", combine(useRowWriterPath, false, false, true, SINGLE_FIELD, "5-"));
Review Comment:
This pins the broken shape as intended behaviour, and the comment states an invariant that does not hold. A trailing dash produces a trailing-slash path and `a--b` produces a doubled-slash path; both fail the same round trip the leading-dash guard exists to protect. `5-` writes to `<base>/5` but records `5/`, and `a--b` writes to `<base>/a/b` but records `a//b` -- evidence in my comment on `KeyGenUtils#slashSeparateDateValue`. Once this merges, a green test locks the wrong behaviour in and the follow-up has to argue with an assertion rather than with a gap.
**Ask:** assert the guarded values instead, and widen the comment to name all three bad shapes. This goes green once the guard change on `slashSeparateDateValue` and the two formatters is in.
```suggestion
// A dash that would turn into a leading, trailing or doubled "/" is left alone as well
assertEquals("5-", combine(useRowWriterPath, false, false, true, SINGLE_FIELD, "5-"));
assertEquals("a--b", combine(useRowWriterPath, false, false, true, SINGLE_FIELD, "a--b"));
```
##########
hudi-spark-datasource/hudi-spark/src/test/scala/org/apache/spark/sql/hudi/common/TestSlashSeparatedPartitionValue.scala:
##########
@@ -90,6 +90,113 @@ class TestSlashSeparatedPartitionValue extends HoodieSparkSqlTestBase {
}
}
+ test("Test slash separated date partitions written through the row writer") {
+ withSQLConf("hoodie.spark.sql.insert.into.operation" -> "bulk_insert") {
+ withTempDir { tmp =>
+ val targetTable = generateTableName
+ val tablePath = s"${tmp.getCanonicalPath}/$targetTable"
+
+ spark.sql(
+ s"""
+ |create table $targetTable (
+ | `id` string,
+ | `name` string,
+ | `ts` bigint,
+ | `datestr` STRING
+ |) using hudi
+ | tblproperties (
+ | 'primaryKey' = 'id',
+ | 'type' = 'COW',
+ | 'preCombineField'='ts',
+ | 'hoodie.datasource.write.slash.separated.date.partitioning'='true'
+ | )
+ | partitioned by (`datestr`)
+ | location '$tablePath'
+ """.stripMargin)
+
+ // NOTE: The row writer derives the partition path off of an [[InternalRow]], which used to
+ // blow up with a [[ClassCastException]]; a null partition value used to NPE
+ spark.sql(
+ s"""
+ | insert into $targetTable values
+ | (1, 'a1', 1000, "2026-01-05"),
+ | (2, 'a2', 2000, "2026-01-06"),
+ | (3, 'a3', 3000, null)
+ """.stripMargin)
+
+ checkAnswer(s"select id, name, ts, _hoodie_partition_path, datestr from $targetTable order by id")(
+ Seq("1", "a1", 1000, "2026/01/05", "2026-01-05"),
+ Seq("2", "a2", 2000, "2026/01/06", "2026-01-06"),
+ Seq("3", "a3", 3000, "__HIVE_DEFAULT_PARTITION__", null)
+ )
+
+ val metaClient = HoodieTableMetaClient.builder()
+ .setConf(HadoopFSUtils.getStorageConfWithCopy(spark.sparkContext.hadoopConfiguration))
+ .setBasePath(tablePath)
+ .build()
+ assertTrue(metaClient.getStorage.exists(new StoragePath(tablePath, "2026/01/05")),
+ s"Partition path 2026/01/05 should exist")
+ assertTrue(metaClient.getStorage.exists(new StoragePath(tablePath, "2026/01/06")),
+ s"Partition path 2026/01/06 should exist")
+ assertTrue(metaClient.getStorage.exists(new StoragePath(tablePath, "__HIVE_DEFAULT_PARTITION__")),
+ s"Partition path __HIVE_DEFAULT_PARTITION__ should exist")
Review Comment:
Both new tests drop the one assertion in this file that checks writer-name against metadata-table-name agreement, which is the invariant this whole PR is about. The two pre-existing tests do make it: `:80-88` builds a `HoodieBackedTableMetadata` and asserts `getAllPartitionPaths` contains `2026/01/05`, and the test at `:257-262` does the same.
`_hoodie_partition_path` plus `storage.exists(...)` are not a substitute -- both still pass when the writer records a partition name that the metadata table and directory listing disagree with (see my comment on `KeyGenUtils#slashSeparateDateValue` for values where they do).
**Ask:** copy the `HoodieBackedTableMetadata` block from `:80-88` into both new tests and assert `getAllPartitionPaths` contains `2026/01/05`, `2026/01/06` and, for this one, `__HIVE_DEFAULT_PARTITION__`.
##########
hudi-spark-datasource/hudi-spark/src/test/scala/org/apache/spark/sql/hudi/common/TestSlashSeparatedPartitionValue.scala:
##########
@@ -90,6 +90,113 @@ class TestSlashSeparatedPartitionValue extends HoodieSparkSqlTestBase {
}
}
+ test("Test slash separated date partitions written through the row writer") {
+ withSQLConf("hoodie.spark.sql.insert.into.operation" -> "bulk_insert") {
+ withTempDir { tmp =>
+ val targetTable = generateTableName
+ val tablePath = s"${tmp.getCanonicalPath}/$targetTable"
+
+ spark.sql(
+ s"""
+ |create table $targetTable (
+ | `id` string,
+ | `name` string,
+ | `ts` bigint,
+ | `datestr` STRING
+ |) using hudi
+ | tblproperties (
+ | 'primaryKey' = 'id',
+ | 'type' = 'COW',
+ | 'preCombineField'='ts',
+ | 'hoodie.datasource.write.slash.separated.date.partitioning'='true'
+ | )
+ | partitioned by (`datestr`)
+ | location '$tablePath'
+ """.stripMargin)
+
+ // NOTE: The row writer derives the partition path off of an [[InternalRow]], which used to
+ // blow up with a [[ClassCastException]]; a null partition value used to NPE
+ spark.sql(
+ s"""
+ | insert into $targetTable values
+ | (1, 'a1', 1000, "2026-01-05"),
+ | (2, 'a2', 2000, "2026-01-06"),
+ | (3, 'a3', 3000, null)
+ """.stripMargin)
+
+ checkAnswer(s"select id, name, ts, _hoodie_partition_path, datestr from $targetTable order by id")(
+ Seq("1", "a1", 1000, "2026/01/05", "2026-01-05"),
+ Seq("2", "a2", 2000, "2026/01/06", "2026-01-06"),
+ Seq("3", "a3", 3000, "__HIVE_DEFAULT_PARTITION__", null)
+ )
+
+ val metaClient = HoodieTableMetaClient.builder()
+ .setConf(HadoopFSUtils.getStorageConfWithCopy(spark.sparkContext.hadoopConfiguration))
+ .setBasePath(tablePath)
+ .build()
+ assertTrue(metaClient.getStorage.exists(new StoragePath(tablePath, "2026/01/05")),
+ s"Partition path 2026/01/05 should exist")
+ assertTrue(metaClient.getStorage.exists(new StoragePath(tablePath, "2026/01/06")),
+ s"Partition path 2026/01/06 should exist")
+ assertTrue(metaClient.getStorage.exists(new StoragePath(tablePath, "__HIVE_DEFAULT_PARTITION__")),
+ s"Partition path __HIVE_DEFAULT_PARTITION__ should exist")
+ }
+ }
+ }
+
+ test("Test slash separated date partitions on a DATE typed partition column") {
+ Seq("insert", "bulk_insert").foreach { operation =>
Review Comment:
The `insert` leg here duplicates an already-merged test, and is the weaker of the two. `TestTypedPartitionValues.scala:28` ("Test reading a date partition column laid out as yyyy/MM/dd", added in #19652, which is an ancestor of this branch) already creates a DATE partition column with `slash.separated.date.partitioning = 'true'`, writes with the default operation -- `SPARK_SQL_INSERT_INTO_OPERATION` defaults to `insert` -- and asserts both `_hoodie_partition_path` and the DATE round trip, plus two partition-pruning assertions this test does not make. So the `insert` iteration passes on master unchanged, and only the `bulk_insert` iteration discriminates the row-writer rendering this PR fixes.
**Ask:** keep only the leg that can fail.
```suggestion
Seq("bulk_insert").foreach { operation =>
```
Better still, drop the loop entirely and pull in the two pruning assertions from `TestTypedPartitionValues.scala:63-68`, so the new test covers the row-writer DATE path *and* pruning rather than re-running the Avro leg.
##########
hudi-spark-datasource/hudi-spark/src/test/scala/org/apache/spark/sql/hudi/common/TestSlashSeparatedPartitionValue.scala:
##########
@@ -90,6 +90,113 @@ class TestSlashSeparatedPartitionValue extends HoodieSparkSqlTestBase {
}
}
+ test("Test slash separated date partitions written through the row writer") {
+ withSQLConf("hoodie.spark.sql.insert.into.operation" -> "bulk_insert") {
+ withTempDir { tmp =>
+ val targetTable = generateTableName
+ val tablePath = s"${tmp.getCanonicalPath}/$targetTable"
+
+ spark.sql(
+ s"""
+ |create table $targetTable (
+ | `id` string,
+ | `name` string,
+ | `ts` bigint,
+ | `datestr` STRING
+ |) using hudi
+ | tblproperties (
+ | 'primaryKey' = 'id',
+ | 'type' = 'COW',
+ | 'preCombineField'='ts',
+ | 'hoodie.datasource.write.slash.separated.date.partitioning'='true'
+ | )
+ | partitioned by (`datestr`)
+ | location '$tablePath'
+ """.stripMargin)
+
+ // NOTE: The row writer derives the partition path off of an [[InternalRow]], which used to
+ // blow up with a [[ClassCastException]]; a null partition value used to NPE
+ spark.sql(
+ s"""
+ | insert into $targetTable values
+ | (1, 'a1', 1000, "2026-01-05"),
+ | (2, 'a2', 2000, "2026-01-06"),
+ | (3, 'a3', 3000, null)
+ """.stripMargin)
+
+ checkAnswer(s"select id, name, ts, _hoodie_partition_path, datestr from $targetTable order by id")(
+ Seq("1", "a1", 1000, "2026/01/05", "2026-01-05"),
+ Seq("2", "a2", 2000, "2026/01/06", "2026-01-06"),
+ Seq("3", "a3", 3000, "__HIVE_DEFAULT_PARTITION__", null)
+ )
+
+ val metaClient = HoodieTableMetaClient.builder()
+ .setConf(HadoopFSUtils.getStorageConfWithCopy(spark.sparkContext.hadoopConfiguration))
+ .setBasePath(tablePath)
+ .build()
+ assertTrue(metaClient.getStorage.exists(new StoragePath(tablePath, "2026/01/05")),
+ s"Partition path 2026/01/05 should exist")
+ assertTrue(metaClient.getStorage.exists(new StoragePath(tablePath, "2026/01/06")),
+ s"Partition path 2026/01/06 should exist")
+ assertTrue(metaClient.getStorage.exists(new StoragePath(tablePath, "__HIVE_DEFAULT_PARTITION__")),
+ s"Partition path __HIVE_DEFAULT_PARTITION__ should exist")
+ }
+ }
+ }
+
+ test("Test slash separated date partitions on a DATE typed partition column") {
+ Seq("insert", "bulk_insert").foreach { operation =>
+ withSQLConf("hoodie.spark.sql.insert.into.operation" -> operation) {
+ withTempDir { tmp =>
+ val targetTable = generateTableName
+ val tablePath = s"${tmp.getCanonicalPath}/$targetTable"
+
+ spark.sql(
Review Comment:
Cleanliness, not urgent: this is the fourth copy of the same DDL block in this file, and this PR added two of the four. Exact counts in the post-PR file (268 lines):
* `create table ... tblproperties(... slash.separated.date.partitioning ...) partitioned by ... location`: four 17-line copies at `:36-52`, `:99-115`, `:154-170`, `:206-222`, so 68 lines. Only two things vary -- the partition column type (`STRING` three times, `DATE` once) and the property value.
* `HoodieTableMetaClient.builder().setConf(...).setBasePath(tablePath).build()`: four 4-line copies at `:68-71`, `:133-136`, `:187-190`, `:243-246`, so 16 lines.
* `assertTrue(metaClient.getStorage.exists(new StoragePath(tablePath, ...)))`: nine asserts over 18 lines.
**Ask:** extract three private helpers -- `createSlashPartitionedTable(name, path, partitionColType = "STRING", slashSeparated = "true")`, `buildMetaClient(path)` and `assertPartitionDirsExist(metaClient, path, partitions*)`. That is roughly 31 lines of helper replacing 102 lines of copy-paste, takes the file to about 209 lines, and makes the next slash test cost three lines instead of forty.
##########
hudi-spark-datasource/hudi-spark/src/test/scala/org/apache/spark/sql/hudi/common/TestSlashSeparatedPartitionValue.scala:
##########
@@ -90,6 +90,113 @@ class TestSlashSeparatedPartitionValue extends HoodieSparkSqlTestBase {
}
}
+ test("Test slash separated date partitions written through the row writer") {
Review Comment:
Coverage gap worth closing while you are in this file: nothing in the repo upserts into a slash-partitioned table. All four tests here are `type = 'COW'` and insert-only, `TestTypedPartitionValues.scala` is insert-only, and no slash test uses MOR:
```
git grep -n "slash.separated.date.partitioning\|SLASH_SEPARATED_DATE" -- '*/test/*'
```
That leaves index lookup and file-system-view agreement on a slash partition path entirely unexercised, which is exactly the surface where a partition-path string that does not match what listing produces shows up as duplicate records rather than as an exception.
**Ask:** add one upsert case to this suite -- insert into `2026/01/05`, then upsert a row with the same key and the same partition value, and assert the row count in that partition is still one and that no second partition directory appeared. A MOR variant would be a bonus, not a requirement.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@hudi.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] fix(spark): make slash-separated date partitioning work on the row writer path [hudi]
Posted by "hudi-bot (via GitHub)" <gi...@apache.org>.
hudi-bot commented on PR #19648:
URL: https://github.com/apache/hudi/pull/19648#issuecomment-5354375529
<!--
Meta data
{
"version" : 1,
"metaDataEntries" : [ {
"hash" : "ce3ab56d080092972df722ab619a3cf71308b6c2",
"status" : "DELETED",
"url" : "https://dev.azure.com/apachehudi/a1a51da7-8592-47d4-88dc-fd67bed336bb/_build/results?buildId=16342",
"triggerID" : "ce3ab56d080092972df722ab619a3cf71308b6c2",
"triggerType" : "PUSH"
}, {
"hash" : "8d523937035c816ddf765ac61acad162e311b738",
"status" : "FAILURE",
"url" : "https://dev.azure.com/apachehudi/a1a51da7-8592-47d4-88dc-fd67bed336bb/_build/results?buildId=16390",
"triggerID" : "8d523937035c816ddf765ac61acad162e311b738",
"triggerType" : "PUSH"
}, {
"hash" : "fdd04bfbf709f806768ae4b4b259a679b08e2aa4",
"status" : "UNKNOWN",
"url" : "TBD",
"triggerID" : "fdd04bfbf709f806768ae4b4b259a679b08e2aa4",
"triggerType" : "PUSH"
} ]
}-->
## CI report:
* 8d523937035c816ddf765ac61acad162e311b738 Azure: [FAILURE](https://dev.azure.com/apachehudi/a1a51da7-8592-47d4-88dc-fd67bed336bb/_build/results?buildId=16390)
* fdd04bfbf709f806768ae4b4b259a679b08e2aa4 UNKNOWN
<details>
<summary>Bot commands</summary>
@hudi-bot supports the following commands:
- `@hudi-bot run azure` re-run the last Azure build
</details>
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@hudi.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] fix(spark): make slash-separated date partitioning work on the row writer path [hudi]
Posted by "hudi-bot (via GitHub)" <gi...@apache.org>.
hudi-bot commented on PR #19648:
URL: https://github.com/apache/hudi/pull/19648#issuecomment-5378734022
<!--
Meta data
{
"version" : 1,
"metaDataEntries" : [ {
"hash" : "ce3ab56d080092972df722ab619a3cf71308b6c2",
"status" : "DELETED",
"url" : "https://dev.azure.com/apachehudi/a1a51da7-8592-47d4-88dc-fd67bed336bb/_build/results?buildId=16342",
"triggerID" : "ce3ab56d080092972df722ab619a3cf71308b6c2",
"triggerType" : "PUSH"
}, {
"hash" : "8d523937035c816ddf765ac61acad162e311b738",
"status" : "DELETED",
"url" : "https://dev.azure.com/apachehudi/a1a51da7-8592-47d4-88dc-fd67bed336bb/_build/results?buildId=16390",
"triggerID" : "8d523937035c816ddf765ac61acad162e311b738",
"triggerType" : "PUSH"
}, {
"hash" : "fdd04bfbf709f806768ae4b4b259a679b08e2aa4",
"status" : "DELETED",
"url" : "https://dev.azure.com/apachehudi/a1a51da7-8592-47d4-88dc-fd67bed336bb/_build/results?buildId=16413",
"triggerID" : "fdd04bfbf709f806768ae4b4b259a679b08e2aa4",
"triggerType" : "PUSH"
}, {
"hash" : "8f1cb373283c41cf6513e83b169e692902c91c4e",
"status" : "FAILURE",
"url" : "https://dev.azure.com/apachehudi/a1a51da7-8592-47d4-88dc-fd67bed336bb/_build/results?buildId=16440",
"triggerID" : "8f1cb373283c41cf6513e83b169e692902c91c4e",
"triggerType" : "PUSH"
}, {
"hash" : "8ce9ad0a09e3fc8a889eefab03abc38f6a1e8aa5",
"status" : "UNKNOWN",
"url" : "TBD",
"triggerID" : "8ce9ad0a09e3fc8a889eefab03abc38f6a1e8aa5",
"triggerType" : "PUSH"
} ]
}-->
## CI report:
* 8f1cb373283c41cf6513e83b169e692902c91c4e Azure: [FAILURE](https://dev.azure.com/apachehudi/a1a51da7-8592-47d4-88dc-fd67bed336bb/_build/results?buildId=16440)
* 8ce9ad0a09e3fc8a889eefab03abc38f6a1e8aa5 UNKNOWN
<details>
<summary>Bot commands</summary>
@hudi-bot supports the following commands:
- `@hudi-bot run azure` re-run the last Azure build
</details>
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@hudi.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] fix(spark): make slash-separated date partitioning work on the row writer path [hudi]
Posted by "hudi-agent (via GitHub)" <gi...@apache.org>.
hudi-agent commented on code in PR #19648:
URL: https://github.com/apache/hudi/pull/19648#discussion_r3795960491
##########
hudi-client/hudi-spark-client/src/main/java/org/apache/hudi/keygen/PartitionPathFormatterBase.java:
##########
@@ -75,15 +75,11 @@ public final S combine(List<String> partitionPathFields, Object... partitionPath
if (useHiveStylePartitioning) {
Review Comment:
🤖 For the hive-style + slash-separated + single-field combo, the loop appends `field=value` but never calls `replaceDashesWithSlashes`, so it yields `date_col=2026-01-05`. The Avro path (`KeyGenUtils.getPartitionPath` and `getRecordPartitionPath`, size==1) applies the dash→slash substitution *after* the hive prefix and gives `date_col=2026/01/05`. Since the PR's goal is that both write paths derive the same partition path, should this case be aligned too (or is hive-style intentionally exempt)? It's pre-existing behavior, so a follow-up is fine, but the new `testHiveStylePartitioningTakesPrecedence` bakes in the divergent result.
<sub><i>⚠️ AI-generated; verify before applying. React 👍/👎 to flag quality.</i></sub>
##########
hudi-client/hudi-spark-client/src/test/java/org/apache/hudi/keygen/TestPartitionPathFormatter.java:
##########
@@ -0,0 +1,110 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.hudi.keygen;
+
+import org.apache.spark.unsafe.types.UTF8String;
+import org.junit.jupiter.params.ParameterizedTest;
+import org.junit.jupiter.params.provider.ValueSource;
+
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.List;
+
+import static org.apache.hudi.common.util.PartitionPathEncodeUtils.DEFAULT_PARTITION_PATH;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+
+/**
+ * Tests the partition-path formatters backing the key generators, making sure that both the
+ * {@link String} (Avro/{@link org.apache.spark.sql.Row} write path) and the {@link UTF8String}
+ * (row-writer/{@link org.apache.spark.sql.catalyst.InternalRow} write path) flavors produce
+ * identical partition paths.
+ */
+class TestPartitionPathFormatter {
+
+ private static final List<String> SINGLE_FIELD = Collections.singletonList("date_col");
+ private static final List<String> TWO_FIELDS = Arrays.asList("date_col", "city");
+
+ private String combine(boolean unsafe,
+ boolean hiveStylePartitioning,
+ boolean encode,
+ boolean slashSeparatedDatePartitioning,
+ List<String> fields,
+ Object... parts) {
Review Comment:
🤖 nit: could you rename `unsafe` to something like `useUTF8` or `useRowWriterPath`? On its own `unsafe` reads as "danger" rather than "use the UTF8String/unsafe-row formatter", which makes the call sites a little harder to parse at a glance.
<sub><i>⚠️ AI-generated; verify before applying. React 👍/👎 to flag quality.</i></sub>
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@hudi.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] fix(spark): make slash-separated date partitioning work on the row writer path [hudi]
Posted by "hudi-bot (via GitHub)" <gi...@apache.org>.
hudi-bot commented on PR #19648:
URL: https://github.com/apache/hudi/pull/19648#issuecomment-5317031991
<!--
Meta data
{
"version" : 1,
"metaDataEntries" : [ {
"hash" : "ce3ab56d080092972df722ab619a3cf71308b6c2",
"status" : "UNKNOWN",
"url" : "TBD",
"triggerID" : "ce3ab56d080092972df722ab619a3cf71308b6c2",
"triggerType" : "PUSH"
} ]
}-->
## CI report:
* ce3ab56d080092972df722ab619a3cf71308b6c2 UNKNOWN
<details>
<summary>Bot commands</summary>
@hudi-bot supports the following commands:
- `@hudi-bot run azure` re-run the last Azure build
</details>
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@hudi.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] fix(spark): make slash-separated date partitioning work on the row writer path [hudi]
Posted by "hudi-bot (via GitHub)" <gi...@apache.org>.
hudi-bot commented on PR #19648:
URL: https://github.com/apache/hudi/pull/19648#issuecomment-5354951483
<!--
Meta data
{
"version" : 1,
"metaDataEntries" : [ {
"hash" : "ce3ab56d080092972df722ab619a3cf71308b6c2",
"status" : "DELETED",
"url" : "https://dev.azure.com/apachehudi/a1a51da7-8592-47d4-88dc-fd67bed336bb/_build/results?buildId=16342",
"triggerID" : "ce3ab56d080092972df722ab619a3cf71308b6c2",
"triggerType" : "PUSH"
}, {
"hash" : "8d523937035c816ddf765ac61acad162e311b738",
"status" : "DELETED",
"url" : "https://dev.azure.com/apachehudi/a1a51da7-8592-47d4-88dc-fd67bed336bb/_build/results?buildId=16390",
"triggerID" : "8d523937035c816ddf765ac61acad162e311b738",
"triggerType" : "PUSH"
}, {
"hash" : "fdd04bfbf709f806768ae4b4b259a679b08e2aa4",
"status" : "FAILURE",
"url" : "https://dev.azure.com/apachehudi/a1a51da7-8592-47d4-88dc-fd67bed336bb/_build/results?buildId=16413",
"triggerID" : "fdd04bfbf709f806768ae4b4b259a679b08e2aa4",
"triggerType" : "PUSH"
} ]
}-->
## CI report:
* fdd04bfbf709f806768ae4b4b259a679b08e2aa4 Azure: [FAILURE](https://dev.azure.com/apachehudi/a1a51da7-8592-47d4-88dc-fd67bed336bb/_build/results?buildId=16413)
<details>
<summary>Bot commands</summary>
@hudi-bot supports the following commands:
- `@hudi-bot run azure` re-run the last Azure build
</details>
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@hudi.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] fix(spark): make slash-separated date partitioning work on the row writer path [hudi]
Posted by "hudi-bot (via GitHub)" <gi...@apache.org>.
hudi-bot commented on PR #19648:
URL: https://github.com/apache/hudi/pull/19648#issuecomment-5365367849
<!--
Meta data
{
"version" : 1,
"metaDataEntries" : [ {
"hash" : "ce3ab56d080092972df722ab619a3cf71308b6c2",
"status" : "DELETED",
"url" : "https://dev.azure.com/apachehudi/a1a51da7-8592-47d4-88dc-fd67bed336bb/_build/results?buildId=16342",
"triggerID" : "ce3ab56d080092972df722ab619a3cf71308b6c2",
"triggerType" : "PUSH"
}, {
"hash" : "8d523937035c816ddf765ac61acad162e311b738",
"status" : "DELETED",
"url" : "https://dev.azure.com/apachehudi/a1a51da7-8592-47d4-88dc-fd67bed336bb/_build/results?buildId=16390",
"triggerID" : "8d523937035c816ddf765ac61acad162e311b738",
"triggerType" : "PUSH"
}, {
"hash" : "fdd04bfbf709f806768ae4b4b259a679b08e2aa4",
"status" : "FAILURE",
"url" : "https://dev.azure.com/apachehudi/a1a51da7-8592-47d4-88dc-fd67bed336bb/_build/results?buildId=16413",
"triggerID" : "fdd04bfbf709f806768ae4b4b259a679b08e2aa4",
"triggerType" : "PUSH"
}, {
"hash" : "8f1cb373283c41cf6513e83b169e692902c91c4e",
"status" : "PENDING",
"url" : "https://dev.azure.com/apachehudi/a1a51da7-8592-47d4-88dc-fd67bed336bb/_build/results?buildId=16440",
"triggerID" : "8f1cb373283c41cf6513e83b169e692902c91c4e",
"triggerType" : "PUSH"
} ]
}-->
## CI report:
* fdd04bfbf709f806768ae4b4b259a679b08e2aa4 Azure: [FAILURE](https://dev.azure.com/apachehudi/a1a51da7-8592-47d4-88dc-fd67bed336bb/_build/results?buildId=16413)
* 8f1cb373283c41cf6513e83b169e692902c91c4e Azure: [PENDING](https://dev.azure.com/apachehudi/a1a51da7-8592-47d4-88dc-fd67bed336bb/_build/results?buildId=16440)
<details>
<summary>Bot commands</summary>
@hudi-bot supports the following commands:
- `@hudi-bot run azure` re-run the last Azure build
</details>
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@hudi.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] fix(spark): make slash-separated date partitioning work on the row writer path [hudi]
Posted by "voonhous (via GitHub)" <gi...@apache.org>.
voonhous commented on code in PR #19648:
URL: https://github.com/apache/hudi/pull/19648#discussion_r3819038112
##########
hudi-spark-datasource/hudi-spark/src/test/scala/org/apache/spark/sql/hudi/common/TestSlashSeparatedPartitionValue.scala:
##########
@@ -90,6 +90,113 @@ class TestSlashSeparatedPartitionValue extends HoodieSparkSqlTestBase {
}
}
+ test("Test slash separated date partitions written through the row writer") {
+ withSQLConf("hoodie.spark.sql.insert.into.operation" -> "bulk_insert") {
+ withTempDir { tmp =>
+ val targetTable = generateTableName
+ val tablePath = s"${tmp.getCanonicalPath}/$targetTable"
+
+ spark.sql(
+ s"""
+ |create table $targetTable (
+ | `id` string,
+ | `name` string,
+ | `ts` bigint,
+ | `datestr` STRING
+ |) using hudi
+ | tblproperties (
+ | 'primaryKey' = 'id',
+ | 'type' = 'COW',
+ | 'preCombineField'='ts',
+ | 'hoodie.datasource.write.slash.separated.date.partitioning'='true'
+ | )
+ | partitioned by (`datestr`)
+ | location '$tablePath'
+ """.stripMargin)
+
+ // NOTE: The row writer derives the partition path off of an [[InternalRow]], which used to
+ // blow up with a [[ClassCastException]]; a null partition value used to NPE
+ spark.sql(
+ s"""
+ | insert into $targetTable values
+ | (1, 'a1', 1000, "2026-01-05"),
+ | (2, 'a2', 2000, "2026-01-06"),
+ | (3, 'a3', 3000, null)
+ """.stripMargin)
+
+ checkAnswer(s"select id, name, ts, _hoodie_partition_path, datestr from $targetTable order by id")(
+ Seq("1", "a1", 1000, "2026/01/05", "2026-01-05"),
+ Seq("2", "a2", 2000, "2026/01/06", "2026-01-06"),
+ Seq("3", "a3", 3000, "__HIVE_DEFAULT_PARTITION__", null)
+ )
+
+ val metaClient = HoodieTableMetaClient.builder()
+ .setConf(HadoopFSUtils.getStorageConfWithCopy(spark.sparkContext.hadoopConfiguration))
+ .setBasePath(tablePath)
+ .build()
+ assertTrue(metaClient.getStorage.exists(new StoragePath(tablePath, "2026/01/05")),
Review Comment:
The partition DDL commands are slash-unaware on the table this test creates: `HoodieSqlCommonUtils#makePartitionPath` (`HoodieSqlCommonUtils.scala:420-427`) reads hive-style and urlencode from table config but never `getSlashSeparatedDatePartitioning`, so `alter table ... drop partition (datestr='2026-01-05')` targets `2026-01-05` while the directory is `2026/01/05`: the replacecommit replaces zero file groups and the drop is a silent no-op, and `add partition` creates a bogus dashed directory. Distinct from #19666/#19668/#19669.
Optional, nothing needed in this PR: this is a pre-existing bug in a file this PR does not touch, so feel free to leave it. Flagging here so it is on record next to the tests that create such tables.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@hudi.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] fix(spark): make slash-separated date partitioning work on the row writer path [hudi]
Posted by "voonhous (via GitHub)" <gi...@apache.org>.
voonhous commented on code in PR #19648:
URL: https://github.com/apache/hudi/pull/19648#discussion_r3819032311
##########
hudi-client/hudi-spark-client/src/main/java/org/apache/hudi/keygen/PartitionPathFormatterBase.java:
##########
@@ -62,11 +62,17 @@ public final S combine(List<String> partitionPathFields, Object... partitionPath
// Avoid creating [[StringBuilder]] in case there's just one partition-path part,
// and Hive-style of partitioning is not required
if (!useHiveStylePartitioning && partitionPathParts.length == 1) {
- if (slashSeparatedDatePartitioning) {
- return ((S) ((String) toString(partitionPathParts[0])).replace('-', '/'));
- } else {
- return tryEncode(handleEmpty(toString(partitionPathParts[0])));
- }
+ S partitionPathPart = tryEncode(handleEmpty(toString(partitionPathParts[0])));
+ // NOTE: For [[SimpleKeyGenerator]]/[[ComplexKeyGenerator]] slash-separated date partitioning
+ // only kicks in for a table partitioned by a single (date) column, mirroring
+ // [[KeyGenUtils#getPartitionPath]] (single field) and [[KeyGenUtils#getRecordPartitionPath]]
+ // (which guards on a single field as well) driving the Avro write-path: both write-paths
+ // have to derive the very same partition path for a record.
+ // [[CustomKeyGenerator]] is not an exception to this: it builds one single-field
+ // sub-key-generator per partition field, so every field takes this branch and a
+ // multi-field table does get each of its values slash-separated -- on the Avro,
+ // [[org.apache.spark.sql.Row]] and [[org.apache.spark.sql.catalyst.InternalRow]] paths alike
+ return slashSeparatedDatePartitioning ? replaceDashesWithSlashes(partitionPathPart) : partitionPathPart;
Review Comment:
The substitution is unconditional, so any value with a leading dash yields a leading-slash path: `-5` becomes `/5`. `FSUtils.constructAbsolutePath(String, String)` chops the leading `/` (`FSUtils.java:590-594`), but the `(StoragePath, String)` overload used by `AbstractTableFileSystemView` does not, and `StoragePath(parent, child)` URI-resolves an absolute child into replacing the base path, so the writer and the file-system view disagree on where that partition lives. Pre-existing on the Avro path (`KeyGenUtils` does the same `replace`), but this PR makes it reachable on the row-writer paths.
Ask: fix this in this PR rather than a follow-up -- guard the substitution (e.g. skip it when the value starts with a dash, or apply it only to values matching `yyyy-MM-dd`) in `PartitionPathFormatterBase#combine` and in `KeyGenUtils#getPartitionPath`/`getRecordPartitionPath` alike so all write paths stay aligned, and add a `-5` assert to `TestPartitionPathFormatter` pinning the guarded behavior.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@hudi.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] fix(spark): make slash-separated date partitioning work on the row writer path [hudi]
Posted by "voonhous (via GitHub)" <gi...@apache.org>.
voonhous commented on code in PR #19648:
URL: https://github.com/apache/hudi/pull/19648#discussion_r3819038112
##########
hudi-spark-datasource/hudi-spark/src/test/scala/org/apache/spark/sql/hudi/common/TestSlashSeparatedPartitionValue.scala:
##########
@@ -90,6 +90,113 @@ class TestSlashSeparatedPartitionValue extends HoodieSparkSqlTestBase {
}
}
+ test("Test slash separated date partitions written through the row writer") {
+ withSQLConf("hoodie.spark.sql.insert.into.operation" -> "bulk_insert") {
+ withTempDir { tmp =>
+ val targetTable = generateTableName
+ val tablePath = s"${tmp.getCanonicalPath}/$targetTable"
+
+ spark.sql(
+ s"""
+ |create table $targetTable (
+ | `id` string,
+ | `name` string,
+ | `ts` bigint,
+ | `datestr` STRING
+ |) using hudi
+ | tblproperties (
+ | 'primaryKey' = 'id',
+ | 'type' = 'COW',
+ | 'preCombineField'='ts',
+ | 'hoodie.datasource.write.slash.separated.date.partitioning'='true'
+ | )
+ | partitioned by (`datestr`)
+ | location '$tablePath'
+ """.stripMargin)
+
+ // NOTE: The row writer derives the partition path off of an [[InternalRow]], which used to
+ // blow up with a [[ClassCastException]]; a null partition value used to NPE
+ spark.sql(
+ s"""
+ | insert into $targetTable values
+ | (1, 'a1', 1000, "2026-01-05"),
+ | (2, 'a2', 2000, "2026-01-06"),
+ | (3, 'a3', 3000, null)
+ """.stripMargin)
+
+ checkAnswer(s"select id, name, ts, _hoodie_partition_path, datestr from $targetTable order by id")(
+ Seq("1", "a1", 1000, "2026/01/05", "2026-01-05"),
+ Seq("2", "a2", 2000, "2026/01/06", "2026-01-06"),
+ Seq("3", "a3", 3000, "__HIVE_DEFAULT_PARTITION__", null)
+ )
+
+ val metaClient = HoodieTableMetaClient.builder()
+ .setConf(HadoopFSUtils.getStorageConfWithCopy(spark.sparkContext.hadoopConfiguration))
+ .setBasePath(tablePath)
+ .build()
+ assertTrue(metaClient.getStorage.exists(new StoragePath(tablePath, "2026/01/05")),
Review Comment:
The partition DDL commands are slash-unaware on the table this test creates: `HoodieSqlCommonUtils#makePartitionPath` (`HoodieSqlCommonUtils.scala:420-427`) reads hive-style and urlencode from table config but never `getSlashSeparatedDatePartitioning`, so `alter table ... drop partition (datestr='2026-01-05')` targets `2026-01-05` while the directory is `2026/01/05`: the replacecommit replaces zero file groups and the drop is a silent no-op, and `add partition` creates a bogus dashed directory. Distinct from #19666/#19668/#19669.
Ask: file a follow-up issue for `makePartitionPath`; a drop-partition case in this suite can land with that fix.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@hudi.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] fix(spark): make slash-separated date partitioning work on the row writer path [hudi]
Posted by "SEPURI-SAI-KRISHNA (via GitHub)" <gi...@apache.org>.
SEPURI-SAI-KRISHNA commented on code in PR #19648:
URL: https://github.com/apache/hudi/pull/19648#discussion_r3836360492
##########
hudi-spark-datasource/hudi-spark/src/test/scala/org/apache/spark/sql/hudi/common/TestSlashSeparatedPartitionValue.scala:
##########
@@ -90,6 +90,113 @@ class TestSlashSeparatedPartitionValue extends HoodieSparkSqlTestBase {
}
}
+ test("Test slash separated date partitions written through the row writer") {
+ withSQLConf("hoodie.spark.sql.insert.into.operation" -> "bulk_insert") {
+ withTempDir { tmp =>
+ val targetTable = generateTableName
+ val tablePath = s"${tmp.getCanonicalPath}/$targetTable"
+
+ spark.sql(
+ s"""
+ |create table $targetTable (
+ | `id` string,
+ | `name` string,
+ | `ts` bigint,
+ | `datestr` STRING
+ |) using hudi
+ | tblproperties (
+ | 'primaryKey' = 'id',
+ | 'type' = 'COW',
+ | 'preCombineField'='ts',
+ | 'hoodie.datasource.write.slash.separated.date.partitioning'='true'
+ | )
+ | partitioned by (`datestr`)
+ | location '$tablePath'
+ """.stripMargin)
+
+ // NOTE: The row writer derives the partition path off of an [[InternalRow]], which used to
+ // blow up with a [[ClassCastException]]; a null partition value used to NPE
+ spark.sql(
+ s"""
+ | insert into $targetTable values
+ | (1, 'a1', 1000, "2026-01-05"),
+ | (2, 'a2', 2000, "2026-01-06"),
+ | (3, 'a3', 3000, null)
+ """.stripMargin)
+
+ checkAnswer(s"select id, name, ts, _hoodie_partition_path, datestr from $targetTable order by id")(
+ Seq("1", "a1", 1000, "2026/01/05", "2026-01-05"),
+ Seq("2", "a2", 2000, "2026/01/06", "2026-01-06"),
+ Seq("3", "a3", 3000, "__HIVE_DEFAULT_PARTITION__", null)
+ )
+
+ val metaClient = HoodieTableMetaClient.builder()
+ .setConf(HadoopFSUtils.getStorageConfWithCopy(spark.sparkContext.hadoopConfiguration))
+ .setBasePath(tablePath)
+ .build()
+ assertTrue(metaClient.getStorage.exists(new StoragePath(tablePath, "2026/01/05")),
+ s"Partition path 2026/01/05 should exist")
+ assertTrue(metaClient.getStorage.exists(new StoragePath(tablePath, "2026/01/06")),
+ s"Partition path 2026/01/06 should exist")
+ assertTrue(metaClient.getStorage.exists(new StoragePath(tablePath, "__HIVE_DEFAULT_PARTITION__")),
+ s"Partition path __HIVE_DEFAULT_PARTITION__ should exist")
Review Comment:
Applied, and pulled into a helper so every test in the file makes the assertion rather than just the two that already did -- `assertMetadataTablePartitions`, which asserts `HoodieBackedTableMetadata#getAllPartitionPaths` contains the expected directories.
All five original tests plus the two new ones now call it. Your point about `_hoodie_partition_path` plus `storage.exists` passing when the two disagree is recorded in the helper's scaladoc, so the next test to be added inherits the reason rather than just the call.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@hudi.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] fix(spark): make slash-separated date partitioning work on the row writer path [hudi]
Posted by "voonhous (via GitHub)" <gi...@apache.org>.
voonhous commented on PR #19648:
URL: https://github.com/apache/hudi/pull/19648#issuecomment-5394513162
Pushed a commit to this branch (maintainer edit) settling the multi-field question the last round left open.
Restoring the substitution in the multi-part branch fixed the `CustomKeyGenerator` prefix miss but opened a write-side hole: `ComplexKeyGenerator#getPartitionPath(InternalRow, StructType)` lands in that branch too, while `KeyGenUtils#getRecordPartitionPath` still guards on `size() == 1`. On a `(datestr, city)` slash table, `insert` writes `2026-01-05/san-francisco` and `bulk_insert` writes `2026/01/05/san/francisco` -- and one such directory makes `BaseHoodieTableFileIndex:476` throw for the whole table under the default lazy listing. On master that leg throws `ClassCastException`, so no table can reach the state; with this PR as it stood, the write commits cleanly and the failure surfaces whenever a read next lists partitions, possibly days later.
Rather than trade the CCE for a silent landmine, the commit pulls #19666's suggested fix into this PR and fails fast at the write:
* `HoodieWriterUtils#validateTableConfig` rejects slash partitioning with more than one partition field (covers `df.write` and SQL writes, new and existing tables)
* `HoodieCatalogTable#extraTableConfig` rejects it at `CREATE TABLE`, next to the existing hive-style check
* the multi-part substitution stays exactly as you restored it -- new writes can no longer reach it, and it keeps `composeRelativePartitionPath` naming the right directory for legacy tables
* the multi-field `CustomKeyGenerator` test becomes two rejection asserts (create and `df.write`); comments and javadoc reworded from "tracked in #19666" to the legacy-read framing
One behavior change a committer should sign off on: registering a legacy multi-field slash table via `CREATE TABLE ... location` now also fails, since that path runs `validateTableConfig` against the on-disk config. I kept it deliberately -- such tables already return silently wrong (zero) rows on any partition-filtered query, so a loud error at registration is protection; tables already registered keep reading, as no read path runs the validation. #19666 stays open for the read side of legacy layouts.
PR description updated to match. `TestSlashSeparatedPartitionValue` is green locally with the change.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@hudi.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] fix(spark): make slash-separated date partitioning work on the row writer path [hudi]
Posted by "SEPURI-SAI-KRISHNA (via GitHub)" <gi...@apache.org>.
SEPURI-SAI-KRISHNA commented on code in PR #19648:
URL: https://github.com/apache/hudi/pull/19648#discussion_r3815161090
##########
hudi-client/hudi-spark-client/src/test/java/org/apache/hudi/keygen/TestPartitionPathFormatter.java:
##########
@@ -0,0 +1,115 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.hudi.keygen;
+
+import org.apache.spark.unsafe.types.UTF8String;
+import org.junit.jupiter.params.ParameterizedTest;
+import org.junit.jupiter.params.provider.ValueSource;
+
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.List;
+
+import static org.apache.hudi.common.util.PartitionPathEncodeUtils.DEFAULT_PARTITION_PATH;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+
+/**
+ * Tests the partition-path formatters backing the key generators, making sure that both the
+ * {@link String} (Avro/{@link org.apache.spark.sql.Row} write path) and the {@link UTF8String}
+ * (row-writer/{@link org.apache.spark.sql.catalyst.InternalRow} write path) flavors produce
+ * identical partition paths.
+ */
+class TestPartitionPathFormatter {
+
+ private static final List<String> SINGLE_FIELD = Collections.singletonList("date_col");
+ private static final List<String> TWO_FIELDS = Arrays.asList("date_col", "city");
+
+ private String combine(boolean useRowWriterPath,
+ boolean hiveStylePartitioning,
+ boolean encode,
+ boolean slashSeparatedDatePartitioning,
+ List<String> fields,
+ Object... parts) {
+ if (useRowWriterPath) {
+ return new UTF8StringPartitionPathFormatter(
+ UTF8StringPartitionPathFormatter.UTF8StringBuilder::new, hiveStylePartitioning, encode,
+ slashSeparatedDatePartitioning).combine(fields, parts).toString();
+ }
+ return new StringPartitionPathFormatter(
+ StringPartitionPathFormatter.JavaStringBuilder::new, hiveStylePartitioning, encode,
+ slashSeparatedDatePartitioning).combine(fields, parts);
+ }
+
+ @ParameterizedTest
+ @ValueSource(booleans = {true, false})
+ void testSlashSeparatedDatePartitioningSingleField(boolean useRowWriterPath) {
+ assertEquals("2026/01/05",
+ combine(useRowWriterPath, false, false, true, SINGLE_FIELD, "2026-01-05"));
+ // Input that is already slash-separated is left untouched
+ assertEquals("2026/01/05",
+ combine(useRowWriterPath, false, false, true, SINGLE_FIELD, "2026/01/05"));
+ }
+
+ @ParameterizedTest
+ @ValueSource(booleans = {true, false})
+ void testSlashSeparatedDatePartitioningOnlyAppliesToSingleFieldPartitioning(boolean useRowWriterPath) {
+ // NOTE: This mirrors [[KeyGenUtils#getRecordPartitionPath]] driving the Avro write-path
+ assertEquals("2026-01-05/san-francisco",
+ combine(useRowWriterPath, false, false, true, TWO_FIELDS, "2026-01-05", "san-francisco"));
+ }
+
+ @ParameterizedTest
+ @ValueSource(booleans = {true, false})
+ void testSlashSeparatedDatePartitioningHandlesNullAndEmptyValues(boolean useRowWriterPath) {
+ assertEquals(DEFAULT_PARTITION_PATH,
+ combine(useRowWriterPath, false, false, true, SINGLE_FIELD, new Object[] {null}));
+ assertEquals(DEFAULT_PARTITION_PATH,
+ combine(useRowWriterPath, false, false, true, SINGLE_FIELD, ""));
+ }
+
+ @ParameterizedTest
+ @ValueSource(booleans = {true, false})
+ void testSlashSeparatedDatePartitioningEncodesValues(boolean useRowWriterPath) {
+ // '?' has to be escaped, while the date separators are turned into directory separators
+ assertEquals("2026/01/05", combine(useRowWriterPath, false, true, true, SINGLE_FIELD, "2026-01-05"));
+ assertEquals("a%3Fb", combine(useRowWriterPath, false, true, true, SINGLE_FIELD, "a?b"));
+ }
+
+ @ParameterizedTest
+ @ValueSource(booleans = {true, false})
+ void testHiveStylePartitioningTakesPrecedence(boolean useRowWriterPath) {
+ // NOTE: Hive-style partitioning and slash-separated date partitioning are mutually exclusive --
+ // [[HoodieCatalogTable#extraTableConfig]] rejects a table configuring both -- so this
+ // combination is unreachable and the formatter deliberately leaves the value alone.
+ // This asserts the pre-existing behavior stays put, it is not a statement about what the
+ // combination *should* produce
+ assertEquals("date_col=2026-01-05",
+ combine(useRowWriterPath, true, false, true, SINGLE_FIELD, "2026-01-05"));
+ }
+
+ @ParameterizedTest
+ @ValueSource(booleans = {true, false})
+ void testPlainPartitioningIsUnaffected(boolean useRowWriterPath) {
Review Comment:
Deleted.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@hudi.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] fix(spark): make slash-separated date partitioning work on the row writer path [hudi]
Posted by "SEPURI-SAI-KRISHNA (via GitHub)" <gi...@apache.org>.
SEPURI-SAI-KRISHNA commented on code in PR #19648:
URL: https://github.com/apache/hudi/pull/19648#discussion_r3815133707
##########
hudi-spark-datasource/hudi-spark/src/test/scala/org/apache/spark/sql/hudi/common/TestSlashSeparatedPartitionValue.scala:
##########
@@ -90,6 +90,61 @@ class TestSlashSeparatedPartitionValue extends HoodieSparkSqlTestBase {
}
}
+ test("Test slash separated date partitions written through the row writer") {
+ withSQLConf("hoodie.sql.bulk.insert.enable" -> "true", "hoodie.sql.insert.mode" -> "non-strict",
+ "hoodie.datasource.write.row.writer.enable" -> "true") {
+ withTempDir { tmp =>
+ val targetTable = generateTableName
+ val tablePath = s"${tmp.getCanonicalPath}/$targetTable"
+
+ spark.sql(
+ s"""
+ |create table $targetTable (
+ | `id` string,
+ | `name` string,
+ | `ts` bigint,
+ | `datestr` STRING
Review Comment:
DATE case added, parameterized over insert and bulk_insert, asserting both the directory on disk and that datestr reads back as date'2026-01-05'.
Worth noting why it needed the rebase: on the previous base the DATE case failed at read time with
ClassCastException: UTF8String cannot be cast to Integer
at ColumnVectorUtils.populate / VectorizedParquetRecordReader.initBatch
because castStringToType returned UTF8String for DateType while Catalyst wants an Int. That is exactly what #19652 fixed, and this branch predated it. Rebased onto master, the case passes -- so it now guards the write-side formatting from this PR and the read-side typing from #19652 together.
For TIMESTAMP I have filed a follow-up rather than widening this PR: the slash arm in SqlKeyGenerator sits ahead of the TimestampType normalization and shadows it, so the Avro path writes raw micros while the row writer writes the normalized rendering. Filed as #19667.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@hudi.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] fix(spark): make slash-separated date partitioning work on the row writer path [hudi]
Posted by "SEPURI-SAI-KRISHNA (via GitHub)" <gi...@apache.org>.
SEPURI-SAI-KRISHNA commented on code in PR #19648:
URL: https://github.com/apache/hudi/pull/19648#discussion_r3815146475
##########
hudi-spark-datasource/hudi-spark/src/test/scala/org/apache/spark/sql/hudi/common/TestSlashSeparatedPartitionValue.scala:
##########
@@ -90,6 +90,61 @@ class TestSlashSeparatedPartitionValue extends HoodieSparkSqlTestBase {
}
}
+ test("Test slash separated date partitions written through the row writer") {
+ withSQLConf("hoodie.sql.bulk.insert.enable" -> "true", "hoodie.sql.insert.mode" -> "non-strict",
+ "hoodie.datasource.write.row.writer.enable" -> "true") {
+ withTempDir { tmp =>
+ val targetTable = generateTableName
+ val tablePath = s"${tmp.getCanonicalPath}/$targetTable"
+
+ spark.sql(
+ s"""
+ |create table $targetTable (
+ | `id` string,
+ | `name` string,
+ | `ts` bigint,
+ | `datestr` STRING
+ |) using hudi
+ | tblproperties (
+ | 'primaryKey' = 'id',
+ | 'type' = 'COW',
+ | 'preCombineField'='ts',
+ | 'hoodie.datasource.write.slash.separated.date.partitioning'='true'
+ | )
+ | partitioned by (`datestr`)
+ | location '$tablePath'
+ """.stripMargin)
+
+ // NOTE: The row writer derives the partition path off of an [[InternalRow]], which used to
+ // blow up with a [[ClassCastException]]; a null partition value used to NPE
+ spark.sql(
+ s"""
+ | insert into $targetTable values
+ | (1, 'a1', 1000, "2026-01-05"),
+ | (2, 'a2', 2000, "2026-01-06"),
+ | (3, 'a3', 3000, null)
+ """.stripMargin)
+
+ checkAnswer(s"select id, name, ts, _hoodie_partition_path from $targetTable order by id")(
+ Seq("1", "a1", 1000, "2026/01/05"),
+ Seq("2", "a2", 2000, "2026/01/06"),
+ Seq("3", "a3", 3000, "__HIVE_DEFAULT_PARTITION__")
Review Comment:
Applied, datestr is projected and the null row is asserted.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@hudi.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] fix(spark): make slash-separated date partitioning work on the row writer path [hudi]
Posted by "SEPURI-SAI-KRISHNA (via GitHub)" <gi...@apache.org>.
SEPURI-SAI-KRISHNA commented on code in PR #19648:
URL: https://github.com/apache/hudi/pull/19648#discussion_r3815137650
##########
hudi-client/hudi-spark-client/src/main/java/org/apache/hudi/keygen/PartitionPathFormatterBase.java:
##########
@@ -75,15 +75,11 @@ public final S combine(List<String> partitionPathFields, Object... partitionPath
if (useHiveStylePartitioning) {
sb.appendJava(partitionPathFields.get(i))
- .appendJava("=")
- .append(partitionPathPartStr);
- } else if (slashSeparatedDatePartitioning) {
- String res = ((String) partitionPathPartStr).replace('-', '/');
- sb.append(((S) res));
- } else {
- sb.append(partitionPathPartStr);
+ .appendJava("=");
}
+ sb.append(partitionPathPartStr);
Review Comment:
Agreed on both points.
The PR description no longer claims a write-path behavior change: the multi-field branch lands in file-index prefix pruning (SparkHoodieTableFileIndex#composeRelativePartitionPath) and in bucket routing via RowRecordKeyExtractor, not in any path that names a directory, and no existing table layout changes.
For the validation I have filed #19666 rather than widening this PR -- it covers rejecting slash-separated date partitioning with more than one partition field at table creation and in writer config validation. ShowHoodieTablePartitionsCommand.scala:60-61 already checkStates that same invariant, so one path treats single-field as a hard requirement while table creation accepts any number of fields.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@hudi.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] fix(spark): make slash-separated date partitioning work on the row writer path [hudi]
Posted by "SEPURI-SAI-KRISHNA (via GitHub)" <gi...@apache.org>.
SEPURI-SAI-KRISHNA commented on code in PR #19648:
URL: https://github.com/apache/hudi/pull/19648#discussion_r3815142276
##########
hudi-client/hudi-spark-client/src/main/java/org/apache/hudi/keygen/PartitionPathFormatterBase.java:
##########
@@ -75,15 +75,11 @@ public final S combine(List<String> partitionPathFields, Object... partitionPath
if (useHiveStylePartitioning) {
Review Comment:
You are right, and the comment is corrected, the "unreachable" claim is gone. It now says the combination is documented as mutually exclusive but only enforced by HoodieCatalogTable#extraTableConfig on the SQL options, so df.write and HoodieStreamer still accept it, and records why the formatter does not mirror the Avro path (doParsePartitionColumnValues cannot read that layout back). Test kept with the corrected comment.
One supporting detail for the all-write-paths check: the config documentation of SLASH_SEPARATED_DATE_PARTITIONING already ends with "Cannot be used together with hive-style partitioning", so adding the check to HoodieWriterUtils.validateTableConfig honors a documented contract rather than adding a restriction. Filed as #19669.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@hudi.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] fix(spark): make slash-separated date partitioning work on the row writer path [hudi]
Posted by "hudi-bot (via GitHub)" <gi...@apache.org>.
hudi-bot commented on PR #19648:
URL: https://github.com/apache/hudi/pull/19648#issuecomment-5345223715
<!--
Meta data
{
"version" : 1,
"metaDataEntries" : [ {
"hash" : "ce3ab56d080092972df722ab619a3cf71308b6c2",
"status" : "FAILURE",
"url" : "https://dev.azure.com/apachehudi/a1a51da7-8592-47d4-88dc-fd67bed336bb/_build/results?buildId=16342",
"triggerID" : "ce3ab56d080092972df722ab619a3cf71308b6c2",
"triggerType" : "PUSH"
}, {
"hash" : "8d523937035c816ddf765ac61acad162e311b738",
"status" : "PENDING",
"url" : "https://dev.azure.com/apachehudi/a1a51da7-8592-47d4-88dc-fd67bed336bb/_build/results?buildId=16390",
"triggerID" : "8d523937035c816ddf765ac61acad162e311b738",
"triggerType" : "PUSH"
} ]
}-->
## CI report:
* ce3ab56d080092972df722ab619a3cf71308b6c2 Azure: [FAILURE](https://dev.azure.com/apachehudi/a1a51da7-8592-47d4-88dc-fd67bed336bb/_build/results?buildId=16342)
* 8d523937035c816ddf765ac61acad162e311b738 Azure: [PENDING](https://dev.azure.com/apachehudi/a1a51da7-8592-47d4-88dc-fd67bed336bb/_build/results?buildId=16390)
<details>
<summary>Bot commands</summary>
@hudi-bot supports the following commands:
- `@hudi-bot run azure` re-run the last Azure build
</details>
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@hudi.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] fix(spark): make slash-separated date partitioning work on the row writer path [hudi]
Posted by "SEPURI-SAI-KRISHNA (via GitHub)" <gi...@apache.org>.
SEPURI-SAI-KRISHNA commented on code in PR #19648:
URL: https://github.com/apache/hudi/pull/19648#discussion_r3820480113
##########
hudi-client/hudi-spark-client/src/main/java/org/apache/hudi/keygen/PartitionPathFormatterBase.java:
##########
@@ -62,11 +62,17 @@ public final S combine(List<String> partitionPathFields, Object... partitionPath
// Avoid creating [[StringBuilder]] in case there's just one partition-path part,
// and Hive-style of partitioning is not required
if (!useHiveStylePartitioning && partitionPathParts.length == 1) {
- if (slashSeparatedDatePartitioning) {
- return ((S) ((String) toString(partitionPathParts[0])).replace('-', '/'));
- } else {
- return tryEncode(handleEmpty(toString(partitionPathParts[0])));
- }
+ S partitionPathPart = tryEncode(handleEmpty(toString(partitionPathParts[0])));
+ // NOTE: For [[SimpleKeyGenerator]]/[[ComplexKeyGenerator]] slash-separated date partitioning
+ // only kicks in for a table partitioned by a single (date) column, mirroring
+ // [[KeyGenUtils#getPartitionPath]] (single field) and [[KeyGenUtils#getRecordPartitionPath]]
+ // (which guards on a single field as well) driving the Avro write-path: both write-paths
+ // have to derive the very same partition path for a record.
+ // [[CustomKeyGenerator]] is not an exception to this: it builds one single-field
+ // sub-key-generator per partition field, so every field takes this branch and a
+ // multi-field table does get each of its values slash-separated -- on the Avro,
+ // [[org.apache.spark.sql.Row]] and [[org.apache.spark.sql.catalyst.InternalRow]] paths alike
+ return slashSeparatedDatePartitioning ? replaceDashesWithSlashes(partitionPathPart) : partitionPathPart;
Review Comment:
Confirmed and fixed in this PR. I probed the resolution directly rather than reading it off, and it's slightly worse than described — the base path isn't just chopped, it's replaced:
```
value partitionPath FSUtils(String, String) FSUtils(StoragePath, String)
"-5" "/5" /tmp/mytable/5 /5
"--5" "//5" /5 (empty)
"-" "/" /tmp/mytable /tmp/mytable
"5-" "5/" /tmp/mytable/5 /tmp/mytable/5
```
So `-5` puts the writer in `<base>/5` and the file-system view in `/5`, `-` collapses the partition onto the table root, and `--5` resolves to nothing at all. Only a *leading* dash does this; an interior one (`a--b` → `a//b`) URI-normalizes back to `a/b` harmlessly, and a trailing one is fine. Encoding doesn't help — `escapePathName` leaves dashes alone.
Fixed by suppressing the substitution when the value starts with a dash, in all three write paths:
* `PartitionPathFormatterBase#combine`, via a new `startsWithDash` abstract implemented by both formatters, so the rule lives in one place rather than being duplicated per string representation
* `KeyGenUtils#getPartitionPath` and `#getRecordPartitionPath`, via a shared private `slashSeparateDateValue` helper
I went with the leading-dash guard rather than restricting the substitution to `yyyy-MM-dd`. Matching the date format is closer to the config's intent, but it silently changes the layout for anyone currently partitioning on a dashed non-date value — `2026-01` writes `2026/01` today and would start writing `2026-01` — which orphans existing partitions on a path that has shipped for several releases. The leading-dash guard only changes values whose current output is already broken and unreadable, so nothing that works today moves. Happy to switch to the stricter check if you'd rather take that compat hit now.
Tests: `TestPartitionPathFormatter#testSlashSeparatedDatePartitioningLeavesLeadingDashesAlone` pins `-5`, `-`, `--5` alongside `5-` and `2026-01-05` across both formatters, and `TestSimpleKeyGenerator#testSlashSeparatedDatePartitioningLeavesLeadingDashesAlone` covers the Avro path. Both fail without their respective guard (`expected: <-5> but was: </5>`).
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@hudi.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] fix(spark): make slash-separated date partitioning work on the row writer path [hudi]
Posted by "hudi-bot (via GitHub)" <gi...@apache.org>.
hudi-bot commented on PR #19648:
URL: https://github.com/apache/hudi/pull/19648#issuecomment-5381030419
<!--
Meta data
{
"version" : 1,
"metaDataEntries" : [ {
"hash" : "ce3ab56d080092972df722ab619a3cf71308b6c2",
"status" : "DELETED",
"url" : "https://dev.azure.com/apachehudi/a1a51da7-8592-47d4-88dc-fd67bed336bb/_build/results?buildId=16342",
"triggerID" : "ce3ab56d080092972df722ab619a3cf71308b6c2",
"triggerType" : "PUSH"
}, {
"hash" : "8d523937035c816ddf765ac61acad162e311b738",
"status" : "DELETED",
"url" : "https://dev.azure.com/apachehudi/a1a51da7-8592-47d4-88dc-fd67bed336bb/_build/results?buildId=16390",
"triggerID" : "8d523937035c816ddf765ac61acad162e311b738",
"triggerType" : "PUSH"
}, {
"hash" : "fdd04bfbf709f806768ae4b4b259a679b08e2aa4",
"status" : "DELETED",
"url" : "https://dev.azure.com/apachehudi/a1a51da7-8592-47d4-88dc-fd67bed336bb/_build/results?buildId=16413",
"triggerID" : "fdd04bfbf709f806768ae4b4b259a679b08e2aa4",
"triggerType" : "PUSH"
}, {
"hash" : "8f1cb373283c41cf6513e83b169e692902c91c4e",
"status" : "DELETED",
"url" : "https://dev.azure.com/apachehudi/a1a51da7-8592-47d4-88dc-fd67bed336bb/_build/results?buildId=16440",
"triggerID" : "8f1cb373283c41cf6513e83b169e692902c91c4e",
"triggerType" : "PUSH"
}, {
"hash" : "8ce9ad0a09e3fc8a889eefab03abc38f6a1e8aa5",
"status" : "SUCCESS",
"url" : "https://dev.azure.com/apachehudi/a1a51da7-8592-47d4-88dc-fd67bed336bb/_build/results?buildId=16477",
"triggerID" : "8ce9ad0a09e3fc8a889eefab03abc38f6a1e8aa5",
"triggerType" : "PUSH"
}, {
"hash" : "2d738376d122aa8b60243bd99f216f5b8b3fa217",
"status" : "PENDING",
"url" : "https://dev.azure.com/apachehudi/a1a51da7-8592-47d4-88dc-fd67bed336bb/_build/results?buildId=16484",
"triggerID" : "2d738376d122aa8b60243bd99f216f5b8b3fa217",
"triggerType" : "PUSH"
} ]
}-->
## CI report:
* 8ce9ad0a09e3fc8a889eefab03abc38f6a1e8aa5 Azure: [SUCCESS](https://dev.azure.com/apachehudi/a1a51da7-8592-47d4-88dc-fd67bed336bb/_build/results?buildId=16477)
* 2d738376d122aa8b60243bd99f216f5b8b3fa217 Azure: [PENDING](https://dev.azure.com/apachehudi/a1a51da7-8592-47d4-88dc-fd67bed336bb/_build/results?buildId=16484)
<details>
<summary>Bot commands</summary>
@hudi-bot supports the following commands:
- `@hudi-bot run azure` re-run the last Azure build
</details>
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@hudi.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] fix(spark): make slash-separated date partitioning work on the row writer path [hudi]
Posted by "hudi-bot (via GitHub)" <gi...@apache.org>.
hudi-bot commented on PR #19648:
URL: https://github.com/apache/hudi/pull/19648#issuecomment-5395285161
<!--
Meta data
{
"version" : 1,
"metaDataEntries" : [ {
"hash" : "ce3ab56d080092972df722ab619a3cf71308b6c2",
"status" : "DELETED",
"url" : "https://dev.azure.com/apachehudi/a1a51da7-8592-47d4-88dc-fd67bed336bb/_build/results?buildId=16342",
"triggerID" : "ce3ab56d080092972df722ab619a3cf71308b6c2",
"triggerType" : "PUSH"
}, {
"hash" : "8d523937035c816ddf765ac61acad162e311b738",
"status" : "DELETED",
"url" : "https://dev.azure.com/apachehudi/a1a51da7-8592-47d4-88dc-fd67bed336bb/_build/results?buildId=16390",
"triggerID" : "8d523937035c816ddf765ac61acad162e311b738",
"triggerType" : "PUSH"
}, {
"hash" : "fdd04bfbf709f806768ae4b4b259a679b08e2aa4",
"status" : "DELETED",
"url" : "https://dev.azure.com/apachehudi/a1a51da7-8592-47d4-88dc-fd67bed336bb/_build/results?buildId=16413",
"triggerID" : "fdd04bfbf709f806768ae4b4b259a679b08e2aa4",
"triggerType" : "PUSH"
}, {
"hash" : "8f1cb373283c41cf6513e83b169e692902c91c4e",
"status" : "DELETED",
"url" : "https://dev.azure.com/apachehudi/a1a51da7-8592-47d4-88dc-fd67bed336bb/_build/results?buildId=16440",
"triggerID" : "8f1cb373283c41cf6513e83b169e692902c91c4e",
"triggerType" : "PUSH"
}, {
"hash" : "8ce9ad0a09e3fc8a889eefab03abc38f6a1e8aa5",
"status" : "DELETED",
"url" : "https://dev.azure.com/apachehudi/a1a51da7-8592-47d4-88dc-fd67bed336bb/_build/results?buildId=16477",
"triggerID" : "8ce9ad0a09e3fc8a889eefab03abc38f6a1e8aa5",
"triggerType" : "PUSH"
}, {
"hash" : "2d738376d122aa8b60243bd99f216f5b8b3fa217",
"status" : "SUCCESS",
"url" : "https://dev.azure.com/apachehudi/a1a51da7-8592-47d4-88dc-fd67bed336bb/_build/results?buildId=16484",
"triggerID" : "2d738376d122aa8b60243bd99f216f5b8b3fa217",
"triggerType" : "PUSH"
}, {
"hash" : "493712b3d69c542864eebf43d0c090276c55bfc6",
"status" : "PENDING",
"url" : "https://dev.azure.com/apachehudi/a1a51da7-8592-47d4-88dc-fd67bed336bb/_build/results?buildId=16505",
"triggerID" : "493712b3d69c542864eebf43d0c090276c55bfc6",
"triggerType" : "PUSH"
}, {
"hash" : "073f3ca3e82c84c1be52833f0b7078b8ecec3614",
"status" : "UNKNOWN",
"url" : "TBD",
"triggerID" : "073f3ca3e82c84c1be52833f0b7078b8ecec3614",
"triggerType" : "PUSH"
}, {
"hash" : "8cd021a924d18b1f761beb318d23dca5550d6eb8",
"status" : "PENDING",
"url" : "https://dev.azure.com/apachehudi/a1a51da7-8592-47d4-88dc-fd67bed336bb/_build/results?buildId=16506",
"triggerID" : "8cd021a924d18b1f761beb318d23dca5550d6eb8",
"triggerType" : "PUSH"
} ]
}-->
## CI report:
* 2d738376d122aa8b60243bd99f216f5b8b3fa217 Azure: [SUCCESS](https://dev.azure.com/apachehudi/a1a51da7-8592-47d4-88dc-fd67bed336bb/_build/results?buildId=16484)
* 493712b3d69c542864eebf43d0c090276c55bfc6 Azure: [PENDING](https://dev.azure.com/apachehudi/a1a51da7-8592-47d4-88dc-fd67bed336bb/_build/results?buildId=16505)
* 073f3ca3e82c84c1be52833f0b7078b8ecec3614 UNKNOWN
* 8cd021a924d18b1f761beb318d23dca5550d6eb8 Azure: [PENDING](https://dev.azure.com/apachehudi/a1a51da7-8592-47d4-88dc-fd67bed336bb/_build/results?buildId=16506)
<details>
<summary>Bot commands</summary>
@hudi-bot supports the following commands:
- `@hudi-bot run azure` re-run the last Azure build
</details>
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@hudi.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] fix(spark): make slash-separated date partitioning work on the row writer path [hudi]
Posted by "hudi-bot (via GitHub)" <gi...@apache.org>.
hudi-bot commented on PR #19648:
URL: https://github.com/apache/hudi/pull/19648#issuecomment-5315409562
<!--
Meta data
{
"version" : 1,
"metaDataEntries" : [ {
"hash" : "bca4b97c14ab1bda65aeb7f3b8466a4fe60b6684",
"status" : "PENDING",
"url" : "https://dev.azure.com/apachehudi/a1a51da7-8592-47d4-88dc-fd67bed336bb/_build/results?buildId=16339",
"triggerID" : "bca4b97c14ab1bda65aeb7f3b8466a4fe60b6684",
"triggerType" : "PUSH"
} ]
}-->
## CI report:
* bca4b97c14ab1bda65aeb7f3b8466a4fe60b6684 Azure: [PENDING](https://dev.azure.com/apachehudi/a1a51da7-8592-47d4-88dc-fd67bed336bb/_build/results?buildId=16339)
<details>
<summary>Bot commands</summary>
@hudi-bot supports the following commands:
- `@hudi-bot run azure` re-run the last Azure build
</details>
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@hudi.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] fix(spark): make slash-separated date partitioning work on the row writer path [hudi]
Posted by "SEPURI-SAI-KRISHNA (via GitHub)" <gi...@apache.org>.
SEPURI-SAI-KRISHNA commented on code in PR #19648:
URL: https://github.com/apache/hudi/pull/19648#discussion_r3836422893
##########
hudi-client/hudi-spark-client/src/main/java/org/apache/hudi/keygen/StringPartitionPathFormatter.java:
##########
@@ -56,6 +56,16 @@ protected String handleEmpty(String partitionPathPart) {
}
}
+ @Override
+ protected String replaceDashesWithSlashes(String partitionPathPart) {
+ return partitionPathPart.replace('-', '/');
+ }
+
+ @Override
+ protected boolean startsWithDash(String partitionPathPart) {
+ return !partitionPathPart.isEmpty() && partitionPathPart.charAt(0) == '-';
Review Comment:
Done, though by a different route than suggested. The check moved to `KeyGenUtils#hasPathBreakingDash` so that the Avro write path and both formatters share one definition, and it now covers trailing and doubled dashes as well as leading ones -- all three produce a partition path that does not survive the round trip back from storage.
`StringPartitionPathFormatter` delegates to it, so the `charAt(0) == '-'` form you flagged is gone.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@hudi.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] fix(spark): make slash-separated date partitioning work on the row writer path [hudi]
Posted by "hudi-bot (via GitHub)" <gi...@apache.org>.
hudi-bot commented on PR #19648:
URL: https://github.com/apache/hudi/pull/19648#issuecomment-5315352295
<!--
Meta data
{
"version" : 1,
"metaDataEntries" : [ {
"hash" : "bca4b97c14ab1bda65aeb7f3b8466a4fe60b6684",
"status" : "UNKNOWN",
"url" : "TBD",
"triggerID" : "bca4b97c14ab1bda65aeb7f3b8466a4fe60b6684",
"triggerType" : "PUSH"
} ]
}-->
## CI report:
* bca4b97c14ab1bda65aeb7f3b8466a4fe60b6684 UNKNOWN
<details>
<summary>Bot commands</summary>
@hudi-bot supports the following commands:
- `@hudi-bot run azure` re-run the last Azure build
</details>
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@hudi.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] fix(spark): make slash-separated date partitioning work on the row writer path [hudi]
Posted by "SEPURI-SAI-KRISHNA (via GitHub)" <gi...@apache.org>.
SEPURI-SAI-KRISHNA commented on PR #19648:
URL: https://github.com/apache/hudi/pull/19648#issuecomment-5350970837
Azure build 16390 is red on one unrelated test: `TestValidateHoodieSyncProcedure` > "Test Call sync_validate record-count modes fail fast on an unreachable HiveServer2" (`TestValidateHoodieSyncProcedure.scala:250`). It asserts a `SQLException` in the cause chain and got a `NoClassDefFoundError` instead, in a run where the agent logged "Free memory is lower than 5%; Currently used: 96.35%" three times — the Hive JDBC driver class failing to load under memory pressure rather than the connection failing as the test expects.
Everything else in that phase passed (527 succeeded, 1 failed), including all four `TestSlashSeparatedPartitionValue` cases this PR adds, and all 22 GitHub Actions checks are green. This PR touches only `hudi-spark-client` keygen classes and their tests — nothing in Hive sync, JDBC, or the procedures.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@hudi.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] fix(spark): make slash-separated date partitioning work on the row writer path [hudi]
Posted by "SEPURI-SAI-KRISHNA (via GitHub)" <gi...@apache.org>.
SEPURI-SAI-KRISHNA commented on code in PR #19648:
URL: https://github.com/apache/hudi/pull/19648#discussion_r3820472332
##########
hudi-client/hudi-spark-client/src/main/java/org/apache/hudi/keygen/PartitionPathFormatterBase.java:
##########
@@ -62,11 +62,11 @@ public final S combine(List<String> partitionPathFields, Object... partitionPath
// Avoid creating [[StringBuilder]] in case there's just one partition-path part,
// and Hive-style of partitioning is not required
if (!useHiveStylePartitioning && partitionPathParts.length == 1) {
- if (slashSeparatedDatePartitioning) {
- return ((S) ((String) toString(partitionPathParts[0])).replace('-', '/'));
- } else {
- return tryEncode(handleEmpty(toString(partitionPathParts[0])));
- }
+ S partitionPathPart = tryEncode(handleEmpty(toString(partitionPathParts[0])));
+ // NOTE: Slash-separated date partitioning only kicks in for a table partitioned by a single
Review Comment:
You're right, and "all three write paths agree" was doing misleading work in that NOTE — agreement isn't usefulness when the agreed-on layout can't be read back. Reworded the last sentence:
```java
// [[org.apache.spark.sql.Row]] and [[org.apache.spark.sql.catalyst.InternalRow]] paths alike.
// All three agreeing does not make that layout usable, though: the extra fragments leave
// [[HoodieSparkUtils#doParsePartitionColumnValues]] unable to line the path up with the
// partition columns, so reading such a table back fails. Tracked in HUDI issue #19666
```
I've also widened #19666 to cover `CustomKeyGenerator` as its own failure mode. Worth separating the two, since they fail differently: `SimpleKeyGenerator`/`ComplexKeyGenerator` give a silent empty result on a prefix-pruned query, while `CustomKeyGenerator` throws outright — I confirmed the length check in `BaseHoodieTableFileIndex#getPartitionColumnValues` is guarded on `shouldListLazily`, which is the default, so it's a hard `HoodieException` on every read rather than wrong rows.
Agreed a partition-field-count check at table creation catches it: the count is a table-level property and doesn't depend on how the key generator decomposes it into sub-key-generators. Noted that in the issue's suggested fix.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@hudi.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] fix(spark): make slash-separated date partitioning work on the row writer path [hudi]
Posted by "voonhous (via GitHub)" <gi...@apache.org>.
voonhous commented on PR #19648:
URL: https://github.com/apache/hudi/pull/19648#issuecomment-5395167084
For the record, three more maintainer commits since the one above, from a final committer-grade pass:
* `3c3aa7f0` -- unit test for the rejection firing off the table config alone (an existing multi-field table, which no new table can reach).
* `073f3ca3` -- the dash guard missed dot segments: `..-a` became `../a` and resolved outside the table base path. Now one token rule (reject any `-`-delimited token that is empty, `.` or `..`), mirrored byte-wise in the UTF8 formatter. Rejection message says "recreate", since `ALTER TABLE SET TBLPROPERTIES` never rewrites `hoodie.properties`.
* `8cd021a9` -- `parseBoolean`-style flag read, Overwrite-mode and Avro encode-parity tests, comment corrections, test polish.
All verified locally on spark3.5. #19666 stays open for the legacy read side.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@hudi.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] fix(spark): make slash-separated date partitioning work on the row writer path [hudi]
Posted by "hudi-bot (via GitHub)" <gi...@apache.org>.
hudi-bot commented on PR #19648:
URL: https://github.com/apache/hudi/pull/19648#issuecomment-5396446504
<!--
Meta data
{
"version" : 1,
"metaDataEntries" : [ {
"hash" : "ce3ab56d080092972df722ab619a3cf71308b6c2",
"status" : "DELETED",
"url" : "https://dev.azure.com/apachehudi/a1a51da7-8592-47d4-88dc-fd67bed336bb/_build/results?buildId=16342",
"triggerID" : "ce3ab56d080092972df722ab619a3cf71308b6c2",
"triggerType" : "PUSH"
}, {
"hash" : "8d523937035c816ddf765ac61acad162e311b738",
"status" : "DELETED",
"url" : "https://dev.azure.com/apachehudi/a1a51da7-8592-47d4-88dc-fd67bed336bb/_build/results?buildId=16390",
"triggerID" : "8d523937035c816ddf765ac61acad162e311b738",
"triggerType" : "PUSH"
}, {
"hash" : "fdd04bfbf709f806768ae4b4b259a679b08e2aa4",
"status" : "DELETED",
"url" : "https://dev.azure.com/apachehudi/a1a51da7-8592-47d4-88dc-fd67bed336bb/_build/results?buildId=16413",
"triggerID" : "fdd04bfbf709f806768ae4b4b259a679b08e2aa4",
"triggerType" : "PUSH"
}, {
"hash" : "8f1cb373283c41cf6513e83b169e692902c91c4e",
"status" : "DELETED",
"url" : "https://dev.azure.com/apachehudi/a1a51da7-8592-47d4-88dc-fd67bed336bb/_build/results?buildId=16440",
"triggerID" : "8f1cb373283c41cf6513e83b169e692902c91c4e",
"triggerType" : "PUSH"
}, {
"hash" : "8ce9ad0a09e3fc8a889eefab03abc38f6a1e8aa5",
"status" : "DELETED",
"url" : "https://dev.azure.com/apachehudi/a1a51da7-8592-47d4-88dc-fd67bed336bb/_build/results?buildId=16477",
"triggerID" : "8ce9ad0a09e3fc8a889eefab03abc38f6a1e8aa5",
"triggerType" : "PUSH"
}, {
"hash" : "2d738376d122aa8b60243bd99f216f5b8b3fa217",
"status" : "DELETED",
"url" : "https://dev.azure.com/apachehudi/a1a51da7-8592-47d4-88dc-fd67bed336bb/_build/results?buildId=16484",
"triggerID" : "2d738376d122aa8b60243bd99f216f5b8b3fa217",
"triggerType" : "PUSH"
}, {
"hash" : "493712b3d69c542864eebf43d0c090276c55bfc6",
"status" : "DELETED",
"url" : "https://dev.azure.com/apachehudi/a1a51da7-8592-47d4-88dc-fd67bed336bb/_build/results?buildId=16505",
"triggerID" : "493712b3d69c542864eebf43d0c090276c55bfc6",
"triggerType" : "PUSH"
}, {
"hash" : "073f3ca3e82c84c1be52833f0b7078b8ecec3614",
"status" : "UNKNOWN",
"url" : "TBD",
"triggerID" : "073f3ca3e82c84c1be52833f0b7078b8ecec3614",
"triggerType" : "PUSH"
}, {
"hash" : "8cd021a924d18b1f761beb318d23dca5550d6eb8",
"status" : "SUCCESS",
"url" : "https://dev.azure.com/apachehudi/a1a51da7-8592-47d4-88dc-fd67bed336bb/_build/results?buildId=16506",
"triggerID" : "8cd021a924d18b1f761beb318d23dca5550d6eb8",
"triggerType" : "PUSH"
} ]
}-->
## CI report:
* 073f3ca3e82c84c1be52833f0b7078b8ecec3614 UNKNOWN
* 8cd021a924d18b1f761beb318d23dca5550d6eb8 Azure: [SUCCESS](https://dev.azure.com/apachehudi/a1a51da7-8592-47d4-88dc-fd67bed336bb/_build/results?buildId=16506)
<details>
<summary>Bot commands</summary>
@hudi-bot supports the following commands:
- `@hudi-bot run azure` re-run the last Azure build
</details>
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@hudi.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] fix(spark): make slash-separated date partitioning work on the row writer path [hudi]
Posted by "hudi-agent (via GitHub)" <gi...@apache.org>.
hudi-agent commented on code in PR #19648:
URL: https://github.com/apache/hudi/pull/19648#discussion_r3822434720
##########
hudi-client/hudi-spark-client/src/main/java/org/apache/hudi/keygen/PartitionPathFormatterBase.java:
##########
@@ -62,11 +62,28 @@ public final S combine(List<String> partitionPathFields, Object... partitionPath
// Avoid creating [[StringBuilder]] in case there's just one partition-path part,
// and Hive-style of partitioning is not required
if (!useHiveStylePartitioning && partitionPathParts.length == 1) {
- if (slashSeparatedDatePartitioning) {
- return ((S) ((String) toString(partitionPathParts[0])).replace('-', '/'));
- } else {
- return tryEncode(handleEmpty(toString(partitionPathParts[0])));
- }
+ S partitionPathPart = tryEncode(handleEmpty(toString(partitionPathParts[0])));
+ // NOTE: For [[SimpleKeyGenerator]]/[[ComplexKeyGenerator]] slash-separated date partitioning
Review Comment:
🤖 nit: this ~20-line NOTE block inline in the hot `combine()` path is a lot to read past. Could you move the rationale (the leading-dash / cross-generator explanation) into the javadoc of `replaceDashesWithSlashes`/`startsWithDash` and leave just a one-line pointer here?
<sub><i>⚠️ AI-generated; verify before applying. React 👍/👎 to flag quality.</i></sub>
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@hudi.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] fix(spark): make slash-separated date partitioning work on the row writer path [hudi]
Posted by "voonhous (via GitHub)" <gi...@apache.org>.
voonhous commented on code in PR #19648:
URL: https://github.com/apache/hudi/pull/19648#discussion_r3819032311
##########
hudi-client/hudi-spark-client/src/main/java/org/apache/hudi/keygen/PartitionPathFormatterBase.java:
##########
@@ -62,11 +62,17 @@ public final S combine(List<String> partitionPathFields, Object... partitionPath
// Avoid creating [[StringBuilder]] in case there's just one partition-path part,
// and Hive-style of partitioning is not required
if (!useHiveStylePartitioning && partitionPathParts.length == 1) {
- if (slashSeparatedDatePartitioning) {
- return ((S) ((String) toString(partitionPathParts[0])).replace('-', '/'));
- } else {
- return tryEncode(handleEmpty(toString(partitionPathParts[0])));
- }
+ S partitionPathPart = tryEncode(handleEmpty(toString(partitionPathParts[0])));
+ // NOTE: For [[SimpleKeyGenerator]]/[[ComplexKeyGenerator]] slash-separated date partitioning
+ // only kicks in for a table partitioned by a single (date) column, mirroring
+ // [[KeyGenUtils#getPartitionPath]] (single field) and [[KeyGenUtils#getRecordPartitionPath]]
+ // (which guards on a single field as well) driving the Avro write-path: both write-paths
+ // have to derive the very same partition path for a record.
+ // [[CustomKeyGenerator]] is not an exception to this: it builds one single-field
+ // sub-key-generator per partition field, so every field takes this branch and a
+ // multi-field table does get each of its values slash-separated -- on the Avro,
+ // [[org.apache.spark.sql.Row]] and [[org.apache.spark.sql.catalyst.InternalRow]] paths alike
+ return slashSeparatedDatePartitioning ? replaceDashesWithSlashes(partitionPathPart) : partitionPathPart;
Review Comment:
The substitution is unconditional, so any value with a leading dash yields a leading-slash path: `-5` becomes `/5`. `FSUtils.constructAbsolutePath(String, String)` chops the leading `/` (`FSUtils.java:590-594`), but the `(StoragePath, String)` overload used by `AbstractTableFileSystemView` does not, and `StoragePath(parent, child)` URI-resolves an absolute child into replacing the base path, so the writer and the file-system view disagree on where that partition lives. Pre-existing on the Avro path (`KeyGenUtils` does the same `replace`), but this PR makes it reachable on the row-writer paths.
Ask: file a follow-up to guard the substitution here and in `KeyGenUtils` alike, and add one `-5` assert to `TestPartitionPathFormatter` so the current behavior is pinned until then.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@hudi.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] fix(spark): make slash-separated date partitioning work on the row writer path [hudi]
Posted by "voonhous (via GitHub)" <gi...@apache.org>.
voonhous commented on code in PR #19648:
URL: https://github.com/apache/hudi/pull/19648#discussion_r3819041736
##########
hudi-spark-datasource/hudi-spark/src/test/scala/org/apache/spark/sql/hudi/common/TestSlashSeparatedPartitionValue.scala:
##########
@@ -90,6 +90,113 @@ class TestSlashSeparatedPartitionValue extends HoodieSparkSqlTestBase {
}
}
+ test("Test slash separated date partitions written through the row writer") {
+ withSQLConf("hoodie.spark.sql.insert.into.operation" -> "bulk_insert") {
+ withTempDir { tmp =>
+ val targetTable = generateTableName
+ val tablePath = s"${tmp.getCanonicalPath}/$targetTable"
+
+ spark.sql(
+ s"""
+ |create table $targetTable (
+ | `id` string,
+ | `name` string,
+ | `ts` bigint,
+ | `datestr` STRING
+ |) using hudi
+ | tblproperties (
+ | 'primaryKey' = 'id',
+ | 'type' = 'COW',
+ | 'preCombineField'='ts',
+ | 'hoodie.datasource.write.slash.separated.date.partitioning'='true'
+ | )
+ | partitioned by (`datestr`)
+ | location '$tablePath'
+ """.stripMargin)
+
+ // NOTE: The row writer derives the partition path off of an [[InternalRow]], which used to
+ // blow up with a [[ClassCastException]]; a null partition value used to NPE
+ spark.sql(
+ s"""
+ | insert into $targetTable values
+ | (1, 'a1', 1000, "2026-01-05"),
+ | (2, 'a2', 2000, "2026-01-06"),
+ | (3, 'a3', 3000, null)
+ """.stripMargin)
+
+ checkAnswer(s"select id, name, ts, _hoodie_partition_path, datestr from $targetTable order by id")(
Review Comment:
Read-back passes here because the Spark-side `doParsePartitionColumnValues` handles the slash layout, but the engine-agnostic `PartitionPathParser#getPartitionValues` does not for a STRING partition column: `2026/01/05` parses to `2026`, since only time-typed fields go through `inferDateValue` and everything else takes `parts[0]`. Its lone consumer today is the bootstrap-merge read (`HoodieFileGroupReader.java:284`), so nothing to change in this PR.
Ask: file a follow-up for `PartitionPathParser` covering STRING columns on slash tables.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@hudi.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] fix(spark): make slash-separated date partitioning work on the row writer path [hudi]
Posted by "voonhous (via GitHub)" <gi...@apache.org>.
voonhous commented on code in PR #19648:
URL: https://github.com/apache/hudi/pull/19648#discussion_r3819028760
##########
hudi-client/hudi-spark-client/src/main/java/org/apache/hudi/keygen/PartitionPathFormatterBase.java:
##########
@@ -62,11 +62,11 @@ public final S combine(List<String> partitionPathFields, Object... partitionPath
// Avoid creating [[StringBuilder]] in case there's just one partition-path part,
// and Hive-style of partitioning is not required
if (!useHiveStylePartitioning && partitionPathParts.length == 1) {
- if (slashSeparatedDatePartitioning) {
- return ((S) ((String) toString(partitionPathParts[0])).replace('-', '/'));
- } else {
- return tryEncode(handleEmpty(toString(partitionPathParts[0])));
- }
+ S partitionPathPart = tryEncode(handleEmpty(toString(partitionPathParts[0])));
+ // NOTE: Slash-separated date partitioning only kicks in for a table partitioned by a single
Review Comment:
One correction to the amended NOTE: the multi-field `CustomKeyGenerator` layout it describes cannot be read back. `date:simple,city:simple` + slash writes `2026/01/05/san/francisco` (all three paths agree), but `HoodieSparkUtils#doParsePartitionColumnValues` returns a length-0 array for it (5 fragments vs 2 partition columns, no `col=` prefix), so `BaseHoodieTableFileIndex.java:477` throws `HoodieException` on every read under the default lazy listing.
Ask: reword the last sentence of the NOTE to say the resulting layout is not readable and cite #19666, and widen #19666 to explicitly cover `CustomKeyGenerator` (a partition-field-count check at table creation still catches its per-field sub-keygens).
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@hudi.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] fix(spark): make slash-separated date partitioning work on the row writer path [hudi]
Posted by "hudi-bot (via GitHub)" <gi...@apache.org>.
hudi-bot commented on PR #19648:
URL: https://github.com/apache/hudi/pull/19648#issuecomment-5345163171
<!--
Meta data
{
"version" : 1,
"metaDataEntries" : [ {
"hash" : "ce3ab56d080092972df722ab619a3cf71308b6c2",
"status" : "FAILURE",
"url" : "https://dev.azure.com/apachehudi/a1a51da7-8592-47d4-88dc-fd67bed336bb/_build/results?buildId=16342",
"triggerID" : "ce3ab56d080092972df722ab619a3cf71308b6c2",
"triggerType" : "PUSH"
}, {
"hash" : "8d523937035c816ddf765ac61acad162e311b738",
"status" : "UNKNOWN",
"url" : "TBD",
"triggerID" : "8d523937035c816ddf765ac61acad162e311b738",
"triggerType" : "PUSH"
} ]
}-->
## CI report:
* ce3ab56d080092972df722ab619a3cf71308b6c2 Azure: [FAILURE](https://dev.azure.com/apachehudi/a1a51da7-8592-47d4-88dc-fd67bed336bb/_build/results?buildId=16342)
* 8d523937035c816ddf765ac61acad162e311b738 UNKNOWN
<details>
<summary>Bot commands</summary>
@hudi-bot supports the following commands:
- `@hudi-bot run azure` re-run the last Azure build
</details>
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@hudi.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] fix(spark): make slash-separated date partitioning work on the row writer path [hudi]
Posted by "SEPURI-SAI-KRISHNA (via GitHub)" <gi...@apache.org>.
SEPURI-SAI-KRISHNA commented on code in PR #19648:
URL: https://github.com/apache/hudi/pull/19648#discussion_r3815158346
##########
hudi-spark-datasource/hudi-spark/src/test/scala/org/apache/spark/sql/hudi/common/TestSlashSeparatedPartitionValue.scala:
##########
@@ -90,6 +90,61 @@ class TestSlashSeparatedPartitionValue extends HoodieSparkSqlTestBase {
}
}
+ test("Test slash separated date partitions written through the row writer") {
+ withSQLConf("hoodie.sql.bulk.insert.enable" -> "true", "hoodie.sql.insert.mode" -> "non-strict",
+ "hoodie.datasource.write.row.writer.enable" -> "true") {
Review Comment:
Applied, the deprecated configs are gone in favour of hoodie.spark.sql.insert.into.operation. The new DATE case uses the Seq("insert", "bulk_insert").foreach shape you suggested; happy to fold the older duplicated blocks into it too if you want that in this PR.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@hudi.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] fix(spark): make slash-separated date partitioning work on the row writer path [hudi]
Posted by "hudi-bot (via GitHub)" <gi...@apache.org>.
hudi-bot commented on PR #19648:
URL: https://github.com/apache/hudi/pull/19648#issuecomment-5345857068
<!--
Meta data
{
"version" : 1,
"metaDataEntries" : [ {
"hash" : "ce3ab56d080092972df722ab619a3cf71308b6c2",
"status" : "DELETED",
"url" : "https://dev.azure.com/apachehudi/a1a51da7-8592-47d4-88dc-fd67bed336bb/_build/results?buildId=16342",
"triggerID" : "ce3ab56d080092972df722ab619a3cf71308b6c2",
"triggerType" : "PUSH"
}, {
"hash" : "8d523937035c816ddf765ac61acad162e311b738",
"status" : "FAILURE",
"url" : "https://dev.azure.com/apachehudi/a1a51da7-8592-47d4-88dc-fd67bed336bb/_build/results?buildId=16390",
"triggerID" : "8d523937035c816ddf765ac61acad162e311b738",
"triggerType" : "PUSH"
} ]
}-->
## CI report:
* 8d523937035c816ddf765ac61acad162e311b738 Azure: [FAILURE](https://dev.azure.com/apachehudi/a1a51da7-8592-47d4-88dc-fd67bed336bb/_build/results?buildId=16390)
<details>
<summary>Bot commands</summary>
@hudi-bot supports the following commands:
- `@hudi-bot run azure` re-run the last Azure build
</details>
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@hudi.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] fix(spark): make slash-separated date partitioning work on the row writer path [hudi]
Posted by "voonhous (via GitHub)" <gi...@apache.org>.
voonhous commented on code in PR #19648:
URL: https://github.com/apache/hudi/pull/19648#discussion_r3813358360
##########
hudi-client/hudi-spark-client/src/main/java/org/apache/hudi/keygen/PartitionPathFormatterBase.java:
##########
@@ -75,15 +75,11 @@ public final S combine(List<String> partitionPathFields, Object... partitionPath
if (useHiveStylePartitioning) {
Review Comment:
Strengthening this: "unreachable" holds only for SQL DDL. The guard is `HoodieCatalogTable#extraTableConfig:296-300` and inspects `sqlOptions` only; `HoodieWriterUtils`, `HoodieSparkSqlWriter` and `BaseKeyGenerator` have no equivalent, so `df.write.format("hudi")` and HoodieStreamer accept `hive_style_partitioning=true` + `slash.separated.date.partitioning=true`. With a single partition field that table gets `date_col=2026/01/05` from the Avro path and `date_col=2026-01-05` from the InternalRow path, and both are live (`HoodieCreateRecordUtils` AVRO vs SPARK record type, plus the row writer). The Avro layout is also not readable: `HoodieSparkUtils.doParsePartitionColumnValues:306-312` takes the `date_col=` prefix branch and never restores `/` -> `-`. Agree with not mirroring Avro.
Ask: drop the "this combination is unreachable" sentence from the `testHiveStylePartitioningTakesPrecedence` comment (`TestPartitionPathFormatter.java:98-102`) -- it pins a non-discriminating value and will mislead the next reader; either delete that test or keep it with the comment corrected. The all-write-paths mutual-exclusion check (e.g. `HoodieWriterUtils.validateTableConfig`) can be here or a linked follow-up.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@hudi.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] fix(spark): make slash-separated date partitioning work on the row writer path [hudi]
Posted by "SEPURI-SAI-KRISHNA (via GitHub)" <gi...@apache.org>.
SEPURI-SAI-KRISHNA commented on code in PR #19648:
URL: https://github.com/apache/hudi/pull/19648#discussion_r3815116952
##########
hudi-client/hudi-spark-client/src/test/java/org/apache/hudi/keygen/TestSimpleKeyGenerator.java:
##########
@@ -213,4 +213,34 @@ void testSlashSeparatedDatePartitioningWithAlreadyFormattedInput() {
Assertions.assertEquals("key1", key.getRecordKey());
Assertions.assertEquals("2026/01/01", key.getPartitionPath());
}
+
+ @Test
+ void testSlashSeparatedDatePartitioningOnRowWritingPaths() {
+ TypedProperties properties = getPropsWithSlashSeparatedDatePartitioning();
+ // NOTE: "ts_ms" is the string-typed field of the example schema, "timestamp" is a long
+ properties.put(KeyGeneratorOptions.PARTITIONPATH_FIELD_NAME.key(), "ts_ms");
+ SimpleKeyGenerator keyGenerator = new SimpleKeyGenerator(properties);
+
+ GenericRecord avroRecord = getRecord();
+ Assertions.assertEquals("2020/03/21", keyGenerator.getPartitionPath(avroRecord));
+
+ Row row = KeyGeneratorTestUtilities.getRow(avroRecord);
+ Assertions.assertEquals("2020/03/21", keyGenerator.getPartitionPath(row));
+
+ InternalRow internalRow = KeyGeneratorTestUtilities.getInternalRow(row);
+ Assertions.assertEquals(UTF8String.fromString("2020/03/21"),
+ keyGenerator.getPartitionPath(internalRow, row.schema()));
+ }
+
+ @Test
+ void testSlashSeparatedDatePartitioningWithNullValue() {
+ TypedProperties properties = getPropsWithSlashSeparatedDatePartitioning();
+ properties.put(KeyGeneratorOptions.PARTITIONPATH_FIELD_NAME.key(), "nested_col.prop1");
+ SimpleKeyGenerator keyGenerator = new SimpleKeyGenerator(properties);
+
+ GenericRecord avroRecord = getRecord(getNestedColRecord(null, 10L));
+
+ Row row = KeyGeneratorTestUtilities.getRow(avroRecord);
+ Assertions.assertEquals(HUDI_DEFAULT_PARTITION_PATH, keyGenerator.getPartitionPath(row));
Review Comment:
Applied, with one adjustment: the suggestion as written cannot run. KeyGeneratorTestUtilities#getInternalRow builds a flat GenericInternalRow via InternalRow.apply, so the "nested_col" value stays a GenericRowWithSchema and reading it back as a struct off the InternalRow fails with
ClassCastException: GenericRowWithSchema cannot be cast to InternalRow
Every other getInternalRow call site in these tests uses a top-level partition field, so this is the first to point it at a nested one. A null on a top-level field is not an escape either -- every other field of EXAMPLE_SCHEMA is non-nullable, and HoodieUnsafeRowUtils rejects the null before the formatter is reached ("Found null value for the field that is declared as non-nullable: StructField(ts_ms,StringType,false)").
So the InternalRow is built through Spark's own converter instead, which handles the nesting:
InternalRow internalRow =
(InternalRow) CatalystTypeConverters.createToCatalystConverter(row.schema()).apply(row);
Same coverage you asked for, without changing the shared helper (that would touch 12 unrelated call sites). Verified red on master -- NullPointerException at the Row assert -- and green here.
Happy to fix getInternalRow properly in a follow-up if you would rather have the helper handle nesting.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@hudi.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] fix(spark): make slash-separated date partitioning work on the row writer path [hudi]
Posted by "SEPURI-SAI-KRISHNA (via GitHub)" <gi...@apache.org>.
SEPURI-SAI-KRISHNA commented on code in PR #19648:
URL: https://github.com/apache/hudi/pull/19648#discussion_r3815127185
##########
hudi-client/hudi-spark-client/src/main/java/org/apache/hudi/keygen/PartitionPathFormatterBase.java:
##########
@@ -62,11 +62,11 @@ public final S combine(List<String> partitionPathFields, Object... partitionPath
// Avoid creating [[StringBuilder]] in case there's just one partition-path part,
// and Hive-style of partitioning is not required
if (!useHiveStylePartitioning && partitionPathParts.length == 1) {
- if (slashSeparatedDatePartitioning) {
- return ((S) ((String) toString(partitionPathParts[0])).replace('-', '/'));
- } else {
- return tryEncode(handleEmpty(toString(partitionPathParts[0])));
- }
+ S partitionPathPart = tryEncode(handleEmpty(toString(partitionPathParts[0])));
+ // NOTE: Slash-separated date partitioning only kicks in for a table partitioned by a single
Review Comment:
Both applied.
The NOTE now scopes the single-field statement to SimpleKeyGenerator/ComplexKeyGenerator, cites KeyGenUtils#getPartitionPath alongside getRecordPartitionPath, and states explicitly that CustomKeyGenerator is not an exception -- it builds one single-field sub-key-generator per partition field, so every field takes that branch and a multi-field table does get each value slash-separated on Avro, Row and InternalRow alike.
TestCustomKeyGenerator.testSlashSeparatedDatePartitioning now asserts Row and InternalRow. One thing worth flagging: it partitioned on "timestamp:simple" and did avroRecord.put("timestamp", "2026-01-05"), but "timestamp" is a long in EXAMPLE_SCHEMA -- Avro tolerates it because getNestedFieldValAsString just stringifies, but converting that record to a Row against STRUCT_TYPE (LongType) does not work. The test now uses the string-typed "ts_ms", which is what makes the Row/InternalRow asserts possible at all.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@hudi.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] fix(spark): make slash-separated date partitioning work on the row writer path [hudi]
Posted by "hudi-bot (via GitHub)" <gi...@apache.org>.
hudi-bot commented on PR #19648:
URL: https://github.com/apache/hudi/pull/19648#issuecomment-5381006067
<!--
Meta data
{
"version" : 1,
"metaDataEntries" : [ {
"hash" : "ce3ab56d080092972df722ab619a3cf71308b6c2",
"status" : "DELETED",
"url" : "https://dev.azure.com/apachehudi/a1a51da7-8592-47d4-88dc-fd67bed336bb/_build/results?buildId=16342",
"triggerID" : "ce3ab56d080092972df722ab619a3cf71308b6c2",
"triggerType" : "PUSH"
}, {
"hash" : "8d523937035c816ddf765ac61acad162e311b738",
"status" : "DELETED",
"url" : "https://dev.azure.com/apachehudi/a1a51da7-8592-47d4-88dc-fd67bed336bb/_build/results?buildId=16390",
"triggerID" : "8d523937035c816ddf765ac61acad162e311b738",
"triggerType" : "PUSH"
}, {
"hash" : "fdd04bfbf709f806768ae4b4b259a679b08e2aa4",
"status" : "DELETED",
"url" : "https://dev.azure.com/apachehudi/a1a51da7-8592-47d4-88dc-fd67bed336bb/_build/results?buildId=16413",
"triggerID" : "fdd04bfbf709f806768ae4b4b259a679b08e2aa4",
"triggerType" : "PUSH"
}, {
"hash" : "8f1cb373283c41cf6513e83b169e692902c91c4e",
"status" : "DELETED",
"url" : "https://dev.azure.com/apachehudi/a1a51da7-8592-47d4-88dc-fd67bed336bb/_build/results?buildId=16440",
"triggerID" : "8f1cb373283c41cf6513e83b169e692902c91c4e",
"triggerType" : "PUSH"
}, {
"hash" : "8ce9ad0a09e3fc8a889eefab03abc38f6a1e8aa5",
"status" : "SUCCESS",
"url" : "https://dev.azure.com/apachehudi/a1a51da7-8592-47d4-88dc-fd67bed336bb/_build/results?buildId=16477",
"triggerID" : "8ce9ad0a09e3fc8a889eefab03abc38f6a1e8aa5",
"triggerType" : "PUSH"
}, {
"hash" : "2d738376d122aa8b60243bd99f216f5b8b3fa217",
"status" : "UNKNOWN",
"url" : "TBD",
"triggerID" : "2d738376d122aa8b60243bd99f216f5b8b3fa217",
"triggerType" : "PUSH"
} ]
}-->
## CI report:
* 8ce9ad0a09e3fc8a889eefab03abc38f6a1e8aa5 Azure: [SUCCESS](https://dev.azure.com/apachehudi/a1a51da7-8592-47d4-88dc-fd67bed336bb/_build/results?buildId=16477)
* 2d738376d122aa8b60243bd99f216f5b8b3fa217 UNKNOWN
<details>
<summary>Bot commands</summary>
@hudi-bot supports the following commands:
- `@hudi-bot run azure` re-run the last Azure build
</details>
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@hudi.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] fix(spark): make slash-separated date partitioning work on the row writer path [hudi]
Posted by "SEPURI-SAI-KRISHNA (via GitHub)" <gi...@apache.org>.
SEPURI-SAI-KRISHNA commented on code in PR #19648:
URL: https://github.com/apache/hudi/pull/19648#discussion_r3836395130
##########
hudi-spark-datasource/hudi-spark/src/test/scala/org/apache/spark/sql/hudi/common/TestSlashSeparatedPartitionValue.scala:
##########
@@ -90,6 +90,113 @@ class TestSlashSeparatedPartitionValue extends HoodieSparkSqlTestBase {
}
}
+ test("Test slash separated date partitions written through the row writer") {
+ withSQLConf("hoodie.spark.sql.insert.into.operation" -> "bulk_insert") {
+ withTempDir { tmp =>
+ val targetTable = generateTableName
+ val tablePath = s"${tmp.getCanonicalPath}/$targetTable"
+
+ spark.sql(
+ s"""
+ |create table $targetTable (
+ | `id` string,
+ | `name` string,
+ | `ts` bigint,
+ | `datestr` STRING
+ |) using hudi
+ | tblproperties (
+ | 'primaryKey' = 'id',
+ | 'type' = 'COW',
+ | 'preCombineField'='ts',
+ | 'hoodie.datasource.write.slash.separated.date.partitioning'='true'
+ | )
+ | partitioned by (`datestr`)
+ | location '$tablePath'
+ """.stripMargin)
+
+ // NOTE: The row writer derives the partition path off of an [[InternalRow]], which used to
+ // blow up with a [[ClassCastException]]; a null partition value used to NPE
+ spark.sql(
+ s"""
+ | insert into $targetTable values
+ | (1, 'a1', 1000, "2026-01-05"),
+ | (2, 'a2', 2000, "2026-01-06"),
+ | (3, 'a3', 3000, null)
+ """.stripMargin)
+
+ checkAnswer(s"select id, name, ts, _hoodie_partition_path, datestr from $targetTable order by id")(
+ Seq("1", "a1", 1000, "2026/01/05", "2026-01-05"),
+ Seq("2", "a2", 2000, "2026/01/06", "2026-01-06"),
+ Seq("3", "a3", 3000, "__HIVE_DEFAULT_PARTITION__", null)
+ )
+
+ val metaClient = HoodieTableMetaClient.builder()
+ .setConf(HadoopFSUtils.getStorageConfWithCopy(spark.sparkContext.hadoopConfiguration))
+ .setBasePath(tablePath)
+ .build()
+ assertTrue(metaClient.getStorage.exists(new StoragePath(tablePath, "2026/01/05")),
+ s"Partition path 2026/01/05 should exist")
+ assertTrue(metaClient.getStorage.exists(new StoragePath(tablePath, "2026/01/06")),
+ s"Partition path 2026/01/06 should exist")
+ assertTrue(metaClient.getStorage.exists(new StoragePath(tablePath, "__HIVE_DEFAULT_PARTITION__")),
+ s"Partition path __HIVE_DEFAULT_PARTITION__ should exist")
+ }
+ }
+ }
+
+ test("Test slash separated date partitions on a DATE typed partition column") {
+ Seq("insert", "bulk_insert").foreach { operation =>
+ withSQLConf("hoodie.spark.sql.insert.into.operation" -> operation) {
+ withTempDir { tmp =>
+ val targetTable = generateTableName
+ val tablePath = s"${tmp.getCanonicalPath}/$targetTable"
+
+ spark.sql(
Review Comment:
Taken rather than ignored -- it paid for itself immediately, since the other asks on this PR each needed another copy of the same block.
Extracted `createSlashPartitionedTable` (parameterized on partition-column type, table type and the config value), `buildMetaClient`, `assertPartitionDirsExist` and `assertMetadataTablePartitions`. The file went from 268 lines to 267 while gaining two new tests and the metadata-table assertions everywhere.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@hudi.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] fix(spark): make slash-separated date partitioning work on the row writer path [hudi]
Posted by "SEPURI-SAI-KRISHNA (via GitHub)" <gi...@apache.org>.
SEPURI-SAI-KRISHNA commented on code in PR #19648:
URL: https://github.com/apache/hudi/pull/19648#discussion_r3836392661
##########
hudi-spark-datasource/hudi-spark/src/test/scala/org/apache/spark/sql/hudi/common/TestSlashSeparatedPartitionValue.scala:
##########
@@ -90,6 +90,113 @@ class TestSlashSeparatedPartitionValue extends HoodieSparkSqlTestBase {
}
}
+ test("Test slash separated date partitions written through the row writer") {
+ withSQLConf("hoodie.spark.sql.insert.into.operation" -> "bulk_insert") {
+ withTempDir { tmp =>
+ val targetTable = generateTableName
+ val tablePath = s"${tmp.getCanonicalPath}/$targetTable"
+
+ spark.sql(
+ s"""
+ |create table $targetTable (
+ | `id` string,
+ | `name` string,
+ | `ts` bigint,
+ | `datestr` STRING
+ |) using hudi
+ | tblproperties (
+ | 'primaryKey' = 'id',
+ | 'type' = 'COW',
+ | 'preCombineField'='ts',
+ | 'hoodie.datasource.write.slash.separated.date.partitioning'='true'
+ | )
+ | partitioned by (`datestr`)
+ | location '$tablePath'
+ """.stripMargin)
+
+ // NOTE: The row writer derives the partition path off of an [[InternalRow]], which used to
+ // blow up with a [[ClassCastException]]; a null partition value used to NPE
+ spark.sql(
+ s"""
+ | insert into $targetTable values
+ | (1, 'a1', 1000, "2026-01-05"),
+ | (2, 'a2', 2000, "2026-01-06"),
+ | (3, 'a3', 3000, null)
+ """.stripMargin)
+
+ checkAnswer(s"select id, name, ts, _hoodie_partition_path, datestr from $targetTable order by id")(
+ Seq("1", "a1", 1000, "2026/01/05", "2026-01-05"),
+ Seq("2", "a2", 2000, "2026/01/06", "2026-01-06"),
+ Seq("3", "a3", 3000, "__HIVE_DEFAULT_PARTITION__", null)
+ )
+
+ val metaClient = HoodieTableMetaClient.builder()
+ .setConf(HadoopFSUtils.getStorageConfWithCopy(spark.sparkContext.hadoopConfiguration))
+ .setBasePath(tablePath)
+ .build()
+ assertTrue(metaClient.getStorage.exists(new StoragePath(tablePath, "2026/01/05")),
+ s"Partition path 2026/01/05 should exist")
+ assertTrue(metaClient.getStorage.exists(new StoragePath(tablePath, "2026/01/06")),
+ s"Partition path 2026/01/06 should exist")
+ assertTrue(metaClient.getStorage.exists(new StoragePath(tablePath, "__HIVE_DEFAULT_PARTITION__")),
+ s"Partition path __HIVE_DEFAULT_PARTITION__ should exist")
+ }
+ }
+ }
+
+ test("Test slash separated date partitions on a DATE typed partition column") {
+ Seq("insert", "bulk_insert").foreach { operation =>
Review Comment:
Applied -- the loop is gone and only `bulk_insert` remains, with a note pointing at `TestTypedPartitionValues` for the `insert` coverage.
Also took the better suggestion: the two partition-pruning assertions are pulled in, so the DATE case now checks that the recovered partition value is what the predicate evaluates against.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@hudi.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] fix(spark): make slash-separated date partitioning work on the row writer path [hudi]
Posted by "hudi-agent (via GitHub)" <gi...@apache.org>.
hudi-agent commented on code in PR #19648:
URL: https://github.com/apache/hudi/pull/19648#discussion_r3817100406
##########
hudi-client/hudi-spark-client/src/main/java/org/apache/hudi/keygen/PartitionPathFormatterBase.java:
##########
@@ -75,15 +75,11 @@ public final S combine(List<String> partitionPathFields, Object... partitionPath
if (useHiveStylePartitioning) {
Review Comment:
🤖 Confirmed against the Avro side: both `KeyGenUtils.getRecordPartitionPath` (the `size()==1 && slashSeparatedDatePartitioning` branch, ~L257-262) and `getPartitionPath` (~L291-295) run `replace('-', '/')` *after* prepending the `field=` hive prefix, so the Avro path really does produce `date_col=2026/01/05`. The row-writer `combine` only slashes in the non-hive branches, so hive-style + slash + single-field diverges to `date_col=2026-01-05`. Agree it's pre-existing and fine to align in a follow-up, but it'd be worth not pinning the divergent result in `testHiveStylePartitioningTakesPrecedence` so the follow-up doesn't have to rewrite the assertion.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@hudi.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] fix(spark): make slash-separated date partitioning work on the row writer path [hudi]
Posted by "voonhous (via GitHub)" <gi...@apache.org>.
voonhous commented on code in PR #19648:
URL: https://github.com/apache/hudi/pull/19648#discussion_r3819038112
##########
hudi-spark-datasource/hudi-spark/src/test/scala/org/apache/spark/sql/hudi/common/TestSlashSeparatedPartitionValue.scala:
##########
@@ -90,6 +90,113 @@ class TestSlashSeparatedPartitionValue extends HoodieSparkSqlTestBase {
}
}
+ test("Test slash separated date partitions written through the row writer") {
+ withSQLConf("hoodie.spark.sql.insert.into.operation" -> "bulk_insert") {
+ withTempDir { tmp =>
+ val targetTable = generateTableName
+ val tablePath = s"${tmp.getCanonicalPath}/$targetTable"
+
+ spark.sql(
+ s"""
+ |create table $targetTable (
+ | `id` string,
+ | `name` string,
+ | `ts` bigint,
+ | `datestr` STRING
+ |) using hudi
+ | tblproperties (
+ | 'primaryKey' = 'id',
+ | 'type' = 'COW',
+ | 'preCombineField'='ts',
+ | 'hoodie.datasource.write.slash.separated.date.partitioning'='true'
+ | )
+ | partitioned by (`datestr`)
+ | location '$tablePath'
+ """.stripMargin)
+
+ // NOTE: The row writer derives the partition path off of an [[InternalRow]], which used to
+ // blow up with a [[ClassCastException]]; a null partition value used to NPE
+ spark.sql(
+ s"""
+ | insert into $targetTable values
+ | (1, 'a1', 1000, "2026-01-05"),
+ | (2, 'a2', 2000, "2026-01-06"),
+ | (3, 'a3', 3000, null)
+ """.stripMargin)
+
+ checkAnswer(s"select id, name, ts, _hoodie_partition_path, datestr from $targetTable order by id")(
+ Seq("1", "a1", 1000, "2026/01/05", "2026-01-05"),
+ Seq("2", "a2", 2000, "2026/01/06", "2026-01-06"),
+ Seq("3", "a3", 3000, "__HIVE_DEFAULT_PARTITION__", null)
+ )
+
+ val metaClient = HoodieTableMetaClient.builder()
+ .setConf(HadoopFSUtils.getStorageConfWithCopy(spark.sparkContext.hadoopConfiguration))
+ .setBasePath(tablePath)
+ .build()
+ assertTrue(metaClient.getStorage.exists(new StoragePath(tablePath, "2026/01/05")),
Review Comment:
The partition DDL commands are slash-unaware on the table this test creates: `HoodieSqlCommonUtils#makePartitionPath` (`HoodieSqlCommonUtils.scala:420-427`) reads hive-style and urlencode from table config but never `getSlashSeparatedDatePartitioning`, so `alter table ... drop partition (datestr='2026-01-05')` targets `2026-01-05` while the directory is `2026/01/05`: the replacecommit replaces zero file groups and the drop is a silent no-op, and `add partition` creates a bogus dashed directory. Distinct from #19666/#19668/#19669.
Optional, nothing needed in this PR: this is a pre-existing bug in a file this PR does not touch, so feel free to leave it -- I will file the follow-up for `makePartitionPath` if you do not pick it up. Flagging here so it is on record next to the tests that create such tables.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@hudi.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] fix(spark): make slash-separated date partitioning work on the row writer path [hudi]
Posted by "SEPURI-SAI-KRISHNA (via GitHub)" <gi...@apache.org>.
SEPURI-SAI-KRISHNA commented on code in PR #19648:
URL: https://github.com/apache/hudi/pull/19648#discussion_r3815194737
##########
hudi-client/hudi-spark-client/src/test/java/org/apache/hudi/keygen/TestPartitionPathFormatter.java:
##########
@@ -0,0 +1,115 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.hudi.keygen;
+
+import org.apache.spark.unsafe.types.UTF8String;
+import org.junit.jupiter.params.ParameterizedTest;
+import org.junit.jupiter.params.provider.ValueSource;
+
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.List;
+
+import static org.apache.hudi.common.util.PartitionPathEncodeUtils.DEFAULT_PARTITION_PATH;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+
+/**
+ * Tests the partition-path formatters backing the key generators, making sure that both the
+ * {@link String} (Avro/{@link org.apache.spark.sql.Row} write path) and the {@link UTF8String}
+ * (row-writer/{@link org.apache.spark.sql.catalyst.InternalRow} write path) flavors produce
+ * identical partition paths.
+ */
+class TestPartitionPathFormatter {
+
+ private static final List<String> SINGLE_FIELD = Collections.singletonList("date_col");
+ private static final List<String> TWO_FIELDS = Arrays.asList("date_col", "city");
+
+ private String combine(boolean useRowWriterPath,
+ boolean hiveStylePartitioning,
+ boolean encode,
+ boolean slashSeparatedDatePartitioning,
+ List<String> fields,
+ Object... parts) {
+ if (useRowWriterPath) {
+ return new UTF8StringPartitionPathFormatter(
+ UTF8StringPartitionPathFormatter.UTF8StringBuilder::new, hiveStylePartitioning, encode,
+ slashSeparatedDatePartitioning).combine(fields, parts).toString();
+ }
+ return new StringPartitionPathFormatter(
+ StringPartitionPathFormatter.JavaStringBuilder::new, hiveStylePartitioning, encode,
+ slashSeparatedDatePartitioning).combine(fields, parts);
+ }
+
+ @ParameterizedTest
+ @ValueSource(booleans = {true, false})
+ void testSlashSeparatedDatePartitioningSingleField(boolean useRowWriterPath) {
+ assertEquals("2026/01/05",
+ combine(useRowWriterPath, false, false, true, SINGLE_FIELD, "2026-01-05"));
+ // Input that is already slash-separated is left untouched
+ assertEquals("2026/01/05",
+ combine(useRowWriterPath, false, false, true, SINGLE_FIELD, "2026/01/05"));
+ }
+
+ @ParameterizedTest
+ @ValueSource(booleans = {true, false})
+ void testSlashSeparatedDatePartitioningOnlyAppliesToSingleFieldPartitioning(boolean useRowWriterPath) {
+ // NOTE: This mirrors [[KeyGenUtils#getRecordPartitionPath]] driving the Avro write-path
+ assertEquals("2026-01-05/san-francisco",
+ combine(useRowWriterPath, false, false, true, TWO_FIELDS, "2026-01-05", "san-francisco"));
+ }
+
+ @ParameterizedTest
+ @ValueSource(booleans = {true, false})
+ void testSlashSeparatedDatePartitioningHandlesNullAndEmptyValues(boolean useRowWriterPath) {
+ assertEquals(DEFAULT_PARTITION_PATH,
+ combine(useRowWriterPath, false, false, true, SINGLE_FIELD, new Object[] {null}));
+ assertEquals(DEFAULT_PARTITION_PATH,
+ combine(useRowWriterPath, false, false, true, SINGLE_FIELD, ""));
+ }
+
+ @ParameterizedTest
+ @ValueSource(booleans = {true, false})
+ void testSlashSeparatedDatePartitioningEncodesValues(boolean useRowWriterPath) {
+ // '?' has to be escaped, while the date separators are turned into directory separators
+ assertEquals("2026/01/05", combine(useRowWriterPath, false, true, true, SINGLE_FIELD, "2026-01-05"));
+ assertEquals("a%3Fb", combine(useRowWriterPath, false, true, true, SINGLE_FIELD, "a?b"));
Review Comment:
Applied. The `a%3Fb` assert stays and the pinned one is added below it, with the comment explaining why:
```java
assertEquals("a%3Fb", combine(useRowWriterPath, false, true, true, SINGLE_FIELD, "a?b"));
// Encoding runs before the substitution (parity with KeyGenUtils), so an already slash-separated
// value is escaped rather than turned into directories
assertEquals("2026%2F01%2F05", combine(useRowWriterPath, false, true, true, SINGLE_FIELD, "2026/01/05"));
```
You are right that the two pre-existing asserts were no-ops for this change: a date value has nothing for `escapePathName` to escape, and `a?b` contains no dash for the substitution to act on. The new line is the one that actually pins the ordering, since it is the only input where encode-then-substitute and substitute-then-encode differ.
Verified on both formatter flavors.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@hudi.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] fix(spark): make slash-separated date partitioning work on the row writer path [hudi]
Posted by "SEPURI-SAI-KRISHNA (via GitHub)" <gi...@apache.org>.
SEPURI-SAI-KRISHNA commented on code in PR #19648:
URL: https://github.com/apache/hudi/pull/19648#discussion_r3815163963
##########
hudi-client/hudi-spark-client/src/test/java/org/apache/hudi/keygen/TestPartitionPathFormatter.java:
##########
@@ -0,0 +1,115 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.hudi.keygen;
+
+import org.apache.spark.unsafe.types.UTF8String;
+import org.junit.jupiter.params.ParameterizedTest;
+import org.junit.jupiter.params.provider.ValueSource;
+
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.List;
+
+import static org.apache.hudi.common.util.PartitionPathEncodeUtils.DEFAULT_PARTITION_PATH;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+
+/**
+ * Tests the partition-path formatters backing the key generators, making sure that both the
+ * {@link String} (Avro/{@link org.apache.spark.sql.Row} write path) and the {@link UTF8String}
+ * (row-writer/{@link org.apache.spark.sql.catalyst.InternalRow} write path) flavors produce
+ * identical partition paths.
+ */
+class TestPartitionPathFormatter {
+
+ private static final List<String> SINGLE_FIELD = Collections.singletonList("date_col");
+ private static final List<String> TWO_FIELDS = Arrays.asList("date_col", "city");
+
+ private String combine(boolean useRowWriterPath,
+ boolean hiveStylePartitioning,
+ boolean encode,
+ boolean slashSeparatedDatePartitioning,
+ List<String> fields,
+ Object... parts) {
+ if (useRowWriterPath) {
+ return new UTF8StringPartitionPathFormatter(
+ UTF8StringPartitionPathFormatter.UTF8StringBuilder::new, hiveStylePartitioning, encode,
+ slashSeparatedDatePartitioning).combine(fields, parts).toString();
+ }
+ return new StringPartitionPathFormatter(
+ StringPartitionPathFormatter.JavaStringBuilder::new, hiveStylePartitioning, encode,
+ slashSeparatedDatePartitioning).combine(fields, parts);
+ }
+
+ @ParameterizedTest
+ @ValueSource(booleans = {true, false})
+ void testSlashSeparatedDatePartitioningSingleField(boolean useRowWriterPath) {
Review Comment:
Deleted.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@hudi.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] fix(spark): make slash-separated date partitioning work on the row writer path [hudi]
Posted by "SEPURI-SAI-KRISHNA (via GitHub)" <gi...@apache.org>.
SEPURI-SAI-KRISHNA commented on code in PR #19648:
URL: https://github.com/apache/hudi/pull/19648#discussion_r3818374749
##########
hudi-client/hudi-spark-client/src/main/java/org/apache/hudi/keygen/PartitionPathFormatterBase.java:
##########
@@ -75,15 +75,11 @@ public final S combine(List<String> partitionPathFields, Object... partitionPath
if (useHiveStylePartitioning) {
Review Comment:
Thanks for tracing the Avro side — that matches what I found, and the divergence is tracked in #19669.
On not pinning the assertion: I'd like to keep it. The test exists specifically to characterize the current row-writer behavior, and the NOTE above it already says so explicitly ("This asserts the pre-existing behavior stays put, it is not a statement about what the combination *should* produce"). Without the assertion the test has nothing left to check. And a follow-up having to update this line is the useful signal rather than a cost — it makes the behavior change visible in that PR's diff instead of silent.
Worth adding that it isn't obvious the row writer is the side that's wrong here: the Avro path's `date_col=2026/01/05` is a layout `HoodieSparkUtils#doParsePartitionColumnValues` cannot read back, so #19669 may well settle on the row writer's current output as the correct one. Pinning it now keeps that option open.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@hudi.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org