-
Notifications
You must be signed in to change notification settings - Fork 63
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
Adds compilation/evaluation support for UNION/INTERSECT/EXCEPT ALL/DISTINCT #1430
Conversation
2e82c38
to
b6b0dc7
Compare
partiql-eval/src/main/kotlin/org/partiql/eval/internal/operator/rel/RelExceptAll.kt
Outdated
Show resolved
Hide resolved
partiql-eval/src/main/kotlin/org/partiql/eval/internal/helpers/IteratorChain.kt
Outdated
Show resolved
Hide resolved
partiql-eval/src/main/kotlin/org/partiql/eval/internal/operator/rel/RelExceptAll.kt
Outdated
Show resolved
Hide resolved
partiql-eval/src/main/kotlin/org/partiql/eval/internal/operator/rel/RelExceptAll.kt
Outdated
Show resolved
Hide resolved
partiql-eval/src/test/kotlin/org/partiql/eval/internal/PartiQLEngineDefaultTest.kt
Show resolved
Hide resolved
type: [ | ||
UNION_ALL, | ||
UNION_DISTINCT, | ||
INTERSECT_ALL, | ||
INTERSECT_DISTINCT, | ||
EXCEPT_ALL, | ||
EXCEPT_DISTINCT | ||
] |
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.
We've gone back and forth for this modeling. I believe I did "set" initially, but PIG modeled as (union ...) (intersect ...) ...
etc. hence them being their own operators.
I'm keen on keeping them separate mostly for staying similar to PartiQL 0.14, but this is entirely preference. However, I would like the set quantifier to be split.
union::{
setq: set_quantifier,
lhs: rel,
rhs: rel,
},
intersect::{
setq: set_quantifier,
lhs: rel,
rhs: rel,
},
except::{
setq: set_quantifier,
lhs: rel,
rhs: rel,
}
Interestingly, substrait uses a list of inputs rather than lhs, rhs. Seems like an optimization
override fun visitRelOpExcept(node: Rel.Op.Except, ctx: Rel.Type?): Rel { | ||
TODO("Type RelOp Except") | ||
// Compute Output Schema | ||
val size = max(lhs.type.schema.size, rhs.type.schema.size) |
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.
Would this not depend on both the OUTER boolean and the operator type?
Like OUTER UNION size may not be computable with open tuples.
set::[ | ||
union::{ | ||
quantifier: quantifier, | ||
lhs: rel, | ||
rhs: rel, | ||
}, |
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.
Nice. This seems like a good middle ground.
Co-authored-by: R. C. Howell <RCHowell@users.noreply.github.com>
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.
One minor change, otherwise let's get this in.
partiql-eval/src/main/kotlin/org/partiql/eval/internal/helpers/IteratorPeeking.kt
Outdated
Show resolved
Hide resolved
override fun close() { | ||
_next = null | ||
next = null | ||
} |
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.
nit, but it would be better to have the abstract method hold the close control so that inheritors don't need to call super.close(). In some languages you can do something like @mustCallSuper but we can do better with a concrete close that does
override fun close() {
close1()
next = null
}
abstract fun close1()
It's a nit, but I wouldn't want to track down a bug because an inheritor didn't call super. Perhaps we just add a comment to keep the change small.
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.
Agreed. I was going to do that in this PR, but I didn't want the diff to affect implementers of RelPeeking. Seeing that you've reviewed the rest of the PR, I'll update. Thanks!
Co-authored-by: R. C. Howell <RCHowell@users.noreply.github.com>
Adds compilation/evaluation support for UNION/INTERSECT/EXCEPT ALL/DISTINCT
Adds compilation/evaluation support for UNION/INTERSECT/EXCEPT ALL/DISTINCT
Relevant Issues
Description
Specification and RFC Insight
Examples
Other Information
and Code Style Guidelines? YES
License Information
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.