You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@phoenix.apache.org by Chinna ts <gu...@gmail.com> on 2017/11/05 14:59:32 UTC

Phoenix: Convert String column to Integer column

Hi,

I am looking for a Built-in UDF or any other method to convert values of a
string column to integer in my phoenix query for sorting using SELECT and
ORDER BY.

I searched in the apache language Manual, but no use. Any other suggestions
also welcome.

Actual Query

select "values" from "test_table"

I tried below approach but did not work

select TO_NUMBER("values", '\u00A4') from "test_table"

Re: Phoenix: Convert String column to Integer column

Posted by Csaba Skrabak <cs...@hortonworks.com>.
Hi Chinna,

I think that your format string in the second parameter of TO_NUMBER should not be '\u00A4'. The format should be specified with this kind of pattern:

https://docs.oracle.com/javase/7/docs/api/java/text/DecimalFormat.html


Does your "values" column actually contain currency signs (dollar sign) or just the decimal digit characters? The '\u00A4' is for parsing a currency sign. Try '#' if you have just the numeric characters in the column.

select TO_NUMBER("values", '#') from "test_table"






On 05/11/17 15:59, "Chinna ts" <gu...@gmail.com> wrote:

>Hi,
>
>I am looking for a Built-in UDF or any other method to convert values of a
>string column to integer in my phoenix query for sorting using SELECT and
>ORDER BY.
>
>I searched in the apache language Manual, but no use. Any other suggestions
>also welcome.
>
>Actual Query
>
>select "values" from "test_table"
>
>I tried below approach but did not work
>
>select TO_NUMBER("values", '\u00A4') from "test_table"