Skip to content

initial implementation for like, between and in #1373

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 2 commits into from
Feb 19, 2024
Merged
Show file tree
Hide file tree
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 @@ -7,6 +7,16 @@ import org.partiql.spi.fn.Fn
import org.partiql.spi.fn.FnExperimental
import org.partiql.spi.fn.FnParameter
import org.partiql.spi.fn.FnSignature
import org.partiql.value.ClobValue
import org.partiql.value.DateValue
import org.partiql.value.DecimalValue
import org.partiql.value.Float32Value
import org.partiql.value.Float64Value
import org.partiql.value.Int16Value
import org.partiql.value.Int32Value
import org.partiql.value.Int64Value
import org.partiql.value.Int8Value
import org.partiql.value.IntValue
import org.partiql.value.PartiQLValue
import org.partiql.value.PartiQLValueExperimental
import org.partiql.value.PartiQLValueType.BOOL
Expand All @@ -24,6 +34,11 @@ import org.partiql.value.PartiQLValueType.STRING
import org.partiql.value.PartiQLValueType.SYMBOL
import org.partiql.value.PartiQLValueType.TIME
import org.partiql.value.PartiQLValueType.TIMESTAMP
import org.partiql.value.TextValue
import org.partiql.value.TimeValue
import org.partiql.value.TimestampValue
import org.partiql.value.boolValue
import org.partiql.value.check

@OptIn(PartiQLValueExperimental::class, FnExperimental::class)
internal object Fn_BETWEEN__INT8_INT8_INT8__BOOL : Fn {
Expand All @@ -41,7 +56,10 @@ internal object Fn_BETWEEN__INT8_INT8_INT8__BOOL : Fn {
)

override fun invoke(args: Array<PartiQLValue>): PartiQLValue {
TODO("Function between not implemented")
val value = args[0].check<Int8Value>().value!!
val lower = args[1].check<Int8Value>().value!!
val upper = args[2].check<Int8Value>().value!!
return boolValue(value in lower..upper)
}
}

Expand All @@ -61,7 +79,10 @@ internal object Fn_BETWEEN__INT16_INT16_INT16__BOOL : Fn {
)

override fun invoke(args: Array<PartiQLValue>): PartiQLValue {
TODO("Function between not implemented")
val value = args[0].check<Int16Value>().value!!
val lower = args[1].check<Int16Value>().value!!
val upper = args[2].check<Int16Value>().value!!
return boolValue(value in lower..upper)
}
}

Expand All @@ -81,7 +102,10 @@ internal object Fn_BETWEEN__INT32_INT32_INT32__BOOL : Fn {
)

override fun invoke(args: Array<PartiQLValue>): PartiQLValue {
TODO("Function between not implemented")
val value = args[0].check<Int32Value>().value!!
val lower = args[1].check<Int32Value>().value!!
val upper = args[2].check<Int32Value>().value!!
return boolValue(value in lower..upper)
}
}

Expand All @@ -101,7 +125,10 @@ internal object Fn_BETWEEN__INT64_INT64_INT64__BOOL : Fn {
)

override fun invoke(args: Array<PartiQLValue>): PartiQLValue {
TODO("Function between not implemented")
val value = args[0].check<Int64Value>().value!!
val lower = args[1].check<Int64Value>().value!!
val upper = args[2].check<Int64Value>().value!!
return boolValue(value in lower..upper)
}
}

Expand All @@ -121,7 +148,10 @@ internal object Fn_BETWEEN__INT_INT_INT__BOOL : Fn {
)

override fun invoke(args: Array<PartiQLValue>): PartiQLValue {
TODO("Function between not implemented")
val value = args[0].check<IntValue>().value!!
val lower = args[1].check<IntValue>().value!!
val upper = args[2].check<IntValue>().value!!
return boolValue(value in lower..upper)
}
}

Expand All @@ -141,7 +171,10 @@ internal object Fn_BETWEEN__DECIMAL_ARBITRARY_DECIMAL_ARBITRARY_DECIMAL_ARBITRAR
)

override fun invoke(args: Array<PartiQLValue>): PartiQLValue {
TODO("Function between not implemented")
val value = args[0].check<DecimalValue>().value!!
val lower = args[1].check<DecimalValue>().value!!
val upper = args[2].check<DecimalValue>().value!!
return boolValue(value in lower..upper)
}
}

Expand All @@ -161,7 +194,10 @@ internal object Fn_BETWEEN__FLOAT32_FLOAT32_FLOAT32__BOOL : Fn {
)

override fun invoke(args: Array<PartiQLValue>): PartiQLValue {
TODO("Function between not implemented")
val value = args[0].check<Float32Value>().value!!
val lower = args[1].check<Float32Value>().value!!
val upper = args[2].check<Float32Value>().value!!
return boolValue(value in lower..upper)
}
}

Expand All @@ -181,7 +217,10 @@ internal object Fn_BETWEEN__FLOAT64_FLOAT64_FLOAT64__BOOL : Fn {
)

override fun invoke(args: Array<PartiQLValue>): PartiQLValue {
TODO("Function between not implemented")
val value = args[0].check<Float64Value>().value!!
val lower = args[1].check<Float64Value>().value!!
val upper = args[2].check<Float64Value>().value!!
return boolValue(value in lower..upper)
}
}

Expand All @@ -201,7 +240,10 @@ internal object Fn_BETWEEN__STRING_STRING_STRING__BOOL : Fn {
)

override fun invoke(args: Array<PartiQLValue>): PartiQLValue {
TODO("Function between not implemented")
val value = args[0].check<TextValue<String>>().value!!
val lower = args[1].check<TextValue<String>>().value!!
val upper = args[2].check<TextValue<String>>().value!!
return boolValue(value in lower..upper)
}
}

Expand All @@ -221,7 +263,10 @@ internal object Fn_BETWEEN__SYMBOL_SYMBOL_SYMBOL__BOOL : Fn {
)

override fun invoke(args: Array<PartiQLValue>): PartiQLValue {
TODO("Function between not implemented")
val value = args[0].check<TextValue<String>>().value!!
val lower = args[1].check<TextValue<String>>().value!!
val upper = args[2].check<TextValue<String>>().value!!
return boolValue(value in lower..upper)
}
}

Expand All @@ -241,7 +286,10 @@ internal object Fn_BETWEEN__CLOB_CLOB_CLOB__BOOL : Fn {
)

override fun invoke(args: Array<PartiQLValue>): PartiQLValue {
TODO("Function between not implemented")
val value = args[0].check<ClobValue>().value!!.toString(Charsets.UTF_8)
val lower = args[1].check<ClobValue>().value!!.toString(Charsets.UTF_8)
val upper = args[2].check<ClobValue>().value!!.toString(Charsets.UTF_8)
return boolValue(value in lower..upper)
}
}

Expand All @@ -261,7 +309,10 @@ internal object Fn_BETWEEN__DATE_DATE_DATE__BOOL : Fn {
)

override fun invoke(args: Array<PartiQLValue>): PartiQLValue {
TODO("Function between not implemented")
val value = args[0].check<DateValue>().value!!
val lower = args[1].check<DateValue>().value!!
val upper = args[2].check<DateValue>().value!!
return boolValue(value in lower..upper)
}
}

Expand All @@ -281,7 +332,10 @@ internal object Fn_BETWEEN__TIME_TIME_TIME__BOOL : Fn {
)

override fun invoke(args: Array<PartiQLValue>): PartiQLValue {
TODO("Function between not implemented")
val value = args[0].check<TimeValue>().value!!
val lower = args[1].check<TimeValue>().value!!
val upper = args[2].check<TimeValue>().value!!
return boolValue(value in lower..upper)
}
}

Expand All @@ -301,6 +355,9 @@ internal object Fn_BETWEEN__TIMESTAMP_TIMESTAMP_TIMESTAMP__BOOL : Fn {
)

override fun invoke(args: Array<PartiQLValue>): PartiQLValue {
TODO("Function between not implemented")
val value = args[0].check<TimestampValue>().value!!
val lower = args[1].check<TimestampValue>().value!!
val upper = args[2].check<TimestampValue>().value!!
return boolValue(value in lower..upper)
}
}
Loading