Uploaded image for project: 'Phoenix'
  1. Phoenix
  2. PHOENIX-538

Support UDFs

    XMLWordPrintableJSON

    Details

    • Type: Task
    • Status: Closed
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 4.4.0
    • Labels:
      None
    • old issue number:
      407

      Description

      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.

        Attachments

        1. PHOENIX-538_v1.patch
          424 kB
          Rajeshbabu Chintaguntla
        2. PHOENIX-538_v2.patch
          441 kB
          Rajeshbabu Chintaguntla
        3. PHOENIX-538_v3.patch
          527 kB
          Rajeshbabu Chintaguntla
        4. PHOENIX-538_v4.patch
          682 kB
          Rajeshbabu Chintaguntla
        5. PHOENIX-538_v5.patch
          688 kB
          Rajeshbabu Chintaguntla
        6. PHOENIX-538_v6.patch
          695 kB
          Rajeshbabu Chintaguntla
        7. PHOENIX-538_v6.patch
          689 kB
          Rajeshbabu Chintaguntla
        8. PHOENIX-538-wip.patch
          412 kB
          Rajeshbabu Chintaguntla

          Issue Links

            Activity

              People

              • Assignee:
                rajeshbabu Rajeshbabu Chintaguntla
                Reporter:
                jamestaylor James Taylor
              • Votes:
                3 Vote for this issue
                Watchers:
                14 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: