You are viewing a plain text version of this content. The canonical link for it is here.
Posted to reviews@spark.apache.org by "pratham76 (via GitHub)" <gi...@apache.org> on 2026/08/13 16:16:44 UTC
[PR] [SPARK-51830][SQL] Fix partition type mismatch when validatePartitionColumns is disabled [spark]
pratham76 opened a new pull request, #57994:
URL: https://github.com/apache/spark/pull/57994
<!--
Thanks for sending a pull request! Here are some tips for you:
1. If this is your first time, please read our contributor guidelines: https://spark.apache.org/contributing.html
2. Ensure you have added or run the appropriate tests for your PR: https://spark.apache.org/developer-tools.html
3. If the PR is unfinished, add '[WIP]' in your PR title, e.g., '[WIP][SPARK-XXXX] Your PR title ...'.
4. Be sure to keep the PR description updated to reflect all changes.
5. Please write your PR title to summarize what this PR proposes.
6. If possible, provide a concise example to reproduce the issue for a faster review.
7. If you want to add a new configuration, please read the guideline first for naming configurations in
'common/utils/src/main/scala/org/apache/spark/internal/config/ConfigEntry.scala'.
8. If you want to add or modify an error type or message, please read the guideline first in
'common/utils/src/main/resources/error/README.md'.
-->
### What changes were proposed in this pull request?
<!--
Please clarify what changes you are proposing. The purpose of this section is to outline the changes and how this PR fixes the issue.
If possible, please consider writing useful notes for better and faster reviews in your PR. See the examples below.
1. If you refactor some codes with changing classes, showing the class hierarchy will help reviewers.
2. If you fix some SQL features, you can provide some references of other DBMSes.
3. If there is design documentation, please add the link.
4. If there is a discussion in the mailing list, please add the link.
-->
This PR fixes a bug where `insertInto()` operations fail with NumberFormatException when writing to legacy tables that have string partition values but numeric partition column schemas, even when `spark.sql.sources.validatePartitionColumns=false` is configured.
### Why are the changes needed?
<!--
Please clarify why the changes are needed. For instance,
1. If you propose a new API, clarify the use case for a new API.
2. If you fix a bug, you can clarify why it is a bug.
-->
This is a real issue for users migrating from legacy systems or working with tables where partition naming conventions don't match the schema. The validatePartitionColumns=false config exists specifically to handle such cases, but it wasn't being respected during writes.
### Does this PR introduce _any_ user-facing change?
<!--
Note that it means *any* user-facing change including all aspects such as new features, bug fixes, or other behavior changes. Documentation-only updates are not considered user-facing changes.
If yes, please clarify the previous behavior and the change this PR proposes - provide the console output, description and/or an example to show the behavior difference if possible.
If possible, please also clarify if this is a user-facing change compared to the released Spark versions or within the unreleased branches such as master.
If no, write 'No'.
-->
Yes, This PR fixes a bug where users could not write to legacy tables with mismatched partition types even when spark.sql.sources.validatePartitionColumns=false was configured.
### How was this patch tested?
<!--
If tests were added, say they were added here. Please make sure to add some test cases that check the changes thoroughly including negative and positive cases if possible.
If it was tested in a way different from regular unit tests, please clarify how you tested step by step, ideally copy and paste-able, so that other reviewers can test and check, and descendants can verify in the future.
If tests were not added, please describe why they were not added and/or why it was difficult to add.
If benchmark tests were added, please run the benchmarks in GitHub Actions for the consistent environment, and the instructions could accord to: https://spark.apache.org/developer-tools.html#github-workflow-benchmarks.
-->
Additional UTs added.
### Was this patch authored or co-authored using generative AI tooling?
<!--
If generative AI tooling has been used in the process of authoring this patch, please include the
phrase: 'Generated-by: ' followed by the name of the tool and its version.
If no, write 'No'.
Please refer to the [ASF Generative Tooling Guidance](https://www.apache.org/legal/generative-tooling.html) for details.
-->
No
--
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: reviews-unsubscribe@spark.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
Re: [PR] [SPARK-51830][SQL] Fix partition type mismatch when validatePartitionColumns is disabled [spark]
Posted by "uros-b (via GitHub)" <gi...@apache.org>.
uros-b commented on PR #57994:
URL: https://github.com/apache/spark/pull/57994#issuecomment-5617935686
Thank you @pratham76 for working on this and addressing all comments!
Let's loop in @HyukjinKwon for another round of review here please.
--
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: reviews-unsubscribe@spark.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
Re: [PR] [SPARK-51830][SQL] Fix partition type mismatch when validatePartitionColumns is disabled [spark]
Posted by "pratham76 (via GitHub)" <gi...@apache.org>.
pratham76 commented on PR #57994:
URL: https://github.com/apache/spark/pull/57994#issuecomment-5301042949
> 1. Loop-invariant config read — InsertIntoHadoopFsRelationCommand.scala (getCustomPartitionLocations): conf.validatePartitionColumns is now evaluated once per partition inside partitions.flatMap { p => ... }, but its value can't change during the traversal. Each call is a SQLConf.get + ConcurrentHashMap lookup, so this repeats per partition. Suggest hoisting it:
val validatePartitionColumns = conf.validatePartitionColumns
partitions.flatMap { p =>
val defaultLocation = qualifiedOutputPath.suffix(
"/" + PartitioningUtils.getPathFragment(
p.spec, table.partitionSchema, validatePartitionColumns)).toString
...
}
(The other new call site, in the static-partition branch, is a single call and is fine.)
Thanks for pointing it out, have addressed.
> 2. Test coverage — the new tests exercise PartitioningUtils.getPathFragment directly, which is good, but not the end-to-end InsertIntoHadoopFsRelationCommand insert/refresh path that motivated the ticket. An integration test (INSERT into a partitioned table whose on-disk partition value is a non-numeric string, with spark.sql.sources.validatePartitionColumns=false) would guard the actual scenario.
Have refactored the tests to include the actual scenario of `INSERT into a partitioned table whose on-disk partition value is a non-numeric string, with spark.sql.sources.validatePartitionColumns=false`
> 3. Pre-existing limitation (not introduced here, just flagging) — the fix rescues values that fail numeric parsing, but a numeric-looking value with leading zeros (e.g. 007) is still normalized to 7 regardless of the flag, so a legacy directory like p_int=007 still wouldn't be matched. Worth confirming that isn't part of the reported scenario.
I believe normalization should happen for parseable values. Since "007" can be successfully parsed as an integer, it should be normalized to "7" for semantic correctness, both represent the same numeric value. The `validatePartitionColumns=false` flag is intended to tolerate type mismatches (e.g., non-numeric strings like "partition_value" in an IntegerType column), not to disable all type-aware processing. Normalizing parseable numeric values maintains consistency with how Spark handles numeric partition values. I have added a comment notifying about this behaviour. Please do provide your thoughts on 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: reviews-unsubscribe@spark.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
Re: [PR] [SPARK-51830][SQL] Fix partition type mismatch when validatePartitionColumns is disabled [spark]
Posted by "uros-b (via GitHub)" <gi...@apache.org>.
uros-b commented on code in PR #57994:
URL: https://github.com/apache/spark/pull/57994#discussion_r3801777895
##########
sql/core/src/test/scala/org/apache/spark/sql/execution/datasources/parquet/ParquetPartitionDiscoverySuite.scala:
##########
@@ -1443,6 +1443,40 @@ class ParquetV2PartitionDiscoverySuite extends ParquetPartitionDiscoverySuite {
assert(s"p_int=${ExternalCatalogUtils.DEFAULT_PARTITION_NAME}" === path)
}
+ test("SPARK-51830: insertInto with string partition values " +
+ "when validatePartitionColumns is disabled") {
+ withTempDir { base =>
+ val legacyPartitionDir = new java.io.File(base, "p_int=partition_value")
+ legacyPartitionDir.mkdirs()
+ makeParquetFile(
+ (1 to 5).map(i => ParquetData(i, s"str$i")),
+ legacyPartitionDir)
+
+ val df = spark.read.parquet(base.getCanonicalPath)
+ df.createOrReplaceTempView("legacy_table")
+
+ withTempView("legacy_table") {
+ checkAnswer(
+ sql("SELECT * FROM legacy_table"),
+ (1 to 5).map(i => Row(i, s"str$i", "partition_value")))
+
+ val newData = Seq((6, "str6")).toDF("intField", "stringField")
+ intercept[NumberFormatException] {
+ newData.write.mode("append").insertInto("legacy_table")
+ }
+
+ withSQLConf(SQLConf.VALIDATE_PARTITION_COLUMNS.key -> "false") {
+ newData.write.mode("append").insertInto("legacy_table")
+
+ checkAnswer(
+ sql("SELECT * FROM legacy_table ORDER BY intField"),
+ (1 to 6).map(i => Row(i, s"str$i", "partition_value")))
+ }
+ }
+ }
+ }
Review Comment:
The new tests exercise PartitioningUtils.getPathFragment in isolation but do not cover the end-to-end InsertIntoHadoopFsRelationCommand path that motivated the ticket. Neither the static-partition branch (line 200-203) nor the getCustomPartitionLocations loop (line 270-272) - both updated in this PR, is exercised by any test that creates a real table and calls insertInto with the config flag disabled. An integration test (e.g., in InsertSuite) that creates a partitioned table whose on-disk partition directory has a non-numeric string name, then asserts a successful insertInto with spark.sql.sources.validatePartitionColumns=false, is needed to guard the actual scenario.
--
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: reviews-unsubscribe@spark.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
Re: [PR] [SPARK-51830][SQL] Fix partition type mismatch when validatePartitionColumns is disabled [spark]
Posted by "cloud-fan (via GitHub)" <gi...@apache.org>.
cloud-fan commented on PR #57994:
URL: https://github.com/apache/spark/pull/57994#issuecomment-5754874638
**Merge Summary:**
- merged into master https://github.com/apache/spark/commit/7e8bf895d1cf21676b021a5b225e2e3c1fc3ea70
- merged into branch-4.x https://github.com/apache/spark/commit/812d8a87e6e702eaee5b92df4bfeecb060a8d20c
- merged into branch-4.3 https://github.com/apache/spark/commit/5fc6b8e1e77cd9bc6567709e46e521e7a316c930
*Posted by `merge_spark_pr.py`*
--
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: reviews-unsubscribe@spark.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
Re: [PR] [SPARK-51830][SQL] Fix partition type mismatch when validatePartitionColumns is disabled [spark]
Posted by "pratham76 (via GitHub)" <gi...@apache.org>.
pratham76 commented on PR #57994:
URL: https://github.com/apache/spark/pull/57994#issuecomment-5681945425
@HyukjinKwon Gentle Ping!
--
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: reviews-unsubscribe@spark.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
Re: [PR] [SPARK-51830][SQL] Fix partition type mismatch when validatePartitionColumns is disabled [spark]
Posted by "pratham76 (via GitHub)" <gi...@apache.org>.
pratham76 commented on PR #57994:
URL: https://github.com/apache/spark/pull/57994#issuecomment-5558946091
@uros-b @HyukjinKwon Could you PTAL? I have updated the test suite to have integration tests with Insert Into, along with certain unit test cases covered as part of `PartitioningUtilsSuite`. Do let know if any other changes are required. 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: reviews-unsubscribe@spark.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
Re: [PR] [SPARK-51830][SQL] Fix partition type mismatch when validatePartitionColumns is disabled [spark]
Posted by "pratham76 (via GitHub)" <gi...@apache.org>.
pratham76 commented on code in PR #57994:
URL: https://github.com/apache/spark/pull/57994#discussion_r3943392066
##########
sql/core/src/test/scala/org/apache/spark/sql/execution/datasources/parquet/ParquetPartitionDiscoverySuite.scala:
##########
@@ -1443,6 +1443,40 @@ class ParquetV2PartitionDiscoverySuite extends ParquetPartitionDiscoverySuite {
assert(s"p_int=${ExternalCatalogUtils.DEFAULT_PARTITION_NAME}" === path)
}
+ test("SPARK-51830: insertInto with string partition values " +
+ "when validatePartitionColumns is disabled") {
+ withTempDir { base =>
+ val legacyPartitionDir = new java.io.File(base, "p_int=partition_value")
+ legacyPartitionDir.mkdirs()
+ makeParquetFile(
+ (1 to 5).map(i => ParquetData(i, s"str$i")),
+ legacyPartitionDir)
+
+ val df = spark.read.parquet(base.getCanonicalPath)
+ df.createOrReplaceTempView("legacy_table")
+
+ withTempView("legacy_table") {
+ checkAnswer(
+ sql("SELECT * FROM legacy_table"),
+ (1 to 5).map(i => Row(i, s"str$i", "partition_value")))
+
+ val newData = Seq((6, "str6")).toDF("intField", "stringField")
+ intercept[NumberFormatException] {
+ newData.write.mode("append").insertInto("legacy_table")
+ }
+
+ withSQLConf(SQLConf.VALIDATE_PARTITION_COLUMNS.key -> "false") {
+ newData.write.mode("append").insertInto("legacy_table")
+
+ checkAnswer(
+ sql("SELECT * FROM legacy_table ORDER BY intField"),
+ (1 to 6).map(i => Row(i, s"str$i", "partition_value")))
+ }
+ }
+ }
+ }
Review Comment:
@uros-b Thanks for the review, you're right — the earlier tests only covered PartitioningUtils.getPathFragment in isolation. I've added end-to-end coverage in InsertSuite that exercises both call sites changed 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: reviews-unsubscribe@spark.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
Re: [PR] [SPARK-51830][SQL] Fix partition type mismatch when validatePartitionColumns is disabled [spark]
Posted by "pratham76 (via GitHub)" <gi...@apache.org>.
pratham76 commented on PR #57994:
URL: https://github.com/apache/spark/pull/57994#issuecomment-5283926525
@cloud-fan @HyukjinKwon PTAL, 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: reviews-unsubscribe@spark.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
Re: [PR] [SPARK-51830][SQL] Fix partition type mismatch when validatePartitionColumns is disabled [spark]
Posted by "cloud-fan (via GitHub)" <gi...@apache.org>.
cloud-fan closed pull request #57994: [SPARK-51830][SQL] Fix partition type mismatch when validatePartitionColumns is disabled
URL: https://github.com/apache/spark/pull/57994
--
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: reviews-unsubscribe@spark.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
Re: [PR] [SPARK-51830][SQL] Fix partition type mismatch when validatePartitionColumns is disabled [spark]
Posted by "pratham76 (via GitHub)" <gi...@apache.org>.
pratham76 commented on PR #57994:
URL: https://github.com/apache/spark/pull/57994#issuecomment-5748825712
@HyukjinKwon @cloud-fan Could you PTAL? Please do let know if further changes are required, if not could we check this change in? 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: reviews-unsubscribe@spark.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
Re: [PR] [SPARK-51830][SQL] Fix partition type mismatch when validatePartitionColumns is disabled [spark]
Posted by "cloud-fan (via GitHub)" <gi...@apache.org>.
cloud-fan commented on PR #57994:
URL: https://github.com/apache/spark/pull/57994#issuecomment-5750377338
Thanks for the ping. I reviewed the current revision and will post the review outcome separately.
<!-- SPARK_DEV_REVIEW_REPLY {"feedback_id":"conversation:5748825712","thread_id":"conversation:5748825712","verdict_sha256":"20a93f4ab876b4f719f6933704ea86aa59485b58417388ec4ddd4e83c50567e9"} -->
--
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: reviews-unsubscribe@spark.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
Re: [PR] [SPARK-51830][SQL] Fix partition type mismatch when validatePartitionColumns is disabled [spark]
Posted by "HyukjinKwon (via GitHub)" <gi...@apache.org>.
HyukjinKwon commented on PR #57994:
URL: https://github.com/apache/spark/pull/57994#issuecomment-5287319472
Thanks for the fix — the approach looks correct and is backward-compatible. When validation is off, `removeLeadingZerosFromNumberTypePartition` catches `NumberFormatException` and returns the raw value; all six numeric types (`Byte`…`Double`) parse via `Integer.parseInt`/`JLong.parseLong`/`JDouble.parseDouble`, which throw exactly `java.lang.NumberFormatException`, so the `catch` matches precisely without swallowing anything broader, and with validation on (the default) the exception still propagates. A few non-blocking points:
**1. Loop-invariant config read** — `InsertIntoHadoopFsRelationCommand.scala` (`getCustomPartitionLocations`): `conf.validatePartitionColumns` is now evaluated once per partition inside `partitions.flatMap { p => ... }`, but its value can't change during the traversal. Each call is a `SQLConf.get` + `ConcurrentHashMap` lookup, so this repeats per partition. Suggest hoisting it:
```scala
val validatePartitionColumns = conf.validatePartitionColumns
partitions.flatMap { p =>
val defaultLocation = qualifiedOutputPath.suffix(
"/" + PartitioningUtils.getPathFragment(
p.spec, table.partitionSchema, validatePartitionColumns)).toString
...
}
```
(The other new call site, in the static-partition branch, is a single call and is fine.)
**2. Test coverage** — the new tests exercise `PartitioningUtils.getPathFragment` directly, which is good, but not the end-to-end `InsertIntoHadoopFsRelationCommand` insert/refresh path that motivated the ticket. An integration test (INSERT into a partitioned table whose on-disk partition value is a non-numeric string, with `spark.sql.sources.validatePartitionColumns=false`) would guard the actual scenario.
**3. Pre-existing limitation (not introduced here, just flagging)** — the fix rescues values that fail numeric parsing, but a numeric-looking value with leading zeros (e.g. `007`) is still normalized to `7` regardless of the flag, so a legacy directory like `p_int=007` still wouldn't be matched. Worth confirming that isn't part of the reported scenario.
--
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: reviews-unsubscribe@spark.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
Re: [PR] [SPARK-51830][SQL] Fix partition type mismatch when validatePartitionColumns is disabled [spark]
Posted by "pratham76 (via GitHub)" <gi...@apache.org>.
pratham76 commented on PR #57994:
URL: https://github.com/apache/spark/pull/57994#issuecomment-5596271993
@uros-b @HyukjinKwon @cloud-fan Gentle Ping!
--
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: reviews-unsubscribe@spark.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
Re: [PR] [SPARK-51830][SQL] Fix partition type mismatch when validatePartitionColumns is disabled [spark]
Posted by "pratham76 (via GitHub)" <gi...@apache.org>.
pratham76 commented on PR #57994:
URL: https://github.com/apache/spark/pull/57994#issuecomment-5310946599
@HyukjinKwon Could you PTAL? Have addressed your comments. 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: reviews-unsubscribe@spark.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
Re: [PR] [SPARK-51830][SQL] Fix partition type mismatch when validatePartitionColumns is disabled [spark]
Posted by "uros-b (via GitHub)" <gi...@apache.org>.
uros-b commented on code in PR #57994:
URL: https://github.com/apache/spark/pull/57994#discussion_r3801775328
##########
sql/core/src/test/scala/org/apache/spark/sql/execution/datasources/parquet/ParquetPartitionDiscoverySuite.scala:
##########
@@ -1443,6 +1443,40 @@ class ParquetV2PartitionDiscoverySuite extends ParquetPartitionDiscoverySuite {
assert(s"p_int=${ExternalCatalogUtils.DEFAULT_PARTITION_NAME}" === path)
}
+ test("SPARK-51830: insertInto with string partition values " +
+ "when validatePartitionColumns is disabled") {
+ withTempDir { base =>
+ val legacyPartitionDir = new java.io.File(base, "p_int=partition_value")
+ legacyPartitionDir.mkdirs()
+ makeParquetFile(
+ (1 to 5).map(i => ParquetData(i, s"str$i")),
+ legacyPartitionDir)
+
+ val df = spark.read.parquet(base.getCanonicalPath)
+ df.createOrReplaceTempView("legacy_table")
+
+ withTempView("legacy_table") {
+ checkAnswer(
+ sql("SELECT * FROM legacy_table"),
+ (1 to 5).map(i => Row(i, s"str$i", "partition_value")))
+
+ val newData = Seq((6, "str6")).toDF("intField", "stringField")
+ intercept[NumberFormatException] {
+ newData.write.mode("append").insertInto("legacy_table")
+ }
+
+ withSQLConf(SQLConf.VALIDATE_PARTITION_COLUMNS.key -> "false") {
+ newData.write.mode("append").insertInto("legacy_table")
+
+ checkAnswer(
+ sql("SELECT * FROM legacy_table ORDER BY intField"),
+ (1 to 6).map(i => Row(i, s"str$i", "partition_value")))
+ }
+ }
+ }
+ }
+
+
Review Comment:
```suggestion
```
--
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: reviews-unsubscribe@spark.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org