in backends-velox/src/main/scala/io/glutenproject/backendsapi/velox/VeloxBackend.scala [71:137]
override def supportFileFormatRead(
format: ReadFileFormat,
fields: Array[StructField],
partTable: Boolean,
paths: Seq[String]): ValidationResult = {
// Validate if all types are supported.
def validateTypes(validatorFunc: PartialFunction[StructField, String]): ValidationResult = {
// Collect unsupported types.
val unsupportedDataTypeReason = fields.collect(validatorFunc)
if (unsupportedDataTypeReason.isEmpty) {
ValidationResult.ok
} else {
ValidationResult.notOk(
s"Found unsupported data type in $format: ${unsupportedDataTypeReason.mkString(", ")}.")
}
}
format match {
case ParquetReadFormat =>
val typeValidator: PartialFunction[StructField, String] = {
// Parquet scan of nested array with struct/array as element type is unsupported in Velox.
case StructField(_, arrayType: ArrayType, _, _)
if arrayType.elementType.isInstanceOf[StructType] =>
"StructType as element in ArrayType"
case StructField(_, arrayType: ArrayType, _, _)
if arrayType.elementType.isInstanceOf[ArrayType] =>
"ArrayType as element in ArrayType"
// Parquet scan of nested map with struct as key type,
// or array type as value type is not supported in Velox.
case StructField(_, mapType: MapType, _, _) if mapType.keyType.isInstanceOf[StructType] =>
"StructType as Key in MapType"
case StructField(_, mapType: MapType, _, _)
if mapType.valueType.isInstanceOf[ArrayType] =>
"ArrayType as Value in MapType"
}
validateTypes(typeValidator)
case DwrfReadFormat => ValidationResult.ok
case OrcReadFormat =>
if (!GlutenConfig.getConf.veloxOrcScanEnabled) {
ValidationResult.notOk(s"Velox ORC scan is turned off.")
} else {
val typeValidator: PartialFunction[StructField, String] = {
case StructField(_, ByteType, _, _) => "ByteType not support"
case StructField(_, arrayType: ArrayType, _, _)
if arrayType.elementType.isInstanceOf[StructType] =>
"StructType as element in ArrayType"
case StructField(_, arrayType: ArrayType, _, _)
if arrayType.elementType.isInstanceOf[ArrayType] =>
"ArrayType as element in ArrayType"
case StructField(_, mapType: MapType, _, _)
if mapType.keyType.isInstanceOf[StructType] =>
"StructType as Key in MapType"
case StructField(_, mapType: MapType, _, _)
if mapType.valueType.isInstanceOf[ArrayType] =>
"ArrayType as Value in MapType"
case StructField(_, stringType: StringType, _, metadata)
if CharVarcharUtils
.getRawTypeString(metadata)
.getOrElse(stringType.catalogString) != stringType.catalogString =>
CharVarcharUtils.getRawTypeString(metadata) + " not support"
case StructField(_, TimestampType, _, _) => "TimestampType not support"
}
validateTypes(typeValidator)
}
case _ => ValidationResult.notOk(s"Unsupported file format for $format.")
}
}