Skip to content

Commit b5dc8e2

Browse files
committed
Code review feedback.
1 parent 5617cf6 commit b5dc8e2

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

sql/core/src/main/scala/org/apache/spark/sql/parquet/newParquet.scala

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ import org.apache.spark.broadcast.Broadcast
3939
import org.apache.spark.deploy.SparkHadoopUtil
4040
import org.apache.spark.rdd.RDD._
4141
import org.apache.spark.rdd.RDD
42+
import org.apache.spark.sql.AnalysisException
4243
import org.apache.spark.sql.sources._
4344
import org.apache.spark.sql.types.{DataType, StructType}
4445
import org.apache.spark.sql.{Row, SQLConf, SQLContext}
@@ -83,7 +84,7 @@ private[sql] class ParquetOutputWriter(path: String, context: TaskAttemptContext
8384
case partFilePattern(id) => id.toInt
8485
case name if name.startsWith("_") => 0
8586
case name if name.startsWith(".") => 0
86-
case name => sys.error(
87+
case name => throw new AnalysisException(
8788
s"Trying to write Parquet files to directory $outputPath, " +
8889
s"but found items with illegal name '$name'.")
8990
}.reduceOption(_ max _).getOrElse(0)
@@ -380,11 +381,12 @@ private[sql] class ParquetRelation2(
380381
// time-consuming.
381382
if (dataSchema == null) {
382383
dataSchema = {
383-
val dataSchema0 =
384-
maybeDataSchema
385-
.orElse(readSchema())
386-
.orElse(maybeMetastoreSchema)
387-
.getOrElse(sys.error("Failed to get the schema."))
384+
val dataSchema0 = maybeDataSchema
385+
.orElse(readSchema())
386+
.orElse(maybeMetastoreSchema)
387+
.getOrElse(throw new AnalysisException(
388+
s"Failed to discover schema of Parquet file(s) in the following location(s):\n" +
389+
paths.mkString("\n\t")))
388390

389391
// If this Parquet relation is converted from a Hive Metastore table, must reconcile case
390392
// case insensitivity issue and possible schema mismatch (probably caused by schema

0 commit comments

Comments
 (0)