Skip to content

Commit b05dbff

Browse files
committed
Provides better error message for malformed rows when caching tables
1 parent f02394d commit b05dbff

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

sql/core/src/main/scala/org/apache/spark/sql/columnar/InMemoryColumnarTableScan.scala

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,17 @@ private[sql] case class InMemoryRelation(
119119
var rowCount = 0
120120
while (rowIterator.hasNext && rowCount < batchSize) {
121121
val row = rowIterator.next()
122+
123+
// Added for SPARK-6082. This assertion can be useful for scenarios when something
124+
// like Hive TRANSFORM is used. The external data generation script used in TRANSFORM
125+
// may result malformed rows, causing ArrayIndexOutOfBoundsException, which is somewhat
126+
// hard to decipher.
127+
assert(
128+
row.size == columnBuilders.size,
129+
s"""Row column number mismatch, expected ${output.size} columns, but got ${row.size}.
130+
|Row content: $row
131+
""".stripMargin)
132+
122133
var i = 0
123134
while (i < row.length) {
124135
columnBuilders(i).appendFrom(row, i)

0 commit comments

Comments
 (0)