Skip to content
Snippets Groups Projects
Commit b5f8c36e authored by Sameer Agarwal's avatar Sameer Agarwal Committed by Yin Huai
Browse files

[SPARK-14144][SQL] Explicitly identify/catch UnsupportedOperationException...

[SPARK-14144][SQL] Explicitly identify/catch UnsupportedOperationException during parquet reader initialization

## What changes were proposed in this pull request?

This PR is a minor cleanup task as part of https://issues.apache.org/jira/browse/SPARK-14008 to explicitly identify/catch the `UnsupportedOperationException` while initializing the vectorized parquet reader. Other exceptions will simply be thrown back to `SqlNewHadoopPartition`.

## How was this patch tested?

N/A (cleanup only; no new functionality added)

Author: Sameer Agarwal <sameer@databricks.com>

Closes #11950 from sameeragarwal/parquet-cleanup.
parent 43b15e01
No related branches found
No related tags found
No related merge requests found
......@@ -104,11 +104,12 @@ public class VectorizedParquetRecordReader extends SpecificParquetRecordReaderBa
* Tries to initialize the reader for this split. Returns true if this reader supports reading
* this split and false otherwise.
*/
public boolean tryInitialize(InputSplit inputSplit, TaskAttemptContext taskAttemptContext) {
public boolean tryInitialize(InputSplit inputSplit, TaskAttemptContext taskAttemptContext)
throws IOException, InterruptedException {
try {
initialize(inputSplit, taskAttemptContext);
return true;
} catch (Exception e) {
} catch (UnsupportedOperationException e) {
return false;
}
}
......@@ -118,7 +119,7 @@ public class VectorizedParquetRecordReader extends SpecificParquetRecordReaderBa
*/
@Override
public void initialize(InputSplit inputSplit, TaskAttemptContext taskAttemptContext)
throws IOException, InterruptedException {
throws IOException, InterruptedException, UnsupportedOperationException {
super.initialize(inputSplit, taskAttemptContext);
initializeInternal();
}
......@@ -128,7 +129,8 @@ public class VectorizedParquetRecordReader extends SpecificParquetRecordReaderBa
* objects to use this class. `columns` can contain the list of columns to project.
*/
@Override
public void initialize(String path, List<String> columns) throws IOException {
public void initialize(String path, List<String> columns) throws IOException,
UnsupportedOperationException {
super.initialize(path, columns);
initializeInternal();
}
......@@ -248,7 +250,7 @@ public class VectorizedParquetRecordReader extends SpecificParquetRecordReaderBa
return true;
}
private void initializeInternal() throws IOException {
private void initializeInternal() throws IOException, UnsupportedOperationException {
/**
* Check that the requested schema is supported.
*/
......@@ -256,14 +258,14 @@ public class VectorizedParquetRecordReader extends SpecificParquetRecordReaderBa
for (int i = 0; i < requestedSchema.getFieldCount(); ++i) {
Type t = requestedSchema.getFields().get(i);
if (!t.isPrimitive() || t.isRepetition(Type.Repetition.REPEATED)) {
throw new IOException("Complex types not supported.");
throw new UnsupportedOperationException("Complex types not supported.");
}
String[] colPath = requestedSchema.getPaths().get(i);
if (fileSchema.containsPath(colPath)) {
ColumnDescriptor fd = fileSchema.getColumnDescription(colPath);
if (!fd.equals(requestedSchema.getColumns().get(i))) {
throw new IOException("Schema evolution not supported.");
throw new UnsupportedOperationException("Schema evolution not supported.");
}
missingColumns[i] = false;
} else {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment