Github user liancheng commented on a diff in the pull request:
https://github.com/apache/spark/pull/5298#discussion_r28241260
--- Diff:
sql/core/src/main/scala/org/apache/spark/sql/parquet/ParquetTableSupport.scala
---
@@ -98,12 +98,32 @@ private[parquet] class RowReadSupport extends
ReadSupport[Row] with Logging {
val metadata = new JHashMap[String, String]()
val requestedAttributes =
RowReadSupport.getRequestedSchema(configuration)
+ // convert fileSchema to attributes
+ val fileAttributes =
ParquetTypesConverter.convertToAttributes(fileSchema, true, true)
+ val fileAttMap = fileAttributes.map(f => f.name.toLowerCase ->
f.name).toMap
+
if (requestedAttributes != null) {
+ // reconcile names of requested Attributes
+ val modRequestedAttributes = requestedAttributes.map(attr => {
+ val lName = attr.name.toLowerCase
+ if (fileAttMap.contains(lName)) {
+ attr.withName(fileAttMap(lName))
+ } else {
+ if (attr.nullable) {
+ attr
+ } else {
+ // field is not nullable but not present in the parquet file
schema!!
+ // this is just a safety check since in hive all columns are
nullable
+ // throw exception here
+ throw new RuntimeException(s"""Field ${attr.name} is
non-nullable,
+ but not found in parquet file schema:
${fileSchema}""".stripMargin)
--- End diff --
This exception message would look pretty weird when printed since there
isn't a "margin" character (`|`) in the string. Also we don't want to split
this message into multiple lines. Maybe this:
```scala
throw new RuntimeException(
s"Field ${attr.name} is non-nullable, " +
s"but not found in parquet file schema: ${fileSchema}")
```
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]