spark-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Mich Talebzadeh <mich.talebza...@gmail.com>
Subject Re: This simple UDF is not working!
Date Fri, 25 Mar 2016 14:59:25 GMT
This works with sql

sqltext = """
INSERT INTO TABLE t14
SELECT
          INVOICENUMBER
        ,
TO_DATE(FROM_UNIXTIME(UNIX_TIMESTAMP(paymentdate,'dd/MM/yyyy'),'yyyy-MM-dd'))
AS paymentdate
        , NET
        , VAT
        , TOTAL
FROM tmp
"""
sql(sqltext)


but not in UDF.  I want to convert it to correct date format  before
writing it to table

Thanks



Dr Mich Talebzadeh



LinkedIn * https://www.linkedin.com/profile/view?id=AAEAAAAWh2gBxianrbJd6zP6AcPCCdOABUrV8Pw
<https://www.linkedin.com/profile/view?id=AAEAAAAWh2gBxianrbJd6zP6AcPCCdOABUrV8Pw>*



http://talebzadehmich.wordpress.com



On 25 March 2016 at 14:54, Ted Yu <yuzhihong@gmail.com> wrote:

> Do you mind showing body of TO_DATE() ?
>
> Thanks
>
> On Fri, Mar 25, 2016 at 7:38 AM, Ted Yu <yuzhihong@gmail.com> wrote:
>
>> Looks like you forgot an import for Date.
>>
>> FYI
>>
>> On Fri, Mar 25, 2016 at 7:36 AM, Mich Talebzadeh <
>> mich.talebzadeh@gmail.com> wrote:
>>
>>>
>>>
>>> Hi,
>>>
>>> writing a UDF to convert  a string into Date
>>>
>>> def ChangeDate(word : String) : Date = {
>>>      | return
>>> TO_DATE(FROM_UNIXTIME(UNIX_TIMESTAMP(word),"dd/MM/yyyy"),"yyyy-MM-dd")
>>>      | }
>>> <console>:19: error: not found: type Date
>>>
>>> That code to_date.. works OK in sql but not here. It is complaining
>>> about to_date?
>>>
>>> Any ideas will be appreciated.
>>>
>>> Thanks,
>>>
>>>
>>> Dr Mich Talebzadeh
>>>
>>>
>>>
>>> LinkedIn * https://www.linkedin.com/profile/view?id=AAEAAAAWh2gBxianrbJd6zP6AcPCCdOABUrV8Pw
>>> <https://www.linkedin.com/profile/view?id=AAEAAAAWh2gBxianrbJd6zP6AcPCCdOABUrV8Pw>*
>>>
>>>
>>>
>>> http://talebzadehmich.wordpress.com
>>>
>>>
>>>
>>
>>
>

Mime
View raw message