-
Notifications
You must be signed in to change notification settings - Fork 9
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add UDFs to catalog; Add extension UDFs for TUPLEUNION/TUPLECONCAT #496
Conversation
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #496 +/- ##
==========================================
+ Coverage 80.49% 80.64% +0.15%
==========================================
Files 73 78 +5
Lines 18947 19157 +210
Branches 18947 19157 +210
==========================================
+ Hits 15251 15450 +199
- Misses 3271 3283 +12
+ Partials 425 424 -1 ☔ View full report in Codecov by Sentry. |
Conformance comparison report
Number passing in both: 5731 Number failing in both: 612 Number passing in Base (70b5ea2) but now fail: 0 Number failing in Base (70b5ea2) but now pass: 0 |
The main alternative I can think of for naming has to do with SQL's
Though, |
Also, looking at Asterix and Couchbase:
|
TUPLE_UNION
and TUPLE_MERGE
; Add 'vararg' functionsTUPLEUNION
and TUPLEMERGE
; Add 'vararg' functions
The initial version of this did use |
Merriam's definitions:
In hindsight, from the definitions above, |
That being said, I don't want to distract from the intention of this PR, but seeing that this is the first instance of |
Good points John. Sharing my thoughts: I am less opinionated in this regard mainly because this is an implementation specific function and we can always add aliased functions later. |
This looks like it will be sufficient for our purposes. I don't have any particular preference about the choice of name here. |
This PR has been reworked to:
|
169ce4f
to
802cebf
Compare
802cebf
to
6f30dc9
Compare
|
||
pub type ScalarFnExprResultValue<'a> = Cow<'a, Value>; | ||
pub type ScalarFnExprResult<'a> = Result<ScalarFnExprResultValue<'a>, ExtensionResultError>; | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shouldn't this and table_fn
move to partiql_eval
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It can't.
partiql-eval
imports partiql-catalog
. Moving them to eval
would necessitate catalog
importing eval
which would create a cycle.
For this reason, I tried to keep anything other than Value
out of the signature.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see, how about partiql-commons
?
partiql-catalog/src/call_defs.rs
Outdated
pub struct ScalarFnCallSpec { | ||
pub input: Vec<CallSpecArg>, | ||
pub output: Box<dyn ScalarFnExpr>, | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does it also need to include isNullCall
and isMissingCall
as partiql-lang-kotlin
implements?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Perhaps in the fullness of time. I think that will become more apparent (and more testable) when the existing builtins are migrated into the catalolg.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See #499
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As it stands, all scalar functions using this mechanism have NULL
and MISSING
propagated as per https://github.com/partiql/partiql-lang-rust/pull/496/files#diff-e9f95c45f5307b665fabb97d0b6f9441210bd70f3934fb9ae806c58e8aa4cf82R42
TUPLEUNION
and TUPLEMERGE
; Add 'vararg' functions
Fixes #459 and #495
Extensions and scalar UDFs
Adds ability to create and register scalar User Defined Functions (UDFs)
TUPLEUNION & TUPLECONCAT
Adds
TUPLEUNION
andTUPLECONCAT
functions via an extension crate under theextension
crate namespace as scalar UDFs.TUPLEUNION
is as per 6.3.2 of the spec (https://partiql.org/assets/PartiQL-Specification.pdf#subsubsection.6.3.2)TUPLECONCAT
is inspired by description of concatenating binding environments as per section 3.3 of the spec (https://partiql.org/assets/PartiQL-Specification.pdf#subsection.3.3) and as requested in #495.tupleunion({ 'bob': 1, 'sally': 'error' }, { 'sally': 1 }, { 'sally': 2 }, { 'sally': 3 }, { 'sally': 4 })
->
{ 'bob': 1, 'sally': 'error', 'sally': 1, 'sally': 2, 'sally': 3, 'sally': 4 }
tupleconcat({ 'bob': 1, 'sally': 'error' }, { 'sally': 1 }, { 'sally': 2 }, { 'sally': 3 }, { 'sally': 4 })
->
{ 'sally': 4, 'bob': 1 }
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.