Skip to content

Commit

Permalink
Backup
Browse files Browse the repository at this point in the history
  • Loading branch information
RCHowell committed Jun 20, 2024
1 parent 6042c0f commit 6fcde57
Show file tree
Hide file tree
Showing 13 changed files with 171 additions and 560 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import org.partiql.eval.value.Datum
*
* TODO consider a `done()` method for short-circuiting.
*/
internal interface Accumulator {
interface Accumulator {

/**
* Apply args to the accumulator.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
package org.partiql.eval.internal

interface Aggregation {

public fun getKey(): String
/**
*
*/
internal fun interface Aggregation {

/**
* Instantiates a stateful accumulator for this aggregation function.
*
* @return
*/
public fun accumulator(): Accumulator
fun accumulator(): Accumulator
}
12 changes: 12 additions & 0 deletions partiql-eval/src/main/kotlin/org/partiql/eval/internal/Routines.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
package org.partiql.eval.internal

import org.partiql.spi.fn.Agg

internal class Routines(
private val functions: Map<String, Fn>,
private val aggregations: Map<String, Aggregation>,
) {



}
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package org.partiql.eval.internal

internal class SqlAggregations private constructor(private val map: Map<String, Aggregation>) {

fun get(specific: String): Aggregation? = map[specific]

companion object {



}

}
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@ import org.partiql.eval.internal.Accumulator
import org.partiql.eval.internal.Aggregation
import org.partiql.eval.internal.routines.internal.isAbsent
import org.partiql.eval.value.Datum
import org.partiql.value.PartiQLValueType
import org.partiql.types.PType

/**
* Note that SOME is normalized to ANY.
* Note that SOME(v) is normalized to ANY(v).
*/
internal object AGG_ANY__BOOL__BOOL : Aggregation {

Expand All @@ -32,7 +32,7 @@ internal object AGG_ANY__BOOL__BOOL : Aggregation {
}

override fun value(): Datum = when (result) {
null -> Datum.nullValue(PartiQLValueType.BOOL)
null -> Datum.nullValue(PType.typeBool())
else -> Datum.boolValue(result!!)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,29 +5,15 @@ package org.partiql.eval.internal.routines

import org.partiql.eval.internal.Aggregation

// internal class AccumulatorAvg(
// private val targetType: PartiQLValueType = PartiQLValueType.DYNAMIC
// ) : Accumulator() {
//
// var sum: Number = 0.0
// var count: Long = 0L
//
// override fun nextValue(value: Datum) {
// checkIsNumberType(funcName = "AVG", value = value)
// this.sum += value.numberValue()
// this.count += 1L
// }
//
// override fun value(): Datum = when (count) {
// 0L -> nullToTargetType(targetType)
// else -> (sum / bigDecimalOf(count)).toTargetType(targetType)
// }
// }

internal object AGG_AVG__TINYINT__TINYINT : Aggregation {

override fun getKey(): String = "AGG_AVG__TINYINT___TINYINT"
internal class AggAvg {

const val

}

internal

internal val AGG_AVG__TINYINT__TINYINT : Aggregation("AGG_AVG__TINYINT___TINYINT") {
override fun accumulator() = TODO("Accumulator not implemented")
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,162 +1,69 @@
// ktlint-disable filename
@file:Suppress("ClassName")
@file:Suppress("ClassName", "unused")

package org.partiql.eval.internal.routines

import org.partiql.spi.connector.sql.builtins.internal.AccumulatorMax
import org.partiql.spi.fn.Agg
import org.partiql.spi.fn.AggSignature
import org.partiql.spi.fn.FnParameter
import org.partiql.value.PType.Kind.DYNAMIC
import org.partiql.value.PType.Kind.DECIMAL_ARBITRARY
import org.partiql.value.PType.Kind.FLOAT32
import org.partiql.value.PType.Kind.FLOAT64
import org.partiql.value.PType.Kind.INT
import org.partiql.value.PType.Kind.SMALLINT
import org.partiql.value.PType.Kind.INT
import org.partiql.value.PType.Kind.BIGINT
import org.partiql.value.PType.Kind.TINYINT


internal object Agg_MAX__TINYINT__TINYINT : Aggregation {

override val signature: AggSignature = AggSignature(
name = "max",
returns = TINYINT,
parameters = listOf(
FnParameter("value", TINYINT),
),
isNullable = true,
isDecomposable = true
)

override fun accumulator(): Accumulator = AccumulatorMax()
}

import org.partiql.eval.internal.Aggregation

internal object Agg_MAX__SMALLINT__SMALLINT : Aggregation {
internal object AGG_MAX__TINYINT__TINYINT : Aggregation {

override val signature: AggSignature = AggSignature(
name = "max",
returns = SMALLINT,
parameters = listOf(
FnParameter("value", SMALLINT),
),
isNullable = true,
isDecomposable = true
)
override fun getKey(): String = "AGG_MAX__TINYINT___TINYINT"

override fun accumulator(): Accumulator = AccumulatorMax()
override fun accumulator() = TODO("Accumulator not implemented")
}

internal object AGG_MAX__SMALLINT__SMALLINT : Aggregation {

internal object Agg_MAX__INT__INT : Aggregation {

override val signature: AggSignature = AggSignature(
name = "max",
returns = INT,
parameters = listOf(
FnParameter("value", INT),
),
isNullable = true,
isDecomposable = true
)
override fun getKey(): String = "AGG_MAX__SMALLINT___SMALLINT"

override fun accumulator(): Accumulator = AccumulatorMax()
override fun accumulator() = TODO("Accumulator not implemented")
}

internal object AGG_MAX__INT__INT : Aggregation {

internal object Agg_MAX__BIGINT__BIGINT : Aggregation {
override fun getKey(): String = "AGG_MAX__INT___INT"

override val signature: AggSignature = AggSignature(
name = "max",
returns = BIGINT,
parameters = listOf(
FnParameter("value", BIGINT),
),
isNullable = true,
isDecomposable = true
)

override fun accumulator(): Accumulator = AccumulatorMax()
override fun accumulator() = TODO("Accumulator not implemented")
}

internal object AGG_MAX__BIGINT__BIGINT : Aggregation {

internal object Agg_MAX__NUMERIC__INT : Aggregation {

override val signature: AggSignature = AggSignature(
name = "max",
returns = INT,
parameters = listOf(
FnParameter("value", INT),
),
isNullable = true,
isDecomposable = true
)
override fun getKey(): String = "AGG_MAX__BIGINT___BIGINT"

override fun accumulator(): Accumulator = AccumulatorMax()
override fun accumulator() = TODO("Accumulator not implemented")
}

internal object AGG_MAX__NUMERIC__INT : Aggregation {

internal object Agg_MAX__DECIMAL_ARBITRARY__DECIMAL_ARBITRARY : Aggregation {

override val signature: AggSignature = AggSignature(
name = "max",
returns = DECIMAL_ARBITRARY,
parameters = listOf(
FnParameter("value", DECIMAL_ARBITRARY),
),
isNullable = true,
isDecomposable = true
)
override fun getKey(): String = "AGG_MAX__NUMERIC___NUMERIC"

override fun accumulator(): Accumulator = AccumulatorMax()
override fun accumulator() = TODO("Accumulator not implemented")
}

internal object AGG_MAX__DECIMAL__DECIMAL : Aggregation {

internal object Agg_MAX__FLOAT32__FLOAT32 : Aggregation {
override fun getKey(): String = "AGG_MAX__NUMERIC___NUMERIC"

override val signature: AggSignature = AggSignature(
name = "max",
returns = FLOAT32,
parameters = listOf(
FnParameter("value", FLOAT32),
),
isNullable = true,
isDecomposable = true
)

override fun accumulator(): Accumulator = AccumulatorMax()
override fun accumulator() = TODO("Accumulator not implemented")
}

internal object AGG_MAX__REAL__REAL : Aggregation {

internal object Agg_MAX__FLOAT64__FLOAT64 : Aggregation {

override val signature: AggSignature = AggSignature(
name = "max",
returns = FLOAT64,
parameters = listOf(
FnParameter("value", FLOAT64),
),
isNullable = true,
isDecomposable = true
)
override fun getKey(): String = "AGG_MAX__REAL___REAL"

override fun accumulator(): Accumulator = AccumulatorMax()
override fun accumulator() = TODO("Accumulator not implemented")
}

internal object AGG_MAX__DOUBLE__DOUBLE : Aggregation {

override fun getKey(): String = "AGG_MAX__SMALLINT___SMALLINT"

override fun accumulator() = TODO("Accumulator not implemented")
}

internal object Agg_MAX__DYNAMIC__DYNAMIC : Aggregation {
internal object AGG_MAX__DYNAMIC__DYNAMIC : Aggregation {

override val signature: AggSignature = AggSignature(
name = "max",
returns = DYNAMIC,
parameters = listOf(
FnParameter("value", DYNAMIC),
),
isNullable = true,
isDecomposable = true
)
override fun getKey(): String = "AGG_MAX__SMALLINT___SMALLINT"

override fun accumulator(): Accumulator = AccumulatorMax()
override fun accumulator() = TODO("Accumulator not implemented")
}
Loading

0 comments on commit 6fcde57

Please sign in to comment.