[
https://issues.apache.org/jira/browse/PHOENIX-995?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14016144#comment-14016144
]
Thomas D'Silva commented on PHOENIX-995:
----------------------------------------
James,
For LPAD, the amount of padding being applied depends on the length of the
input string. Also, if the the final pad length is shorter than the input
string, the string is truncated (This is similar to how postgress implements
LPAD http://www.postgresql.org/docs/8.2/static/functions-string.html). Because
of this I think LPAD has to return OrderPreserving.NO for preservesOrder().
For ENCODE I think since the base62 encoded number is represented as a VARCHAR,
its sort order (lexicographical) is different compared to the natural sort
order of the input numbers.
In any case, I don't think LPAD or ENCODE is going to be used in a WHERE
clause, so I will just have them return NO_TRAVERSAL.
Thanks,
Thomas
> ADD ENCODE AND LPAD functions
> ------------------------------
>
> Key: PHOENIX-995
> URL: https://issues.apache.org/jira/browse/PHOENIX-995
> Project: Phoenix
> Issue Type: New Feature
> Reporter: Thomas D'Silva
> Assignee: Thomas D'Silva
> Attachments: PHOENIX-995.patch
>
>
> Add ENCODE(input number, format encodeformat) which can be used to convert a
> base 10 number to a base 62 number
> Add LPAD(input string, length int [, fill string]) which can be used to left
> pad an input string.
> Together these two functions can be used to generate IDs using sequences, for
> example:
> {code:sql}
> CREATE SEQUENCE foo.bar START WITH 0 INCREMENT BY 62
> SELECT LPAD(ENCODE(NEXT VALUE FOR foo.bar,'BASE62'), 10,'0') FROM
> SYSTEM."SEQUENCE"
> {code}
--
This message was sent by Atlassian JIRA
(v6.2#6252)