Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add shims to compare ORC TypeDescription [databricks] #4786

Merged
merged 1 commit into from
Feb 15, 2022
Merged
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 @@ -20,7 +20,7 @@ import scala.collection.mutable.ArrayBuffer
import com.nvidia.spark.rapids.OrcOutputStripe
import org.apache.hadoop.conf.Configuration
import org.apache.hadoop.hive.common.io.DiskRangeList
import org.apache.orc.{CompressionCodec, CompressionKind, DataReader, OrcFile, OrcProto, PhysicalWriter, Reader, StripeInformation}
import org.apache.orc.{CompressionCodec, CompressionKind, DataReader, OrcFile, OrcProto, PhysicalWriter, Reader, StripeInformation, TypeDescription}
import org.apache.orc.impl.{DataReaderProperties, OutStream, SchemaEvolution}
import org.apache.orc.impl.RecordReaderImpl.SargApplier

Expand Down Expand Up @@ -84,4 +84,11 @@ trait OrcShims301until320Base {
}
result
}

/**
* Compare if the two TypeDescriptions are equal by ignoring attribute
*/
def typeDescriptionEqual(lhs: TypeDescription, rhs: TypeDescription): Boolean = {
lhs.equals(rhs)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import com.nvidia.spark.rapids.OrcOutputStripe
import com.nvidia.spark.rapids.RapidsPluginImplicits._
import org.apache.hadoop.conf.Configuration
import org.apache.hadoop.hive.common.io.DiskRangeList
import org.apache.orc.{CompressionCodec, CompressionKind, DataReader, OrcConf, OrcFile, OrcProto, PhysicalWriter, Reader, StripeInformation}
import org.apache.orc.{CompressionCodec, CompressionKind, DataReader, OrcConf, OrcFile, OrcProto, PhysicalWriter, Reader, StripeInformation, TypeDescription}
import org.apache.orc.impl.{BufferChunk, BufferChunkList, DataReaderProperties, InStream, OrcCodecPool, OutStream, ReaderImpl, SchemaEvolution}
import org.apache.orc.impl.RecordReaderImpl.SargApplier
import org.apache.orc.impl.reader.StripePlanner
Expand Down Expand Up @@ -120,4 +120,11 @@ object OrcShims {
result

}

/**
* Compare if the two TypeDescriptions are equal by ignoring attribute
*/
def typeDescriptionEqual(lhs: TypeDescription, rhs: TypeDescription): Boolean = {
lhs.equals(rhs, false)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -1224,7 +1224,7 @@ private case class GpuOrcFileFilterHandler(
newUnion
// Primitive types should be equal to each other.
case _ =>
if (fileSchema != readSchema) {
if (!OrcShims.typeDescriptionEqual(fileSchema, readSchema)) {
throw new QueryExecutionException("Incompatible schemas for ORC file" +
s" at ${partFile.filePath}\n" +
s" file schema: $fileSchema\n" +
Expand Down