Skip to content

Adds int32 and int64 variants of date_add #1291

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

Merged
merged 1 commit into from
Dec 8, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -590,23 +590,26 @@ public object PartiQLHeader : Header() {
private fun extract(): List<FunctionSignature.Scalar> = emptyList()

private fun dateAdd(): List<FunctionSignature.Scalar> {
val intervals = listOf(INT32, INT64, INT)
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
val intervals = listOf(INT32, INT64, INT)
val intervals = listOf(INT8, INT16, INT32, INT64, INT)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

That was intentional. They're not necessary because the INT8 and INT16 will be implicitly cast to INT32

Copy link
Contributor

Choose a reason for hiding this comment

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

What if the input is not a literal? Would you still prefer an implicit cast?

Copy link
Contributor

Choose a reason for hiding this comment

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

DateAdd(Day, a_int16_type, b_timestamp_type)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah that's fine. We mostly need int32 for our target systems

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The default was INT which should never be the default. The default integer should always be INT32. Then INT64 is between them, hence why I did those three

val operators = mutableListOf<FunctionSignature.Scalar>()
for (field in DatetimeField.values()) {
for (type in types.datetime) {
if (field == DatetimeField.TIMEZONE_HOUR || field == DatetimeField.TIMEZONE_MINUTE) {
continue
}
val signature = FunctionSignature.Scalar(
name = "date_add_${field.name.lowercase()}",
returns = type,
parameters = listOf(
FunctionParameter("interval", INT),
FunctionParameter("datetime", type),
),
isNullable = false,
isNullCall = true,
)
operators.add(signature)
for (interval in intervals) {
val signature = FunctionSignature.Scalar(
name = "date_add_${field.name.lowercase()}",
returns = type,
parameters = listOf(
FunctionParameter("interval", interval),
FunctionParameter("datetime", type),
),
isNullable = false,
isNullCall = true,
)
operators.add(signature)
}
}
}
return operators
Expand Down