Skip to content

Commit

Permalink
Support ANY type in Header functions And Planning of Control Flow Fun…
Browse files Browse the repository at this point in the history
…ctions. (#1256)

* coalesce; nullif; ANY type in function signature.
  • Loading branch information
yliuuuu authored Nov 2, 2023
1 parent a365a45 commit 5cdc8bb
Show file tree
Hide file tree
Showing 6 changed files with 268 additions and 69 deletions.
1 change: 1 addition & 0 deletions partiql-lang/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -85,5 +85,6 @@ tasks.processTestResources {

tasks.shadowJar {
archiveBaseName.set("shadow")
exclude("**/*.kotlin_metadata")
archiveClassifier.set("")
}
8 changes: 5 additions & 3 deletions partiql-planner/src/main/kotlin/org/partiql/planner/Header.kt
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ public abstract class Header {
* For functions, output CREATE FUNCTION statements.
*/
override fun toString(): String = buildString {
functions.groupBy { it.name }.forEach {
(functions + operators + aggregations).groupBy { it.name }.forEach {
appendLine("-- [${it.key}] ---------")
appendLine()
it.value.forEach { fn -> appendLine(fn) }
Expand All @@ -58,23 +58,25 @@ public abstract class Header {
companion object {

@JvmStatic
internal fun unary(name: String, returns: PartiQLValueType, value: PartiQLValueType) =
internal fun unary(name: String, returns: PartiQLValueType, value: PartiQLValueType, isMissable: Boolean = false) =
FunctionSignature.Scalar(
name = name,
returns = returns,
parameters = listOf(FunctionParameter("value", value)),
isNullCall = true,
isNullable = false,
isMissable = isMissable
)

@JvmStatic
internal fun binary(name: String, returns: PartiQLValueType, lhs: PartiQLValueType, rhs: PartiQLValueType) =
internal fun binary(name: String, returns: PartiQLValueType, lhs: PartiQLValueType, rhs: PartiQLValueType, isMissable: Boolean = false) =
FunctionSignature.Scalar(
name = name,
returns = returns,
parameters = listOf(FunctionParameter("lhs", lhs), FunctionParameter("rhs", rhs)),
isNullCall = true,
isNullable = false,
isMissable = isMissable
)
}
}
Loading

0 comments on commit 5cdc8bb

Please sign in to comment.