Skip to content

Commit

Permalink
Prepare function guidelines
Browse files Browse the repository at this point in the history
  • Loading branch information
elharo committed Aug 19, 2024
1 parent 1caebcc commit 3a18c33
Showing 1 changed file with 30 additions and 0 deletions.
30 changes: 30 additions & 0 deletions FUNCTIONS.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# Presto Function Guidelines

Presto includes a large library of built-in, core SQL functions such as AVG and CONCAT that are available in every deployment.

Presto also includes extension functions that are not enabled by default but can be optionally enabled in particular deployments.

Finally, Presto allows users to write user defined functions (UDFs) in either Java or SQL that are not stored in this GitHub repository. This is done through the [Plugin SPI](https://prestodb.io/docs/current/develop/functions.html).

This document lays out some guidelines for which category is right for which functions.

Functions defined in [ANSI SQL](https://jakewheat.github.io/sql-overview/) should be written as core functions in this repository.

Non-standard functions that are commonly available in multiple other SQL dialects such as MySQL and Postgres can also be written as core functions in this library.

Functions that are provided in order to mirror the syntax and semantics of particular other SQL dialects (MySQL, Postgres, Oracle, etc.) should be extension functions so they can be turned on only by users who need compatibility with that dialect. This also helps avoid conflicts where two existing dialects are incompatible.

Functions that alias or closely resemble existing core functions should not be included in this repository. For instance, because Presto already has an AVG function it should not also have a MEAN or an AVERAGE function, even if the semantics or arguments are slightly different.

Core functions should be broadly applicable to many users in different areas. For example,
functions that work with data in the [FITS format](https://fits.gsfc.nasa.gov/fits_primer.html)
would mostly be used by astronomers, and thus should be extension functions or UDFs.

Core functions should be purely computational. That is, they do not make network connections or perform I/O outside the database. (Date/time functions like NOW() are an exception.) For example, a function that talks to a remote server to check the current temperature or a stock price should not be a core function. This should be a user defined function maintained outside the Presto GitHub repository.

Core and extension functions should be able to be maintained by Presto committers without support from the original contributors. That is, they should not require specialized or expert knowledge beyond what Presto maintenance already requires. For instance, cryptographic functions should not be included in this repository because it is not reasonable to expect that Presto committers are also domain experts in cryptography.

Core functions that extend Presto into new domains should have a detailed plan and ideally an implementation for a library of functions that covers the domain. For instance, a function that only finds the eigenvalues of a matrix would not be accepted on its own. A library of multiple matrix functions along the lines of LAPACK could be considered. It can be helpful to prototype complex functionality like this in UDFs before it is submitted to core.

Core and extension functions must be freely available without fee and compatible with the Presto license. Functions using algorithms that are in any way restricted by copyright, patent, trademark, field of use, or other reasons will not be included in this repository. For instance, a patented video CODEC cannot be used. Functions that include trademarked names should be UDFs outside this repository.

0 comments on commit 3a18c33

Please sign in to comment.