Skip to content
Closed
Changes from 1 commit
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
Prev Previous commit
Next Next commit
Modify ArrowUtils to avoid deprecated APIs.
  • Loading branch information
ueshin committed Jul 19, 2017
commit a50a271b2738cf25748f2376935d5b30bf4bc3aa
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import scala.collection.JavaConverters._

import org.apache.arrow.memory.RootAllocator
import org.apache.arrow.vector.types.FloatingPointPrecision
import org.apache.arrow.vector.types.pojo.{ArrowType, Field, Schema}
import org.apache.arrow.vector.types.pojo.{ArrowType, Field, FieldType, Schema}

import org.apache.spark.sql.types._

Expand Down Expand Up @@ -64,15 +64,17 @@ object ArrowUtils {
def toArrowField(name: String, dt: DataType, nullable: Boolean): Field = {
dt match {
case ArrayType(elementType, containsNull) =>
new Field(name, nullable, ArrowType.List.INSTANCE,
Seq(toArrowField("element", elementType, containsNull)).asJava)
val fieldType = new FieldType(nullable, ArrowType.List.INSTANCE, null)
new Field(name, fieldType, Seq(toArrowField("element", elementType, containsNull)).asJava)
case StructType(fields) =>
new Field(name, nullable, ArrowType.Struct.INSTANCE,
val fieldType = new FieldType(nullable, ArrowType.Struct.INSTANCE, null)
new Field(name, fieldType,
fields.map { field =>
toArrowField(field.name, field.dataType, field.nullable)
}.toSeq.asJava)
case dataType =>
new Field(name, nullable, toArrowType(dataType), Seq.empty[Field].asJava)
val fieldType = new FieldType(nullable, toArrowType(dataType), null)
new Field(name, fieldType, Seq.empty[Field].asJava)
}
}

Expand Down