Github user brkyvz commented on the issue:

    https://github.com/apache/spark/pull/16030
  
    @maropu I think I found the simplest fix!
    Would you mind changing:
    
https://github.com/apache/spark/blob/2ab8551e79e1655c406c358b21c0a1e719f498be/sql/core/src/main/scala/org/apache/spark/sql/execution/datasources/DataSource.scala#L180
    to something like:
    ```scala
    val dataSchema = userSpecifiedSchema.orElse {
        format.inferSchema(
          sparkSession,
          caseInsensitiveOptions
          tempFileIndex.allFiles())
    }.getOrElse {
      throw new AnalysisException(
        s"Unable to infer schema for $format. It must be specified manually.")
    }
    val dataWithoutPartitions = dataSchema.filterNot { field =>
      partitionSchema.exists(p => equality(p.name, field.name))
    }
    ```
    What we were missing was removing the partition columns from the data 
schema when we infer the format


---
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 infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org
For additional commands, e-mail: reviews-h...@spark.apache.org

Reply via email to