You are viewing a plain text version of this content. The canonical link for it is here.
Posted to reviews@spark.apache.org by "leonwind (via GitHub)" <gi...@apache.org> on 2026/02/03 17:22:27 UTC
[PR] [SPARK-55340][SQL] Add helper for name to data type [spark]
leonwind opened a new pull request, #54117:
URL: https://github.com/apache/spark/pull/54117
### What changes were proposed in this pull request?
Adding a helper for `StructType` for mapping the names to their data types.
### Why are the changes needed?
### Does this PR introduce _any_ user-facing change?
No
### How was this patch tested?
NA
### Was this patch authored or co-authored using generative AI tooling?
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-55340][SQL] Add helper for name to data type [spark]
Posted by "HyukjinKwon (via GitHub)" <gi...@apache.org>.
HyukjinKwon commented on PR #54117:
URL: https://github.com/apache/spark/pull/54117#issuecomment-3850424365
Merged 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.
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-55340][SQL] Add helper for name to data type [spark]
Posted by "HyukjinKwon (via GitHub)" <gi...@apache.org>.
HyukjinKwon closed pull request #54117: [SPARK-55340][SQL] Add helper for name to data type
URL: https://github.com/apache/spark/pull/54117
--
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-55340][SQL] Add helper for name to data type [spark]
Posted by "HyukjinKwon (via GitHub)" <gi...@apache.org>.
HyukjinKwon commented on code in PR #54117:
URL: https://github.com/apache/spark/pull/54117#discussion_r2766529115
##########
sql/api/src/main/scala/org/apache/spark/sql/types/StructType.scala:
##########
@@ -122,6 +122,10 @@ case class StructType(fields: Array[StructField]) extends DataType with Seq[Stru
private lazy val nameToIndex: Map[String, Int] = SparkCollectionUtils.toMapWithIndex(fieldNames)
private lazy val nameToIndexCaseInsensitive: CaseInsensitiveMap[Int] =
CaseInsensitiveMap[Int](nameToIndex.toMap)
+ lazy val nameToDataType: collection.immutable.Map[String, DataType] =
+ fields.map(f => f.name -> f.dataType).toMap
Review Comment:
StructType itself is `Seq[StructField]` so you can just do `s.map(f => f.name -> f.dataType)` which I don't think it's worth as an API.
##########
sql/api/src/main/scala/org/apache/spark/sql/types/StructType.scala:
##########
@@ -122,6 +122,10 @@ case class StructType(fields: Array[StructField]) extends DataType with Seq[Stru
private lazy val nameToIndex: Map[String, Int] = SparkCollectionUtils.toMapWithIndex(fieldNames)
private lazy val nameToIndexCaseInsensitive: CaseInsensitiveMap[Int] =
CaseInsensitiveMap[Int](nameToIndex.toMap)
+ lazy val nameToDataType: collection.immutable.Map[String, DataType] =
+ fields.map(f => f.name -> f.dataType).toMap
Review Comment:
StructType itself is `Seq[StructField]` so you can just do `s.map(f => f.name -> f.dataType)` which I don't think it's worth as an API.
--
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-55340][SQL] Add helper for name to data type [spark]
Posted by "github-actions[bot] (via GitHub)" <gi...@apache.org>.
github-actions[bot] commented on PR #54117:
URL: https://github.com/apache/spark/pull/54117#issuecomment-3842628813
## JIRA Issue Information
=== Improvement SPARK-55340 ===
Summary: Introduce helper for StructType for mapping names to datatypes
Assignee: None
Status: Open
Affected: ["4.1.1"]
---
*This comment was automatically generated by GitHub Actions*
--
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