[
https://issues.apache.org/jira/browse/ARROW-1361?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16133444#comment-16133444
]
Bryan Cutler commented on ARROW-1361:
-------------------------------------
Thanks for sharing this [~jnadeau]! If I understand correctly, I would need a
visitor to be able to make a call like {{public String getTimezone()}} from the
given ArrowType? That might be too heavyweight for my purposes, but I can see
{{CompleteType}} being useful in some other cases.
My use case is in Spark when constructing type specific writers for a given
{{ValueVector}}. When the vector is a {{NullableTimeStampMicroTZVector}}, I
just want to check the time zone that is set. Here is a code sample of how I
currently do it (pardon the Scala):
{code}
private def createFieldWriter(vector: ValueVector): ArrowFieldWriter = {
vector match {
...
case vector: NullableTimeStampMicroTZVector =>
val field = vector.getField()
val timeZone = field.getType.asInstanceOf[ArrowType.Timestamp].getTimezone
// do something with timeZone
new TimestampWriter(vector)
...
{code}
Since the vector has already been casted, it would be more convenient to just
access the timezone from there instead of having to also cast the type. Then
it would simply to this
{code}
private def createFieldWriter(vector: ValueVector): ArrowFieldWriter = {
vector match {
...
case vector: NullableTimeStampMicroTZVector =>
val timeZone = vector.getTimezone()
// do something with timeZone
new TimestampWriter(vector)
...
{code}
> [Java] Add minor type param accessors to NullableValueVectors
> -------------------------------------------------------------
>
> Key: ARROW-1361
> URL: https://issues.apache.org/jira/browse/ARROW-1361
> Project: Apache Arrow
> Issue Type: Improvement
> Components: Java - Vectors
> Reporter: Bryan Cutler
> Assignee: Bryan Cutler
>
> A {{NullableValueVector}} creates private copies of each param in the minor
> type, but does not have any way public api to access them. So if given a
> {{NullableValueVector}} you would have to use the {{Field}} and cast to the
> correct type. For example, with a {{NullableTimeStampMicroTZVector}} and
> trying to get the timezone:
> {noformat}
> if field.getType.isInstanceOf[ArrowType.Timestamp] &&
> field.getType.asInstanceOf[ArrowType.Timestamp].getTimezone
> {noformat}
> It would be more convenient to have direct accessors for these type params.
> Also, it is possible to do some minor refactoring because
> {{NullableValueVectors}} does not use these type params, so there is no need
> to store them. They already exist in the inner vector object and the Field
> type.
--
This message was sent by Atlassian JIRA
(v6.4.14#64029)