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

ASF GitHub Bot commented on DRILL-3988:
---------------------------------------

kkhatua opened a new pull request #1483: DRILL-3988: Expose Drill built-in 
functions & UDFs  in a system table
URL: https://github.com/apache/drill/pull/1483
 
 
   This commit exposes available SQL functions in Drill and also detects UDFs 
that have been dynamically loaded into Drill. 
   An example is shown below for 2 UDFs dynamically loaded into the cluster, 
along side the existing built-in functions that come with Drill.
   
   ```
   0: jdbc:drill:schema=sys>  select source, count(*) as functionCount from 
sys.functions group by source;
   +-----------------------------------------+----------------+
   |                 source                  | functionCount  |
   +-----------------------------------------+----------------+
   | built-in                                | 2704           |
   | simple-drill-function-1.0-SNAPSHOT.jar  | 12             |
   | drill-url-tools-1.0.jar                 | 1              |
   +-----------------------------------------+----------------+
   1 row selected (0.211 seconds)
   ```
   
   The system table exposes information as shown. Since UDFs are lazily 
initialized (i.e. only when a SQL query needs it), the `returnType` is not 
available and listed as `n/a`.
   Once the UDF is initialized, the `returnType` is also available.
   The `random(FLOAT8-REQUIRED,FLOAT8-REQUIRED)` function is an example of a 
lazily loaded UDF (see `returnType`).
   The `url_parse(VARCHAR-REQUIRED)` function is an example of an initialized 
UDF (see `returnType`).
   Rest are built-in functions that meet the query's filter criteria.
   
   ```
   0: jdbc:drill:schema=sys>select * from sys.functions where name like 
'random' or `name` like '%url%';
   
+-------------+----------------------------------+-------------+-----------------------------------------+
   |    name     |            signature             | returnType  |             
     source                 |
   
+-------------+----------------------------------+-------------+-----------------------------------------+
   | parse_url   | VARCHAR-REQUIRED                 | LATE        | built-in    
                            |
   | random      |                                  | FLOAT8      | built-in    
                            |
   | random      | FLOAT8-REQUIRED,FLOAT8-REQUIRED  | n/a         | 
simple-drill-function-1.0-SNAPSHOT.jar  |
   | url_decode  | VARCHAR-REQUIRED                 | VARCHAR     | built-in    
                            |
   | url_encode  | VARCHAR-REQUIRED                 | VARCHAR     | built-in    
                            |
   | url_parse   | VARCHAR-REQUIRED                 | LATE        | 
drill-url-tools-1.0.jar                 |
   
+-------------+----------------------------------+-------------+-----------------------------------------+
   6 rows selected (0.221 seconds)
   ```

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
[email protected]


> Create a sys.functions table to expose available Drill functions
> ----------------------------------------------------------------
>
>                 Key: DRILL-3988
>                 URL: https://issues.apache.org/jira/browse/DRILL-3988
>             Project: Apache Drill
>          Issue Type: Sub-task
>          Components: Metadata
>            Reporter: Jacques Nadeau
>            Assignee: Kunal Khatua
>            Priority: Major
>              Labels: newbie
>             Fix For: 1.15.0
>
>
> Create a new sys.functions table that returns a list of all available 
> functions.
> Key considerations: 
> - one row per name or one per argument set. I'm inclined to latter so people 
> can use queries to get to data.
> - we need to create a delineation between user functions and internal 
> functions and only show user functions. 'CastInt' isn't something the user 
> should be able to see (or run).
> - should we add a description annotation that could be included in the 
> sys.functions table?



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

Reply via email to