[ https://issues.apache.org/jira/browse/PHOENIX-538?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14498267#comment-14498267 ]
Rajeshbabu Chintaguntla commented on PHOENIX-538: ------------------------------------------------- bq. We could have a local secondary index on tenantID+classname that we check for uniqueness when a function is created. Good. I will add this as improvement later [~jamestaylor]. bq. Do you have a pointer to the code that manages the class loaders on the client-side? You can see UDFExpression.java in the patch where I am handling dynamic loading jars both at client and sever side(Same logic for both). bq. How do you manage unloading jars if a UDF is replaced with with a new implementation in a different or the same jar? Do you need to deal with this? On the server-side too? Here is the javadoc of DynmicClassLoader in HBase. As for this we cannot unload the jars to take new implementation. Some thing like we need to maintain last modified times of jars and unload if the updated jar is recently modified. {code} * <p> * The configured folder can be a HDFS path. In this case, the jar files * under that folder will be copied to local at first under ${hbase.local.dir}/jars/. * The local copy will be updated if the remote copy is updated, according to its * last modified timestamp. * <p> * We can't unload a class already loaded. So we will use the existing * jar files we already know to load any class which can't be loaded * using the parent class loader. If we still can't load the class from * the existing jar files, we will check if any new jar file is added, * if so, we will load the new jar file and try to load the class again. * If still failed, a class not found exception will be thrown. {code} In the latest patch added basic tests. Adding the scenarios you have pointed and more tests as well. Will update it once done. Thanks. > 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 > Fix For: 5.0.0, 4.4.0 > > Attachments: PHOENIX-538-wip.patch, PHOENIX-538_v1.patch, > PHOENIX-538_v2.patch > > > 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)