Skip to content
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 support for nullable casts and missable/missingCall functions #1422

Closed
wants to merge 2 commits into from

Conversation

johnedquinn
Copy link
Member

Relevant Issues

Description

Other Information

License Information

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

@johnedquinn johnedquinn marked this pull request as ready for review April 11, 2024 18:39
@@ -584,18 +584,21 @@ internal class PlanTyper(

// Type the arguments
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm curious if https://github.com/partiql/partiql-lang-kotlin/blob/v1/partiql-planner/src/main/kotlin/org/partiql/planner/internal/typer/PlanTyper.kt#L1357-L1405 can be a replacement for this? This is a lot of logic that isn't in V1. Ideally we can bring the latest to 0.14.+

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+1 to Robert's question. Can the same logic from v1 be ported to this PR/main? Have a couple concerns that

  • the PR may have a different typing behavior from the v1 branch
  • the code changes may make it tricky to merge main into v1 (or v1 into main)

@johnedquinn johnedquinn requested a review from alancai98 May 9, 2024 17:58
Copy link
Member

@alancai98 alancai98 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Haven't looked at the tests in too much detail. Raising some initial concerns + questions in this review.

@@ -14,13 +14,18 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Deprecated

### Fixed
- Fixes [#1398](https://github.com/partiql/partiql-lang-kotlin/issues/1398) by handling "missable" arguments to
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: changelog entry added to the template and not the Unreleased section below

@@ -57,6 +60,8 @@ public sealed class FunctionSignature(
isNullable: Boolean = true,
@JvmField public val isDeterministic: Boolean = true,
@JvmField public val isNullCall: Boolean = false,
@JvmField public val isMissable: Boolean = false,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Any reason isMissable on the main branch defaults to false? FnSignature on the v1 branch defaults to true:

@JvmField public val isMissable: Boolean = true,

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A little confused w/ the divergence in behavior. Seems like all the functions defined in the PartiQLHeader are all not "missible"?

Comment on lines +50 to +52
* @property isMissable Indicates whether the function's operator may return MISSING.
* @property isMissingCall Indicates behavior when any of the arguments are MISSING. If set to true, the function
* will return MISSING. If false, the operator itself will handle the MISSING.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: for easier merging, may be helpful to use the same kdoc comments from the FnSignature defined on v1 branch:

* @property isMissable Flag indicating this function's operator may return a MISSING value.
* @property isMissingCall Flag indicating if any of the call arguments is MISSING, the return MISSING.

@@ -182,15 +184,24 @@ internal object PartiQLHeader : Header() {
unary("neg", t, t)
}

private fun eq(): List<FunctionSignature.Scalar> = types.all.map { t ->
private fun eq(): List<FunctionSignature.Scalar> = types.all.filterNot { it == ANY || it == MISSING }.map { t ->
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There's a divergence here between the modeling of functions between this PR and the v1 branch. E.g.

  • For eq, the v1 branch includes all the types and they have the same isNullable, isMissingCall`, etc. configurations
    private fun eq(): List<FnSignature> = all.map { t ->
    FnSignature(
    name = "eq",
    returns = BOOL,
    parameters = listOf(FnParameter("lhs", t), FnParameter("rhs", t)),
    isNullable = false,
    isNullCall = true,
    )
    }
  • For the logical ops, the v1 branch uses the defaults for isMissable = true and isMissingCall = true, whereas this PR defines isMissable = false and isMissingCall = false

I'm curious the reasoning for the modeling differences.

@@ -584,18 +584,21 @@ internal class PlanTyper(

// Type the arguments
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+1 to Robert's question. Can the same logic from v1 be ported to this PR/main? Have a couple concerns that

  • the PR may have a different typing behavior from the v1 branch
  • the code changes may make it tricky to merge main into v1 (or v1 into main)

@johnedquinn
Copy link
Member Author

Closing as an alternative solution is being actively pursued.

@johnedquinn johnedquinn deleted the fn-dynamic-fix branch May 14, 2024 22:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Confirm plan typer behavior for equality between a type with a missable type
3 participants