[ 
https://issues.apache.org/jira/browse/PHOENIX-995?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14007361#comment-14007361
 ] 

Thomas D'Silva commented on PHOENIX-995:
----------------------------------------

I have a question about the getKeyFormationTraversalIndex(), newKeyPart() and 
preservesOrder() functions. I used the default implementation of these 
functions because I was not sure how to implement them correctly.
I think for both  LPAD and TO_STRING getKeyFormationTraversalIndex() should 
return NO_TRAVERSAL since its not possible to generate the start/stop key if 
these functions are used in the where clause.  
I was not able to understand how the preservesOrder() is supposed to be 
implemented. Does OrderPreserving.YES mean that if inputs to the function are 
ordered in a particular way, applying the function will not re-order the 
outputs wrt to inputs? However, can they be sorted differently, for eg INVERT 
has OrderPreserving.YES, even thought it inverts the bits of the input?
I think preservesOrder()  should return NO_TRAVERSAL since TO_STRING returns a 
string which is sorted lexicographically compared to numeric sort. of the 
original input. 
I think LPAD also should return NO_TRAVERSAL.

> ADD TO_STRING 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
>         Attachments: PHOENIX-995.patch
>
>
> Add TO_STRING(input number, base number) which can be used to convert a base 
> 10 number to a number in any base between 2 to 62.
> 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(TO_STRING(NEXT VALUE FOR foo.bar,62), 10,'0') FROM 
> SYSTEM."SEQUENCE"
> {code}



--
This message was sent by Atlassian JIRA
(v6.2#6252)

Reply via email to