You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@spark.apache.org by Mohammed Guller <mo...@glassbeam.com> on 2014/10/29 01:03:36 UTC

how to retrieve the value of a column of type date/timestamp from a Spark SQL Row

Hi -

The Spark SQL Row class has methods such as getInt, getLong, getBoolean, getFloat, getDouble, etc. However, I don't see a getDate method. So how can one retrieve a date/timestamp type column from a result set?

Thanks,
Mohammed


RE: how to retrieve the value of a column of type date/timestamp from a Spark SQL Row

Posted by Mohammed Guller <mo...@glassbeam.com>.
Thanks, guys. Michael Armbrust also suggested the same two approaches.

I believe “getAs[Date]” is available only in 1.2 branch and I have Spark 1.1, so I am using row(i).asInstanceOf[Date], which works.

Mohammed

From: Shixiong Zhu [mailto:zsxwing@gmail.com]
Sent: Tuesday, October 28, 2014 10:23 PM
To: Zhan Zhang
Cc: Mohammed Guller; user@spark.apache.org
Subject: Re: how to retrieve the value of a column of type date/timestamp from a Spark SQL Row

Or "def getAs[T](i: Int): T"


Best Regards,
Shixiong Zhu

2014-10-29 13:16 GMT+08:00 Zhan Zhang <zz...@hortonworks.com>>:
Can you use row(i).asInstanceOf[]

Thanks.

Zhan Zhang



On Oct 28, 2014, at 5:03 PM, Mohammed Guller <mo...@glassbeam.com>> wrote:


Hi –

The Spark SQL Row class has methods such as getInt, getLong, getBoolean, getFloat, getDouble, etc. However, I don’t see a getDate method. So how can one retrieve a date/timestamp type column from a result set?

Thanks,
Mohammed


CONFIDENTIALITY NOTICE
NOTICE: This message is intended for the use of the individual or entity to which it is addressed and may contain information that is confidential, privileged and exempt from disclosure under applicable law. If the reader of this message is not the intended recipient, you are hereby notified that any printing, copying, dissemination, distribution, disclosure or forwarding of this communication is strictly prohibited. If you have received this communication in error, please contact the sender immediately and delete it from your system. Thank You.


Re: how to retrieve the value of a column of type date/timestamp from a Spark SQL Row

Posted by Shixiong Zhu <zs...@gmail.com>.
Or "def getAs[T](i: Int): T"

Best Regards,
Shixiong Zhu

2014-10-29 13:16 GMT+08:00 Zhan Zhang <zz...@hortonworks.com>:

> Can you use row(i).asInstanceOf[]
>
> Thanks.
>
> Zhan Zhang
>
>
>
> On Oct 28, 2014, at 5:03 PM, Mohammed Guller <mo...@glassbeam.com>
> wrote:
>
> Hi –
>
> The Spark SQL Row class has methods such as getInt, getLong, getBoolean,
> getFloat, getDouble, etc. However, I don’t see a getDate method. So how can
> one retrieve a date/timestamp type column from a result set?
>
> Thanks,
> Mohammed
>
>
>
> CONFIDENTIALITY NOTICE
> NOTICE: This message is intended for the use of the individual or entity
> to which it is addressed and may contain information that is confidential,
> privileged and exempt from disclosure under applicable law. If the reader
> of this message is not the intended recipient, you are hereby notified that
> any printing, copying, dissemination, distribution, disclosure or
> forwarding of this communication is strictly prohibited. If you have
> received this communication in error, please contact the sender immediately
> and delete it from your system. Thank You.

Re: how to retrieve the value of a column of type date/timestamp from a Spark SQL Row

Posted by Zhan Zhang <zz...@hortonworks.com>.
Can you use row(i).asInstanceOf[]

Thanks.

Zhan Zhang


On Oct 28, 2014, at 5:03 PM, Mohammed Guller <mo...@glassbeam.com> wrote:

> Hi –
>  
> The Spark SQL Row class has methods such as getInt, getLong, getBoolean, getFloat, getDouble, etc. However, I don’t see a getDate method. So how can one retrieve a date/timestamp type column from a result set?
>  
> Thanks,
> Mohammed


-- 
CONFIDENTIALITY NOTICE
NOTICE: This message is intended for the use of the individual or entity to 
which it is addressed and may contain information that is confidential, 
privileged and exempt from disclosure under applicable law. If the reader 
of this message is not the intended recipient, you are hereby notified that 
any printing, copying, dissemination, distribution, disclosure or 
forwarding of this communication is strictly prohibited. If you have 
received this communication in error, please contact the sender immediately 
and delete it from your system. Thank You.