Github user hvanhovell commented on a diff in the pull request:
https://github.com/apache/spark/pull/20981#discussion_r180008583
--- Diff: sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/InternalRow.scala
---
@@ -119,4 +119,25 @@ object InternalRow {
case v: MapData => v.copy()
case _ => value
}
+
+ /**
+ * Returns an accessor for an InternalRow with given data type and ordinal.
+ */
+ def getAccessor(dataType: DataType, ordinal: Int): (InternalRow) => Any = dataType
match {
+ case BooleanType => (input) => input.getBoolean(ordinal)
+ case ByteType => (input) => input.getByte(ordinal)
+ case ShortType => (input) => input.getShort(ordinal)
+ case IntegerType | DateType => (input) => input.getInt(ordinal)
+ case LongType | TimestampType => (input) => input.getLong(ordinal)
+ case FloatType => (input) => input.getFloat(ordinal)
+ case DoubleType => (input) => input.getDouble(ordinal)
+ case StringType => (input) => input.getUTF8String(ordinal)
+ case BinaryType => (input) => input.getBinary(ordinal)
+ case CalendarIntervalType => (input) => input.getInterval(ordinal)
+ case t: DecimalType => (input) => input.getDecimal(ordinal, t.precision, t.scale)
+ case t: StructType => (input) => input.getStruct(ordinal, t.size)
+ case _: ArrayType => (input) => input.getArray(ordinal)
+ case _: MapType => (input) => input.getMap(ordinal)
+ case _ => (input) => input.get(ordinal, dataType)
--- End diff --
Handle `UDT`?
---
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
|