From 3fa3853724cdde490c23eddfde9c1280f70a2ad0 Mon Sep 17 00:00:00 2001
From: "R. C. Howell"
Date: Tue, 26 Nov 2024 17:22:34 -0500
Subject: [PATCH] Update Datum from PartiQLValue
---
.../java/org/partiql/spi/value/Datum.java | 64 ++++++++++--------
.../spi/function/builtins/FnDateAddMonth.kt | 12 ++--
.../spi/function/builtins/FnDateAddSecond.kt | 12 ++--
.../spi/function/builtins/FnDateAddYear.kt | 12 ++--
.../spi/function/builtins/FnExtract.kt | 65 +++++--------------
.../partiql/spi/function/builtins/FnGte.kt | 8 +--
.../org/partiql/spi/function/builtins/FnLt.kt | 12 ++--
.../partiql/spi/function/builtins/FnLte.kt | 12 ++--
8 files changed, 88 insertions(+), 109 deletions(-)
diff --git a/partiql-spi/src/main/java/org/partiql/spi/value/Datum.java b/partiql-spi/src/main/java/org/partiql/spi/value/Datum.java
index 20fd7b5f7..279a9108b 100644
--- a/partiql-spi/src/main/java/org/partiql/spi/value/Datum.java
+++ b/partiql-spi/src/main/java/org/partiql/spi/value/Datum.java
@@ -9,9 +9,6 @@
import org.partiql.value.PartiQL;
import org.partiql.value.PartiQLValue;
import org.partiql.value.PartiQLValueType;
-import org.partiql.value.datetime.Date;
-import org.partiql.value.datetime.Time;
-import org.partiql.value.datetime.Timestamp;
import java.math.BigDecimal;
import java.math.BigInteger;
@@ -106,6 +103,7 @@ default boolean getBoolean() {
*
* ! ! ! EXPERIMENTAL ! ! ! This is an experimental API under development by the PartiQL maintainers.
*
+ *
* @return the underlying value applicable to the types:
* {@link PartiQLValueType#BINARY},
* {@link PartiQLValueType#BLOB},
@@ -115,7 +113,7 @@ default boolean getBoolean() {
* will throw this exception upon invocation.
* @throws NullPointerException if this instance also returns true on {@link #isNull()}; callers should check that
* {@link #isNull()} returns false before attempting to invoke this method.
- * Please abstain from using this API until given notice otherwise. This may break between iterations without prior notice.
+ * Please abstain from using this API until given notice otherwise. This may break between iterations without prior notice.
* @deprecated BINARY doesn't exist in SQL or Ion. This is subject to deletion. BLOB and CLOB are typically represented
* in a fashion that can support much larger values -- this may be modified at any time.
*/
@@ -126,6 +124,7 @@ default byte[] getBytes() {
/**
* ! ! ! EXPERIMENTAL ! ! ! This is an experimental API under development by the PartiQL maintainers.
+ *
* @return the underlying value applicable to the types:
* {@link PartiQLValueType#BYTE},
* {@link PartiQLValueType#INT8}
@@ -134,7 +133,7 @@ default byte[] getBytes() {
* will throw this exception upon invocation.
* @throws NullPointerException if this instance also returns true on {@link #isNull()}; callers should check that
* {@link #isNull()} returns false before attempting to invoke this method.
- * Please abstain from using this API until given notice otherwise. This may break between iterations without prior notice.
+ * Please abstain from using this API until given notice otherwise. This may break between iterations without prior notice.
* @deprecated BYTE is not present in SQL or Ion. This is subject to deletion.
*/
@Deprecated
@@ -144,7 +143,6 @@ default byte getByte() {
/**
* @return a {@link LocalDate} for DATE, TIMESTAMP, and TIMESTAMPZ types.
- *
* @throws UnsupportedOperationException if type not in (DATE, TIMESTAMP, TIMESTAMPZ)
* @throws NullPointerException if isNull() is true; callers should check to avoid NPEs.
*/
@@ -155,7 +153,6 @@ default LocalDate getLocalDate() {
/**
* @return an {@link OffsetTime} for TIME and TIMESTAMP types.
- *
* @throws UnsupportedOperationException if type not in (TIME, TIMESTAMP)
* @throws NullPointerException if isNull() is true; callers should check to avoid NPEs.
*/
@@ -166,7 +163,6 @@ default LocalTime getLocalTime() {
/**
* @return an {@link OffsetTime} for TIMEZ and TIMESTAMPZ types.
- *
* @throws UnsupportedOperationException if type not in (TIMEZ, TIMESTAMPZ)
* @throws NullPointerException if isNull() is true; callers should check to avoid NPEs.
*/
@@ -177,7 +173,6 @@ default OffsetTime getOffsetTime() {
/**
* @return a {@link LocalDateTime} for TIMESTAMP types.
- *
* @throws UnsupportedOperationException if type not TIMESTAMP
* @throws NullPointerException if isNull() is true; callers should check to avoid NPEs.
*/
@@ -188,7 +183,6 @@ default LocalDateTime getLocalDateTime() {
/**
* @return a {@link OffsetDateTime} for TIMESTAMPZ types.
- *
* @throws UnsupportedOperationException if type not TIMESTAMPZ
* @throws NullPointerException if isNull() is true; callers should check to avoid NPEs.
*/
@@ -199,7 +193,6 @@ default OffsetDateTime getOffsetDateTime() {
/**
* @return a {@link Period} for the INTERVALYM type.
- *
* @throws UnsupportedOperationException if type not in [INTERVAL]
* @throws NullPointerException if isNull() is true; callers should check to avoid NPEs.
*/
@@ -210,7 +203,6 @@ default Period getPeriod() {
/**
* @return a {@link Duration} for the INTERVALDT type.
- *
* @throws UnsupportedOperationException if type not in [INTERVALDT]
* @throws NullPointerException if isNull() is true; callers should check to avoid NPEs.
*/
@@ -433,13 +425,13 @@ default PartiQLValue toPartiQLValue() {
case CLOB:
return this.isNull() ? PartiQL.clobValue(null) : PartiQL.clobValue(this.getBytes());
case DATE:
- return this.isNull() ? PartiQL.dateValue(null) : PartiQL.dateValue(this.getDate());
+ throw new UnsupportedOperationException("Datum date to PartiQLValue is not supported");
case TIMEZ:
- case TIME: // TODO
- return this.isNull() ? PartiQL.timeValue(null) : PartiQL.timeValue(this.getTime());
+ case TIME:
+ throw new UnsupportedOperationException("Datum time/timez to PartiQLValue is not supported");
case TIMESTAMPZ:
case TIMESTAMP:
- return this.isNull() ? PartiQL.timestampValue(null) : PartiQL.timestampValue(this.getTimestamp());
+ throw new UnsupportedOperationException("Datum timestamp/timestampz to PartiQLValue is not supported");
case BAG:
return this.isNull() ? PartiQL.bagValue((Iterable extends PartiQLValue>) null) : PartiQL.bagValue(new PQLToPartiQLIterable(this));
case ARRAY:
@@ -511,17 +503,34 @@ static Datum of(PartiQLValue value) {
case BINARY:
throw new UnsupportedOperationException();
case DATE:
- org.partiql.value.DateValue DATEValue = (org.partiql.value.DateValue) value;
- return new DatumDate(Objects.requireNonNull(DATEValue.getValue()));
+ org.partiql.value.datetime.Date DATEValue = ((org.partiql.value.DateValue) value).getValue();
+ Objects.requireNonNull(DATEValue);
+ LocalDate date = LocalDate.of(DATEValue.getYear(), DATEValue.getMonth(), DATEValue.getDay());
+ return new DatumDate(date);
case INTERVAL:
- org.partiql.value.IntervalValue INTERVALValue = (org.partiql.value.IntervalValue) value;
- return new DatumInterval(Objects.requireNonNull(INTERVALValue.getValue()));
+ throw new UnsupportedOperationException("INTERVAL not implemented");
case TIMESTAMP:
- org.partiql.value.TimestampValue TIMESTAMPValue = (org.partiql.value.TimestampValue) value;
- return new DatumTimestamp(Objects.requireNonNull(TIMESTAMPValue.getValue()));
+ org.partiql.value.datetime.Timestamp TIMESTAMPValue = ((org.partiql.value.TimestampValue) value).getValue();
+ Objects.requireNonNull(TIMESTAMPValue);
+ // calculate seconds precision
+ BigDecimal tsds = TIMESTAMPValue.getDecimalSecond();
+ int tsprec = tsds.scale();
+ int tssecs = tsds.intValue();
+ int tsnano = tsds.remainder(BigDecimal.ONE).movePointRight(tsds.scale()).abs().intValue();
+ // make datum
+ LocalDateTime timestamp = LocalDateTime.of(TIMESTAMPValue.getYear(), TIMESTAMPValue.getMonth(), TIMESTAMPValue.getDay(), TIMESTAMPValue.getHour(), TIMESTAMPValue.getMinute(), tssecs, tsnano);
+ return new DatumTimestamp(timestamp, tsprec);
case TIME:
- org.partiql.value.TimeValue TIMEValue = (org.partiql.value.TimeValue) value;
- return new DatumTime(Objects.requireNonNull(TIMEValue.getValue()));
+ org.partiql.value.datetime.Timestamp TIMEValue = ((org.partiql.value.TimestampValue) value).getValue();
+ Objects.requireNonNull(TIMEValue);
+ // calculate seconds precision
+ BigDecimal tds = TIMEValue.getDecimalSecond();
+ int tprec = tds.scale();
+ int tsecs = tds.intValue();
+ int tnano = tds.remainder(BigDecimal.ONE).movePointRight(tds.scale()).abs().intValue();
+ // make datum
+ LocalTime time = LocalTime.of(TIMEValue.getHour(), TIMEValue.getMinute(), tsecs, tnano);
+ return new DatumTime(time, tprec);
case FLOAT32:
org.partiql.value.Float32Value FLOAT32Value = (org.partiql.value.Float32Value) value;
return new DatumFloat(Objects.requireNonNull(FLOAT32Value.getValue()));
@@ -571,6 +580,7 @@ static Datum nullValue(@NotNull PType type) {
/**
* Returns a typed missing value
* ! EXPERIMENTAL ! This is subject to breaking changes and/or removal without prior notice.
+ *
* @param type the type of the value
* @return a typed missing value
* @deprecated this may not be required. This is subject to removal.
@@ -646,7 +656,6 @@ static Datum string(@NotNull String value) {
}
/**
- *
* @param value the string to place in the varchar
* @return a varchar value with a default length of 255
*/
@@ -656,7 +665,6 @@ static Datum varchar(@NotNull String value) {
}
/**
- *
* @param value the string to place in the varchar
* @return a varchar value
* TODO: Error or coerce here? Right now coerce, though I think this should likely error.
@@ -678,7 +686,6 @@ static Datum varchar(@NotNull String value, int length) {
}
/**
- *
* @param value the string to place in the char
* @return a char value with a default length of 255
*/
@@ -688,7 +695,6 @@ static Datum character(@NotNull String value) {
}
/**
- *
* @param value the string to place in the char
* @return a char value
*/
@@ -801,6 +807,7 @@ static Datum struct(@NotNull Iterable values) {
* {@link java.util.TreeSet} in combination with this {@link Comparator} to implement the before-mentioned
* operations.
*
+ *
* @return the default comparator for {@link Datum}. The comparator orders null values first.
* @see Datum
* @see java.util.TreeSet
@@ -821,6 +828,7 @@ static Comparator comparator() {
* {@link java.util.TreeSet} in combination with this {@link Comparator} to implement the before-mentioned
* operations.
*
+ *
* @param nullsFirst if true, nulls are ordered before non-null values, otherwise after.
* @return the default comparator for {@link Datum}.
* @see Datum
diff --git a/partiql-spi/src/main/kotlin/org/partiql/spi/function/builtins/FnDateAddMonth.kt b/partiql-spi/src/main/kotlin/org/partiql/spi/function/builtins/FnDateAddMonth.kt
index 443d26a81..9785f64af 100644
--- a/partiql-spi/src/main/kotlin/org/partiql/spi/function/builtins/FnDateAddMonth.kt
+++ b/partiql-spi/src/main/kotlin/org/partiql/spi/function/builtins/FnDateAddMonth.kt
@@ -21,7 +21,7 @@ internal val Fn_DATE_ADD_MONTH__INT32_DATE__DATE = Function.static(
) { args ->
val interval = args[0].int
- val datetime = args[1].date
+ val datetime = args[1].localDate
val datetimeValue = datetime
val intervalValue = interval.toLong()
Datum.date(datetimeValue.plusMonths(intervalValue))
@@ -38,7 +38,7 @@ internal val Fn_DATE_ADD_MONTH__INT64_DATE__DATE = Function.static(
) { args ->
val interval = args[0].long
- val datetime = args[1].date
+ val datetime = args[1].localDate
val datetimeValue = datetime
val intervalValue = interval
Datum.date(datetimeValue.plusMonths(intervalValue))
@@ -55,7 +55,7 @@ internal val Fn_DATE_ADD_MONTH__INT_DATE__DATE = Function.static(
) { args ->
val interval = args[0].bigInteger
- val datetime = args[1].date
+ val datetime = args[1].localDate
val datetimeValue = datetime
val intervalValue = try {
interval.toLong()
@@ -76,7 +76,7 @@ internal val Fn_DATE_ADD_MONTH__INT32_TIMESTAMP__TIMESTAMP = Function.static(
) { args ->
val interval = args[0].int
- val datetime = args[1].timestamp
+ val datetime = args[1].localDateTime
val datetimeValue = datetime
val intervalValue = interval.toLong()
Datum.timestamp(datetimeValue.plusMonths(intervalValue))
@@ -93,7 +93,7 @@ internal val Fn_DATE_ADD_MONTH__INT64_TIMESTAMP__TIMESTAMP = Function.static(
) { args ->
val interval = args[0].long
- val datetime = args[1].timestamp
+ val datetime = args[1].localDateTime
val datetimeValue = datetime
val intervalValue = interval
Datum.timestamp(datetimeValue.plusMonths(intervalValue))
@@ -110,7 +110,7 @@ internal val Fn_DATE_ADD_MONTH__INT_TIMESTAMP__TIMESTAMP = Function.static(
) { args ->
val interval = args[0].bigInteger
- val datetime = args[1].timestamp
+ val datetime = args[1].localDateTime
val datetimeValue = datetime
val intervalValue = try {
interval.toLong()
diff --git a/partiql-spi/src/main/kotlin/org/partiql/spi/function/builtins/FnDateAddSecond.kt b/partiql-spi/src/main/kotlin/org/partiql/spi/function/builtins/FnDateAddSecond.kt
index 995ecfd11..acb37d788 100644
--- a/partiql-spi/src/main/kotlin/org/partiql/spi/function/builtins/FnDateAddSecond.kt
+++ b/partiql-spi/src/main/kotlin/org/partiql/spi/function/builtins/FnDateAddSecond.kt
@@ -21,7 +21,7 @@ internal val Fn_DATE_ADD_SECOND__INT32_TIME__TIME = Function.static(
) { args ->
val interval = args[0].int
- val datetime = args[1].time
+ val datetime = args[1].localTime
val datetimeValue = datetime
val intervalValue = interval.toLong()
Datum.time(datetimeValue.plusSeconds(intervalValue))
@@ -38,7 +38,7 @@ internal val Fn_DATE_ADD_SECOND__INT64_TIME__TIME = Function.static(
) { args ->
val interval = args[0].long
- val datetime = args[1].time
+ val datetime = args[1].localTime
val datetimeValue = datetime
val intervalValue = interval
Datum.time(datetimeValue.plusSeconds(intervalValue))
@@ -55,7 +55,7 @@ internal val Fn_DATE_ADD_SECOND__INT_TIME__TIME = Function.static(
) { args ->
val interval = args[0].bigInteger
- val datetime = args[1].time
+ val datetime = args[1].localTime
val datetimeValue = datetime
val intervalValue = try {
interval.toLong()
@@ -76,7 +76,7 @@ internal val Fn_DATE_ADD_SECOND__INT32_TIMESTAMP__TIMESTAMP = Function.static(
) { args ->
val interval = args[0].int
- val datetime = args[1].timestamp
+ val datetime = args[1].localDateTime
val datetimeValue = datetime
val intervalValue = interval.toLong()
Datum.timestamp(datetimeValue.plusSeconds(intervalValue))
@@ -93,7 +93,7 @@ internal val Fn_DATE_ADD_SECOND__INT64_TIMESTAMP__TIMESTAMP = Function.static(
) { args ->
val interval = args[0].long
- val datetime = args[1].timestamp
+ val datetime = args[1].localDateTime
val datetimeValue = datetime
val intervalValue = interval
Datum.timestamp(datetimeValue.plusSeconds(intervalValue))
@@ -110,7 +110,7 @@ internal val Fn_DATE_ADD_SECOND__INT_TIMESTAMP__TIMESTAMP = Function.static(
) { args ->
val interval = args[0].bigInteger
- val datetime = args[1].timestamp
+ val datetime = args[1].localDateTime
val datetimeValue = datetime
val intervalValue = try {
interval.toLong()
diff --git a/partiql-spi/src/main/kotlin/org/partiql/spi/function/builtins/FnDateAddYear.kt b/partiql-spi/src/main/kotlin/org/partiql/spi/function/builtins/FnDateAddYear.kt
index 3ba1f66e1..5e2bc641f 100644
--- a/partiql-spi/src/main/kotlin/org/partiql/spi/function/builtins/FnDateAddYear.kt
+++ b/partiql-spi/src/main/kotlin/org/partiql/spi/function/builtins/FnDateAddYear.kt
@@ -21,7 +21,7 @@ internal val Fn_DATE_ADD_YEAR__INT32_DATE__DATE = Function.static(
) { args ->
val interval = args[0].int
- val datetime = args[1].date
+ val datetime = args[1].localDate
val datetimeValue = datetime
val intervalValue = interval.toLong()
Datum.date(datetimeValue.plusYears(intervalValue))
@@ -38,7 +38,7 @@ internal val Fn_DATE_ADD_YEAR__INT64_DATE__DATE = Function.static(
) { args ->
val interval = args[0].long
- val datetime = args[1].date
+ val datetime = args[1].localDate
val datetimeValue = datetime
val intervalValue = interval
Datum.date(datetimeValue.plusYears(intervalValue))
@@ -55,7 +55,7 @@ internal val Fn_DATE_ADD_YEAR__INT_DATE__DATE = Function.static(
) { args ->
val interval = args[0].bigInteger
- val datetime = args[1].date
+ val datetime = args[1].localDate
val datetimeValue = datetime
val intervalValue = try {
interval.toLong()
@@ -76,7 +76,7 @@ internal val Fn_DATE_ADD_YEAR__INT32_TIMESTAMP__TIMESTAMP = Function.static(
) { args ->
val interval = args[0].int
- val datetime = args[1].timestamp
+ val datetime = args[1].localDateTime
val datetimeValue = datetime
val intervalValue = interval.toLong()
Datum.timestamp(datetimeValue.plusYears(intervalValue))
@@ -93,7 +93,7 @@ internal val Fn_DATE_ADD_YEAR__INT64_TIMESTAMP__TIMESTAMP = Function.static(
) { args ->
val interval = args[0].long
- val datetime = args[1].timestamp
+ val datetime = args[1].localDateTime
val datetimeValue = datetime
val intervalValue = interval
Datum.timestamp(datetimeValue.plusYears(intervalValue))
@@ -110,7 +110,7 @@ internal val Fn_DATE_ADD_YEAR__INT_TIMESTAMP__TIMESTAMP = Function.static(
) { args ->
val interval = args[0].bigInteger
- val datetime = args[1].timestamp
+ val datetime = args[1].localDateTime
val datetimeValue = datetime
val intervalValue = try {
interval.toLong()
diff --git a/partiql-spi/src/main/kotlin/org/partiql/spi/function/builtins/FnExtract.kt b/partiql-spi/src/main/kotlin/org/partiql/spi/function/builtins/FnExtract.kt
index aca766682..b62119f5d 100644
--- a/partiql-spi/src/main/kotlin/org/partiql/spi/function/builtins/FnExtract.kt
+++ b/partiql-spi/src/main/kotlin/org/partiql/spi/function/builtins/FnExtract.kt
@@ -21,7 +21,7 @@ internal val Fn_EXTRACT_YEAR__DATE__INT32 = Function.static(
),
) { args ->
- val v = args[0].date
+ val v = args[0].localDate
Datum.integer(v.year)
}
@@ -34,7 +34,7 @@ internal val Fn_EXTRACT_YEAR__TIMESTAMP__INT32 = Function.static(
),
) { args ->
- val v = args[0].timestamp
+ val v = args[0].localDateTime
Datum.integer(v.year)
}
@@ -50,8 +50,8 @@ internal val Fn_EXTRACT_MONTH__DATE__INT32 = Function.static(
),
) { args ->
- val v = args[0].date
- Datum.integer(v.month)
+ val v = args[0].localDate
+ Datum.integer(v.monthValue)
}
internal val Fn_EXTRACT_MONTH__TIMESTAMP__INT32 = Function.static(
@@ -63,8 +63,8 @@ internal val Fn_EXTRACT_MONTH__TIMESTAMP__INT32 = Function.static(
),
) { args ->
- val v = args[0].timestamp
- Datum.integer(v.month)
+ val v = args[0].localDateTime
+ Datum.integer(v.monthValue)
}
//
@@ -80,8 +80,8 @@ internal val Fn_EXTRACT_DAY__DATE__INT32 = Function.static(
),
) { args ->
- val v = args[0].date
- Datum.integer(v.day)
+ val v = args[0].localDate
+ Datum.integer(v.dayOfMonth)
}
internal val Fn_EXTRACT_DAY__TIMESTAMP__INT32 = Function.static(
@@ -93,8 +93,8 @@ internal val Fn_EXTRACT_DAY__TIMESTAMP__INT32 = Function.static(
),
) { args ->
- val v = args[0].timestamp
- Datum.integer(v.day)
+ val v = args[0].localDateTime
+ Datum.integer(v.dayOfMonth)
}
//
@@ -109,7 +109,7 @@ internal val Fn_EXTRACT_HOUR__TIME__INT32 = Function.static(
),
) { args ->
- val v = args[0].time
+ val v = args[0].localTime
Datum.integer(v.hour)
}
@@ -122,7 +122,7 @@ internal val Fn_EXTRACT_HOUR__TIMESTAMP__INT32 = Function.static(
),
) { args ->
- val v = args[0].timestamp
+ val v = args[0].localDateTime
Datum.integer(v.hour)
}
@@ -138,7 +138,7 @@ internal val Fn_EXTRACT_MINUTE__TIME__INT32 = Function.static(
),
) { args ->
- val v = args[0].time
+ val v = args[0].localTime
Datum.integer(v.minute)
}
@@ -151,39 +151,10 @@ internal val Fn_EXTRACT_MINUTE__TIMESTAMP__INT32 = Function.static(
),
) { args ->
- val v = args[0].timestamp
+ val v = args[0].localDateTime
Datum.integer(v.minute)
}
-//
-// Extract Second
-//
-internal val Fn_EXTRACT_SECOND__TIME__DECIMAL_ARBITRARY = Function.static(
-
- name = "extract_second",
- returns = PType.decimal(),
- parameters = arrayOf(
- Parameter("datetime", PType.time(6)),
- ),
-
-) { args ->
- val v = args[0].time
- Datum.decimal(v.decimalSecond)
-}
-
-internal val Fn_EXTRACT_SECOND__TIMESTAMP__DECIMAL_ARBITRARY = Function.static(
-
- name = "extract_second",
- returns = PType.decimal(),
- parameters = arrayOf(
- Parameter("datetime", PType.timestamp(6)),
- ),
-
-) { args ->
- val v = args[0].timestamp
- Datum.decimal(v.decimalSecond)
-}
-
//
// Extract Timezone Hour
//
@@ -196,7 +167,7 @@ internal val Fn_EXTRACT_TIMEZONE_HOUR__TIME__INT32 = Function.static(
),
) { args ->
- val v = args[0].time
+ val v = args[0].offsetTime
when (val tz = v.timeZone) {
TimeZone.UnknownTimeZone -> Datum.integer(0) // TODO: Should this be NULL?
is TimeZone.UtcOffset -> Datum.integer(tz.tzHour)
@@ -213,7 +184,7 @@ internal val Fn_EXTRACT_TIMEZONE_HOUR__TIMESTAMP__INT32 = Function.static(
),
) { args ->
- val v = args[0].timestamp
+ val v = args[0].localDateTime
when (val tz = v.timeZone) {
TimeZone.UnknownTimeZone -> Datum.integer(0) // TODO: Should this be NULL?
is TimeZone.UtcOffset -> Datum.integer(tz.tzHour)
@@ -233,7 +204,7 @@ internal val Fn_EXTRACT_TIMEZONE_MINUTE__TIME__INT32 = Function.static(
),
) { args ->
- val v = args[0].time
+ val v = args[0].localTime
when (val tz = v.timeZone) {
TimeZone.UnknownTimeZone -> Datum.integer(0) // TODO: Should this be NULL?
is TimeZone.UtcOffset -> Datum.integer(tz.tzMinute)
@@ -250,7 +221,7 @@ internal val Fn_EXTRACT_TIMEZONE_MINUTE__TIMESTAMP__INT32 = Function.static(
),
) { args ->
- val v = args[0].timestamp
+ val v = args[0].localDateTime
when (val tz = v.timeZone) {
TimeZone.UnknownTimeZone -> Datum.integer(0) // TODO: Should this be NULL?
is TimeZone.UtcOffset -> Datum.integer(tz.tzMinute)
diff --git a/partiql-spi/src/main/kotlin/org/partiql/spi/function/builtins/FnGte.kt b/partiql-spi/src/main/kotlin/org/partiql/spi/function/builtins/FnGte.kt
index b93ef52df..30d6f8d4e 100644
--- a/partiql-spi/src/main/kotlin/org/partiql/spi/function/builtins/FnGte.kt
+++ b/partiql-spi/src/main/kotlin/org/partiql/spi/function/builtins/FnGte.kt
@@ -168,8 +168,8 @@ internal val Fn_GTE__TIME_TIME__BOOL = Function.static(
),
) { args ->
- val lhs = args[0].time
- val rhs = args[1].time
+ val lhs = args[0].localTime
+ val rhs = args[1].localTime
Datum.bool(lhs >= rhs)
}
@@ -183,8 +183,8 @@ internal val Fn_GTE__TIMESTAMP_TIMESTAMP__BOOL = Function.static(
),
) { args ->
- val lhs = args[0].timestamp
- val rhs = args[1].timestamp
+ val lhs = args[0].localDateTime
+ val rhs = args[1].localDateTime
Datum.bool(lhs >= rhs)
}
diff --git a/partiql-spi/src/main/kotlin/org/partiql/spi/function/builtins/FnLt.kt b/partiql-spi/src/main/kotlin/org/partiql/spi/function/builtins/FnLt.kt
index 461c9d4ba..4ac6ba8dd 100644
--- a/partiql-spi/src/main/kotlin/org/partiql/spi/function/builtins/FnLt.kt
+++ b/partiql-spi/src/main/kotlin/org/partiql/spi/function/builtins/FnLt.kt
@@ -153,8 +153,8 @@ internal val Fn_LT__DATE_DATE__BOOL = Function.static(
),
) { args ->
- val lhs = args[0].date
- val rhs = args[1].date
+ val lhs = args[0].localDate
+ val rhs = args[1].localDate
Datum.bool(lhs < rhs)
}
@@ -168,8 +168,8 @@ internal val Fn_LT__TIME_TIME__BOOL = Function.static(
),
) { args ->
- val lhs = args[0].time
- val rhs = args[1].time
+ val lhs = args[0].localTime
+ val rhs = args[1].localTime
Datum.bool(lhs < rhs)
}
@@ -183,8 +183,8 @@ internal val Fn_LT__TIMESTAMP_TIMESTAMP__BOOL = Function.static(
),
) { args ->
- val lhs = args[0].timestamp
- val rhs = args[1].timestamp
+ val lhs = args[0].localDateTime
+ val rhs = args[1].localDateTime
Datum.bool(lhs < rhs)
}
diff --git a/partiql-spi/src/main/kotlin/org/partiql/spi/function/builtins/FnLte.kt b/partiql-spi/src/main/kotlin/org/partiql/spi/function/builtins/FnLte.kt
index a2c2b4e28..d105f47d1 100644
--- a/partiql-spi/src/main/kotlin/org/partiql/spi/function/builtins/FnLte.kt
+++ b/partiql-spi/src/main/kotlin/org/partiql/spi/function/builtins/FnLte.kt
@@ -153,8 +153,8 @@ internal val Fn_LTE__DATE_DATE__BOOL = Function.static(
),
) { args ->
- val lhs = args[0].date
- val rhs = args[1].date
+ val lhs = args[0].localDate
+ val rhs = args[1].localDate
Datum.bool(lhs <= rhs)
}
@@ -168,8 +168,8 @@ internal val Fn_LTE__TIME_TIME__BOOL = Function.static(
),
) { args ->
- val lhs = args[0].time
- val rhs = args[1].time
+ val lhs = args[0].localTime
+ val rhs = args[1].localTime
Datum.bool(lhs <= rhs)
}
@@ -183,8 +183,8 @@ internal val Fn_LTE__TIMESTAMP_TIMESTAMP__BOOL = Function.static(
),
) { args ->
- val lhs = args[0].timestamp
- val rhs = args[1].timestamp
+ val lhs = args[0].localDateTime
+ val rhs = args[1].localDateTime
Datum.bool(lhs <= rhs)
}