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

James Taylor commented on PHOENIX-538:
--------------------------------------

bq. 3) I think it's fine to support phoenix data types as argument types right? 
Ex: create function MY_REVERSE(VARCHAR,CHAR) returns VARCHAR
Those are SQL types (not specific to any kind of Phoenix-specific types), and 
yes I agree that seems like it'd be a good way to specify them

bq. 4) Do we need to allow to specify any details for arguments like not null, 
constant, max length,precision,scale? 
Maybe with follow up work? It'd be good to get the basic stuff in first. FWIW, 
the max length, precision, scale are part of the type declaration, so we'd get 
with your proposed syntax. For example: create function power(DECIMAL(10,2), 
INTEGER).

That seems reasonable to have separate commands that manages the dynamic class 
path. Maybe we could even punt on this initially and folks would need to 
manually manage this?

Glad you're pursuing this, [~rajeshbabu] - this will be a nice feature. I'd 
make sure you have a way of disallowing it, though, too just in case folks 
don't want to allow this functionality.



> Support UDFs
> ------------
>
>                 Key: PHOENIX-538
>                 URL: https://issues.apache.org/jira/browse/PHOENIX-538
>             Project: Phoenix
>          Issue Type: Task
>            Reporter: James Taylor
>            Assignee: Rajeshbabu Chintaguntla
>
> Phoenix allows built-in functions to be added (as described 
> [here](http://phoenix-hbase.blogspot.com/2013/04/how-to-add-your-own-built-in-function.html))
>  with the restriction that they must be in the phoenix jar. We should improve 
> on this and allow folks to declare new functions through a CREATE FUNCTION 
> command like this:
>       CREATE FUNCTION mdHash(anytype)
>       RETURNS binary(16)
>       LOCATION 'hdfs://path-to-my-jar' 'com.me.MDHashFunction'
> Since HBase supports loading jars dynamically, this would not be too 
> difficult. The function implementation class would be required to extend our 
> ScalarFunction base class. Here's how I could see it being implemented:
> * modify the phoenix grammar to support the new CREATE FUNCTION syntax
> * create a new UTFParseNode class to capture the parse state
> * add a new method to the MetaDataProtocol interface
> * add a new method in ConnectionQueryServices to invoke the MetaDataProtocol 
> method
> * add a new method in MetaDataClient to invoke the ConnectionQueryServices 
> method
> * persist functions in a new "SYSTEM.FUNCTION" table
> * add a new client-side representation to cache functions called PFunction
> * modify ColumnResolver to dynamically resolve a function in the same way we 
> dynamically resolve and load a table
> * create and register a new ExpressionType called UDFExpression
> * at parse time, check for the function name in the built in list first (as 
> is currently done), and if not found in the PFunction cache. If not found 
> there, then use the new UDFExpression as a placeholder and have the 
> ColumnResolver attempt to resolve it at compile time and throw an error if 
> unsuccessful.



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Reply via email to