Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,8 @@ private[avro] class AvroFileFormat extends FileFormat

override def shortName(): String = "avro"

override def toString(): String = "Avro"

override def isSplitable(
sparkSession: SparkSession,
options: Map[String, String],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -896,7 +896,7 @@ class AvroSuite extends QueryTest with SharedSQLContext with SQLTestUtils {
sql("select testType()").write.format("avro").mode("overwrite").save(tempDir)
}.getMessage
assert(msg.toLowerCase(Locale.ROOT)
.contains(s"data source does not support calendarinterval data type."))
.contains(s"avro data source does not support calendarinterval data type."))
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -412,7 +412,7 @@ case class DataSource(
hs.partitionSchema.map(_.name),
"in the partition schema",
equality)
DataSourceUtils.verifyReadSchema(hs.fileFormat, hs.dataSchema)
DataSourceUtils.verifySchema(hs.fileFormat, hs.dataSchema)
case _ =>
SchemaUtils.checkColumnNameDuplication(
relation.schema.map(_.name),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,26 +24,11 @@ import org.apache.spark.sql.types._


object DataSourceUtils {

/**
* Verify if the schema is supported in datasource in write path.
*/
def verifyWriteSchema(format: FileFormat, schema: StructType): Unit = {
verifySchema(format, schema, isReadPath = false)
}

/**
* Verify if the schema is supported in datasource in read path.
*/
def verifyReadSchema(format: FileFormat, schema: StructType): Unit = {
verifySchema(format, schema, isReadPath = true)
}

/**
* Verify if the schema is supported in datasource. This verification should be done
* in a driver side.
*/
private def verifySchema(format: FileFormat, schema: StructType, isReadPath: Boolean): Unit = {
def verifySchema(format: FileFormat, schema: StructType): Unit = {
schema.foreach { field =>
if (!format.supportDataType(field.dataType)) {
throw new AnalysisException(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ object FileFormatWriter extends Logging {
val caseInsensitiveOptions = CaseInsensitiveMap(options)

val dataSchema = dataColumns.toStructType
DataSourceUtils.verifyWriteSchema(fileFormat, dataSchema)
DataSourceUtils.verifySchema(fileFormat, dataSchema)
// Note: prepareWrite has side effect. It sets "job".
val outputWriterFactory =
fileFormat.prepareWrite(sparkSession, job, caseInsensitiveOptions, dataSchema)
Expand Down