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)
```

[ Full content available at: https://github.com/apache/drill/pull/1483 ]
This message was relayed via gitbox.apache.org for [email protected]

Reply via email to