You are viewing a plain text version of this content. The canonical link for it is here.
Posted to reviews@spark.apache.org by GitBox <gi...@apache.org> on 2020/11/23 19:58:34 UTC
[GitHub] [spark] MaxGekk opened a new pull request #30474: [SPARK-33521][SQL] Universal type conversion in resolving V2 partition specs
MaxGekk opened a new pull request #30474:
URL: https://github.com/apache/spark/pull/30474
### What changes were proposed in this pull request?
In the PR, I propose to changes the resolver of partition specs used in V2 `ALTER TABLE .. ADD/DROP PARTITION` (at the moment), and re-use `CAST` in conversion partition values to desired types according to the partition schema.
### Why are the changes needed?
Currently, the resolver of V2 partition specs supports just a few types: https://github.com/apache/spark/blob/23e9920b3910e4f05269853429c7f18888cdc7b5/sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/analysis/ResolvePartitionSpec.scala#L72, and fails on other types like date/timestamp.
### Does this PR introduce _any_ user-facing change?
Yes
### How was this patch tested?
By running `AlterTablePartitionV2SQLSuite`
----------------------------------------------------------------
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.
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
[GitHub] [spark] MaxGekk commented on a change in pull request #30474: [SPARK-33521][SQL] Universal type conversion in resolving V2 partition specs
Posted by GitBox <gi...@apache.org>.
MaxGekk commented on a change in pull request #30474:
URL: https://github.com/apache/spark/pull/30474#discussion_r529214126
##########
File path: sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/analysis/ResolvePartitionSpec.scala
##########
@@ -65,31 +65,8 @@ object ResolvePartitionSpec extends Rule[LogicalPlan] {
conf.resolver)
val partValues = partSchema.map { part =>
- val partValue = normalizedSpec.get(part.name).orNull
- if (partValue == null) {
- null
- } else {
- // TODO: Support other datatypes, such as DateType
- part.dataType match {
- case _: ByteType =>
- partValue.toByte
- case _: ShortType =>
- partValue.toShort
- case _: IntegerType =>
- partValue.toInt
- case _: LongType =>
- partValue.toLong
- case _: FloatType =>
- partValue.toFloat
- case _: DoubleType =>
- partValue.toDouble
- case _: StringType =>
- partValue
- case _ =>
- throw new AnalysisException(
- s"Type ${part.dataType.typeName} is not supported for partition.")
- }
- }
+ val raw = normalizedSpec.get(part.name).orNull
+ Cast(Literal.create(raw, StringType), part.dataType, Some(conf.sessionLocalTimeZone)).eval()
Review comment:
We don't have unified tests for V1 and V2 `ALTER TABLE .. ADD/DROP PARTITION` at the moment. I plan to do that soon. As soon as we have such tests we will see the differences and fix them.
For now, I just try to make implementation simpler - cast partition values according to the partition schema.
----------------------------------------------------------------
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.
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
[GitHub] [spark] SparkQA commented on pull request #30474: [SPARK-33521][SQL] Universal type conversion in resolving V2 partition specs
Posted by GitBox <gi...@apache.org>.
SparkQA commented on pull request #30474:
URL: https://github.com/apache/spark/pull/30474#issuecomment-732394889
**[Test build #131572 has started](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/131572/testReport)** for PR 30474 at commit [`d0108e0`](https://github.com/apache/spark/commit/d0108e097ccbd0531f5189750c129855c97f7378).
----------------------------------------------------------------
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.
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
[GitHub] [spark] MaxGekk commented on a change in pull request #30474: [SPARK-33521][SQL] Universal type conversion in resolving V2 partition specs
Posted by GitBox <gi...@apache.org>.
MaxGekk commented on a change in pull request #30474:
URL: https://github.com/apache/spark/pull/30474#discussion_r529375116
##########
File path: sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/analysis/ResolvePartitionSpec.scala
##########
@@ -65,31 +65,8 @@ object ResolvePartitionSpec extends Rule[LogicalPlan] {
conf.resolver)
val partValues = partSchema.map { part =>
- val partValue = normalizedSpec.get(part.name).orNull
- if (partValue == null) {
- null
- } else {
- // TODO: Support other datatypes, such as DateType
- part.dataType match {
- case _: ByteType =>
- partValue.toByte
- case _: ShortType =>
- partValue.toShort
- case _: IntegerType =>
- partValue.toInt
- case _: LongType =>
- partValue.toLong
- case _: FloatType =>
- partValue.toFloat
- case _: DoubleType =>
- partValue.toDouble
- case _: StringType =>
- partValue
- case _ =>
- throw new AnalysisException(
- s"Type ${part.dataType.typeName} is not supported for partition.")
- }
- }
+ val raw = normalizedSpec.get(part.name).orNull
+ Cast(Literal.create(raw, StringType), part.dataType, Some(conf.sessionLocalTimeZone)).eval()
Review comment:
I reused the code from DSv1 https://github.com/apache/spark/pull/30482 and fixed an issue. @HyukjinKwon Please, review it.
----------------------------------------------------------------
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.
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
[GitHub] [spark] AmplabJenkins removed a comment on pull request #30474: [SPARK-33521][SQL] Universal type conversion in resolving V2 partition specs
Posted by GitBox <gi...@apache.org>.
AmplabJenkins removed a comment on pull request #30474:
URL: https://github.com/apache/spark/pull/30474#issuecomment-732536783
----------------------------------------------------------------
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.
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
[GitHub] [spark] MaxGekk commented on a change in pull request #30474: [SPARK-33521][SQL] Universal type conversion in resolving V2 partition specs
Posted by GitBox <gi...@apache.org>.
MaxGekk commented on a change in pull request #30474:
URL: https://github.com/apache/spark/pull/30474#discussion_r529375116
##########
File path: sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/analysis/ResolvePartitionSpec.scala
##########
@@ -65,31 +65,8 @@ object ResolvePartitionSpec extends Rule[LogicalPlan] {
conf.resolver)
val partValues = partSchema.map { part =>
- val partValue = normalizedSpec.get(part.name).orNull
- if (partValue == null) {
- null
- } else {
- // TODO: Support other datatypes, such as DateType
- part.dataType match {
- case _: ByteType =>
- partValue.toByte
- case _: ShortType =>
- partValue.toShort
- case _: IntegerType =>
- partValue.toInt
- case _: LongType =>
- partValue.toLong
- case _: FloatType =>
- partValue.toFloat
- case _: DoubleType =>
- partValue.toDouble
- case _: StringType =>
- partValue
- case _ =>
- throw new AnalysisException(
- s"Type ${part.dataType.typeName} is not supported for partition.")
- }
- }
+ val raw = normalizedSpec.get(part.name).orNull
+ Cast(Literal.create(raw, StringType), part.dataType, Some(conf.sessionLocalTimeZone)).eval()
Review comment:
I reused the code from DSv1 https://github.com/apache/spark/pull/30482 and fixed an issue.
----------------------------------------------------------------
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.
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
[GitHub] [spark] MaxGekk commented on a change in pull request #30474: [SPARK-33521][SQL] Universal type conversion in resolving V2 partition specs
Posted by GitBox <gi...@apache.org>.
MaxGekk commented on a change in pull request #30474:
URL: https://github.com/apache/spark/pull/30474#discussion_r529228577
##########
File path: sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/analysis/ResolvePartitionSpec.scala
##########
@@ -65,31 +65,8 @@ object ResolvePartitionSpec extends Rule[LogicalPlan] {
conf.resolver)
val partValues = partSchema.map { part =>
- val partValue = normalizedSpec.get(part.name).orNull
- if (partValue == null) {
- null
- } else {
- // TODO: Support other datatypes, such as DateType
- part.dataType match {
- case _: ByteType =>
- partValue.toByte
- case _: ShortType =>
- partValue.toShort
- case _: IntegerType =>
- partValue.toInt
- case _: LongType =>
- partValue.toLong
- case _: FloatType =>
- partValue.toFloat
- case _: DoubleType =>
- partValue.toDouble
- case _: StringType =>
- partValue
- case _ =>
- throw new AnalysisException(
- s"Type ${part.dataType.typeName} is not supported for partition.")
- }
- }
+ val raw = normalizedSpec.get(part.name).orNull
+ Cast(Literal.create(raw, StringType), part.dataType, Some(conf.sessionLocalTimeZone)).eval()
Review comment:
I think V1 does the same, see https://github.com/apache/spark/blob/dfa6fb46f4238792bff6a0201da201be1b42620e/sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/catalog/interface.scala#L149-L165
Let me extract the code to `PartitioningUtils`, and re-use it in V2.
----------------------------------------------------------------
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.
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
[GitHub] [spark] HyukjinKwon commented on a change in pull request #30474: [SPARK-33521][SQL] Universal type conversion in resolving V2 partition specs
Posted by GitBox <gi...@apache.org>.
HyukjinKwon commented on a change in pull request #30474:
URL: https://github.com/apache/spark/pull/30474#discussion_r529235952
##########
File path: sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/analysis/ResolvePartitionSpec.scala
##########
@@ -65,31 +65,8 @@ object ResolvePartitionSpec extends Rule[LogicalPlan] {
conf.resolver)
val partValues = partSchema.map { part =>
- val partValue = normalizedSpec.get(part.name).orNull
- if (partValue == null) {
- null
- } else {
- // TODO: Support other datatypes, such as DateType
- part.dataType match {
- case _: ByteType =>
- partValue.toByte
- case _: ShortType =>
- partValue.toShort
- case _: IntegerType =>
- partValue.toInt
- case _: LongType =>
- partValue.toLong
- case _: FloatType =>
- partValue.toFloat
- case _: DoubleType =>
- partValue.toDouble
- case _: StringType =>
- partValue
- case _ =>
- throw new AnalysisException(
- s"Type ${part.dataType.typeName} is not supported for partition.")
- }
- }
+ val raw = normalizedSpec.get(part.name).orNull
+ Cast(Literal.create(raw, StringType), part.dataType, Some(conf.sessionLocalTimeZone)).eval()
Review comment:
Gotya
----------------------------------------------------------------
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.
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
[GitHub] [spark] SparkQA commented on pull request #30474: [SPARK-33521][SQL] Universal type conversion in resolving V2 partition specs
Posted by GitBox <gi...@apache.org>.
SparkQA commented on pull request #30474:
URL: https://github.com/apache/spark/pull/30474#issuecomment-732415425
Kubernetes integration test starting
URL: https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder-K8s/36173/
----------------------------------------------------------------
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.
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
[GitHub] [spark] SparkQA commented on pull request #30474: [SPARK-33521][SQL] Universal type conversion in resolving V2 partition specs
Posted by GitBox <gi...@apache.org>.
SparkQA commented on pull request #30474:
URL: https://github.com/apache/spark/pull/30474#issuecomment-732501431
**[Test build #131579 has started](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/131579/testReport)** for PR 30474 at commit [`d0108e0`](https://github.com/apache/spark/commit/d0108e097ccbd0531f5189750c129855c97f7378).
----------------------------------------------------------------
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.
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
[GitHub] [spark] AmplabJenkins commented on pull request #30474: [SPARK-33521][SQL] Universal type conversion in resolving V2 partition specs
Posted by GitBox <gi...@apache.org>.
AmplabJenkins commented on pull request #30474:
URL: https://github.com/apache/spark/pull/30474#issuecomment-732536783
----------------------------------------------------------------
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.
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
[GitHub] [spark] SparkQA commented on pull request #30474: [SPARK-33521][SQL] Universal type conversion in resolving V2 partition specs
Posted by GitBox <gi...@apache.org>.
SparkQA commented on pull request #30474:
URL: https://github.com/apache/spark/pull/30474#issuecomment-732426120
Kubernetes integration test status success
URL: https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder-K8s/36173/
----------------------------------------------------------------
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.
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
[GitHub] [spark] SparkQA commented on pull request #30474: [SPARK-33521][SQL] Universal type conversion in resolving V2 partition specs
Posted by GitBox <gi...@apache.org>.
SparkQA commented on pull request #30474:
URL: https://github.com/apache/spark/pull/30474#issuecomment-732672385
**[Test build #131579 has finished](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/131579/testReport)** for PR 30474 at commit [`d0108e0`](https://github.com/apache/spark/commit/d0108e097ccbd0531f5189750c129855c97f7378).
* This patch passes all tests.
* This patch merges cleanly.
* This patch adds no public classes.
----------------------------------------------------------------
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.
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
[GitHub] [spark] AmplabJenkins removed a comment on pull request #30474: [SPARK-33521][SQL] Universal type conversion in resolving V2 partition specs
Posted by GitBox <gi...@apache.org>.
AmplabJenkins removed a comment on pull request #30474:
URL: https://github.com/apache/spark/pull/30474#issuecomment-732426141
----------------------------------------------------------------
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.
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
[GitHub] [spark] AmplabJenkins commented on pull request #30474: [SPARK-33521][SQL] Universal type conversion in resolving V2 partition specs
Posted by GitBox <gi...@apache.org>.
AmplabJenkins commented on pull request #30474:
URL: https://github.com/apache/spark/pull/30474#issuecomment-732426141
----------------------------------------------------------------
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.
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
[GitHub] [spark] AmplabJenkins commented on pull request #30474: [SPARK-33521][SQL] Universal type conversion in resolving V2 partition specs
Posted by GitBox <gi...@apache.org>.
AmplabJenkins commented on pull request #30474:
URL: https://github.com/apache/spark/pull/30474#issuecomment-732673371
----------------------------------------------------------------
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.
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
[GitHub] [spark] SparkQA removed a comment on pull request #30474: [SPARK-33521][SQL] Universal type conversion in resolving V2 partition specs
Posted by GitBox <gi...@apache.org>.
SparkQA removed a comment on pull request #30474:
URL: https://github.com/apache/spark/pull/30474#issuecomment-732501431
**[Test build #131579 has started](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/131579/testReport)** for PR 30474 at commit [`d0108e0`](https://github.com/apache/spark/commit/d0108e097ccbd0531f5189750c129855c97f7378).
----------------------------------------------------------------
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.
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
[GitHub] [spark] cloud-fan closed pull request #30474: [SPARK-33521][SQL] Universal type conversion in resolving V2 partition specs
Posted by GitBox <gi...@apache.org>.
cloud-fan closed pull request #30474:
URL: https://github.com/apache/spark/pull/30474
----------------------------------------------------------------
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.
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
[GitHub] [spark] AmplabJenkins removed a comment on pull request #30474: [SPARK-33521][SQL] Universal type conversion in resolving V2 partition specs
Posted by GitBox <gi...@apache.org>.
AmplabJenkins removed a comment on pull request #30474:
URL: https://github.com/apache/spark/pull/30474#issuecomment-732673371
----------------------------------------------------------------
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.
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
[GitHub] [spark] cloud-fan commented on pull request #30474: [SPARK-33521][SQL] Universal type conversion in resolving V2 partition specs
Posted by GitBox <gi...@apache.org>.
cloud-fan commented on pull request #30474:
URL: https://github.com/apache/spark/pull/30474#issuecomment-732726529
thanks, merging to master!
----------------------------------------------------------------
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.
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
[GitHub] [spark] HyukjinKwon commented on a change in pull request #30474: [SPARK-33521][SQL] Universal type conversion in resolving V2 partition specs
Posted by GitBox <gi...@apache.org>.
HyukjinKwon commented on a change in pull request #30474:
URL: https://github.com/apache/spark/pull/30474#discussion_r529103627
##########
File path: sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/analysis/ResolvePartitionSpec.scala
##########
@@ -65,31 +65,8 @@ object ResolvePartitionSpec extends Rule[LogicalPlan] {
conf.resolver)
val partValues = partSchema.map { part =>
- val partValue = normalizedSpec.get(part.name).orNull
- if (partValue == null) {
- null
- } else {
- // TODO: Support other datatypes, such as DateType
- part.dataType match {
- case _: ByteType =>
- partValue.toByte
- case _: ShortType =>
- partValue.toShort
- case _: IntegerType =>
- partValue.toInt
- case _: LongType =>
- partValue.toLong
- case _: FloatType =>
- partValue.toFloat
- case _: DoubleType =>
- partValue.toDouble
- case _: StringType =>
- partValue
- case _ =>
- throw new AnalysisException(
- s"Type ${part.dataType.typeName} is not supported for partition.")
- }
- }
+ val raw = normalizedSpec.get(part.name).orNull
+ Cast(Literal.create(raw, StringType), part.dataType, Some(conf.sessionLocalTimeZone)).eval()
Review comment:
Is this matched to the V1 partitioning type coercion? I remember it has a bit different rules, see `PartitioningUtils.inferPartitionColumnValue`.
----------------------------------------------------------------
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.
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