Replies: 1 comment
-
Accredit to @jpschorr. Originally from partiql/partiql-docs#3 |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
PartiQL Prelude
Terminology
a+b*10
,lower(col1) LIKE 'exception'
).SELECT ... FROM ... WHERE ...
(SFW
) queries as well as expression language queries.UPDATE ... WHERE ...
,INSERT INTO ... VALUES ...
).Background
The PartiQL library needs to support a spectrum of PartiQL hosts. Some of these hosts will wish to embed and expose the total PartiQL functionality, while some will wish to expose only a subset. Thus PartiQL needs to support 'dialects' of the PartiQL language. For example, CLI application host for querying against an
Ion
orjson
file may wish to expose all query functionality but no DML/DDL. On the other hand, a host that translates PartiQL queries to a series of manipulations against a (possibly remote) key-value store may wish to expose Query/DML/DDL but with none of the built-in functions and operators that PartiQL provides.A complete discussion of dialects (i.e., Query vs. DML vs. DDL and which clauses are supported) is outside the scope of this document. Herein is proposed a mechanism to model the ability to define the set of PartiQL functions and operators that a host makes available to end users for use in the expression language of PartiQL.
A Model for function imports
The general idea is to model the functions and operators available to the expression language as a set of namespaced functions that are made available un-namespaced to the end users via the use of a "prelude". The prelude consists of a number of
import
statements that hoist functions out of their namespaces and into the "top-level" namespace.At the very least, this serves as a conceptual model to explain and document the expression language features available to end-users.
Note For now, only hoisting is specified -- there is no 'renaming' of imported functions.
Note There is no ability provided to allow end users to use the un-imported, namespaced functions; only functions imported into the 'top-level' will be available to the expression language.
Functions and Namespaces
NOTE the syntax in this section is illustrative for purposed of explaining the namespacing, not normative. PartiQL library implementations will have implementation-specific plugin mechanisms.
PartiQL will model vended (and, where supported, host-injected) functions as though they were defined with namespacing and types similar to the below.
Selected SQL92 specified functions (
sql92
andstring
are namespace components, eachfn
line defines a function signature):Selected Native PartiQL functions:
Straw-man host-vended functions:
Prelude
PartiQL hosts will define a 'prelude' script (Cf. the Rust prelude and the Haskell Prelude) to describe the functions that are available to end-users of a hosted application of PartiQL.
An example of a 'complete' usage of available PartiQL functions might look something like (where
**
and*
are analogous to shell-globing, so**
means 'match all sub-namespaces, recursively' and*
means 'match all functions`):While a service host that wishes to translate a PartiQL query into a simple key-value lookup might have an empty prelude:
Beta Was this translation helpful? Give feedback.
All reactions