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

Support ANY type in Header functions And Planning of Control Flow Functions. #1256

Merged
merged 6 commits into from
Nov 2, 2023

Conversation

yliuuuu
Copy link
Contributor

@yliuuuu yliuuuu commented Nov 1, 2023

Relevant Issues

  • N/A

Description

  • Control Flow functions such as coalesce and nullIf will be rewrited to a case when expression.
  • Support for ANY type in Function Header.

Other Information

  • Updated Unreleased Section in CHANGELOG: [YES/NO]

    • No, feature branch.
  • Any backward-incompatible changes? [YES/NO]

    • No.
  • Any new external dependencies? [YES/NO]

    • No.
  • Do your changes comply with the Contributing Guidelines
    and Code Style Guidelines? [YES/NO]
    Yes.

License Information

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

@yliuuuu yliuuuu requested a review from RCHowell November 1, 2023 19:45
Copy link

github-actions bot commented Nov 1, 2023

Conformance comparison report

Base (234ff97) cee3d99 +/-
% Passing 92.33% 92.33% 0.00%
✅ Passing 5372 5372 0
❌ Failing 446 446 0
🔶 Ignored 0 0 0
Total Tests 5818 5818 0

Number passing in both: 5372

Number failing in both: 446

Number passing in Base (234ff97) but now fail: 0

Number failing in Base (234ff97) but now pass: 0

partiql-lang/build.gradle.kts Show resolved Hide resolved
Comment on lines 136 to 178
private fun lt(): List<FunctionSignature.Scalar> = types.numeric.map { t ->
binary("lt", BOOL, t, t)
}
} + listOf(binary("lt", ANY, ANY, ANY))

private fun lte(): List<FunctionSignature.Scalar> = types.numeric.map { t ->
binary("lte", BOOL, t, t)
}
} + listOf(binary("lte", ANY, ANY, ANY))

private fun gt(): List<FunctionSignature.Scalar> = types.numeric.map { t ->
binary("gt", BOOL, t, t)
}
} + listOf(binary("gt", ANY, ANY, ANY))

private fun gte(): List<FunctionSignature.Scalar> = types.numeric.map { t ->
binary("gte", BOOL, t, t)
}
} + listOf(binary("gte", ANY, ANY, ANY))

private fun plus(): List<FunctionSignature.Scalar> = types.numeric.map { t ->
binary("plus", t, t, t)
}
} + listOf(binary("plus", ANY, ANY, ANY))

private fun minus(): List<FunctionSignature.Scalar> = types.numeric.map { t ->
binary("minus", t, t, t)
}
} + listOf(binary("minus", ANY, ANY, ANY))

private fun times(): List<FunctionSignature.Scalar> = types.numeric.map { t ->
binary("times", t, t, t)
}
} + listOf(binary("times", ANY, ANY, ANY))

private fun div(): List<FunctionSignature.Scalar> = types.numeric.map { t ->
binary("divide", t, t, t)
}
} + listOf(binary("divide", ANY, ANY, ANY))

private fun mod(): List<FunctionSignature.Scalar> = types.numeric.map { t ->
binary("modulo", t, t, t)
}
} + listOf(binary("modulo", ANY, ANY, ANY))

private fun concat(): List<FunctionSignature.Scalar> = types.text.map { t ->
binary("concat", t, t, t)
}
} + listOf(binary("concat", ANY, ANY, ANY))

private fun bitwiseAnd(): List<FunctionSignature.Scalar> = types.integer.map { t ->
binary("bitwise_and", t, t, t)
}
} + listOf(binary("bitwise_and", ANY, ANY, ANY))
Copy link
Member

Choose a reason for hiding this comment

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

These are slightly different functions. The return type is still BOOL, but the functions are MISSABLE because we could have a mis-typing case.

@yliuuuu yliuuuu changed the title Add Support for ANY type in Header functions. Support ANY type in Header functions And Planning of Control Flow Functions. Nov 2, 2023
@yliuuuu yliuuuu requested a review from RCHowell November 2, 2023 17:56
Comment on lines -329 to -345
// TODO
private fun coalesce(): List<FunctionSignature.Scalar> = emptyList()

// NULLIF(x, y)
private fun nullIf(): List<FunctionSignature.Scalar> = types.nullable.map { t ->
FunctionSignature.Scalar(
name = "null_if",
returns = t,
parameters = listOf(
FunctionParameter("value", t),
FunctionParameter("nullifier", BOOL), // TODO: why is this BOOL?
),
isNullCall = true,
isNullable = true,
)
}

Copy link
Member

Choose a reason for hiding this comment

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

goodbye!!

name = "date_diff_${field.name.lowercase()}",
returns = ANY,
parameters = listOf(
FunctionParameter("interval", INT),
Copy link
Member

Choose a reason for hiding this comment

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

Should interval also be ANY?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

good catch : )

@yliuuuu yliuuuu merged commit 5cdc8bb into partiql-planner Nov 2, 2023
4 of 8 checks passed
@yliuuuu yliuuuu deleted the planner-coalesce branch November 2, 2023 18:15
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.

2 participants