From 483e693b4fa838aab85cfc451b63403b7cabcde8 Mon Sep 17 00:00:00 2001
From: "R. C. Howell"
Date: Wed, 18 Dec 2024 15:56:26 -0800
Subject: [PATCH 1/3] Adds DatumWriter for most types
---
docs/wiki/v1/streams.md | 97 ++
partiql-spi/api/partiql-spi.api | 850 +++++++++++++++++-
.../java/org/partiql/spi/stream/PSink.java | 159 ++++
.../java/org/partiql/spi/stream/PSource.java | 83 ++
.../java/org/partiql/spi/value/Datum.java | 25 +-
.../org/partiql/spi/value/DatumWriter.java | 16 -
.../org/partiql/spi/value/DatumWriter.kt | 98 ++
.../partiql/spi/value/ion/IonDatumWriter.kt | 15 -
.../org/partiql/spi/value/ion/IonSink.kt | 364 ++++++++
.../partiql/spi/value/ion/IonStreamTest.kt | 168 ++++
.../main/java/org/partiql/types/PType.java | 2 +
11 files changed, 1838 insertions(+), 39 deletions(-)
create mode 100644 docs/wiki/v1/streams.md
create mode 100644 partiql-spi/src/main/java/org/partiql/spi/stream/PSink.java
create mode 100644 partiql-spi/src/main/java/org/partiql/spi/stream/PSource.java
delete mode 100644 partiql-spi/src/main/java/org/partiql/spi/value/DatumWriter.java
create mode 100644 partiql-spi/src/main/kotlin/org/partiql/spi/value/DatumWriter.kt
delete mode 100644 partiql-spi/src/main/kotlin/org/partiql/spi/value/ion/IonDatumWriter.kt
create mode 100644 partiql-spi/src/main/kotlin/org/partiql/spi/value/ion/IonSink.kt
create mode 100644 partiql-spi/src/test/kotlin/org/partiql/spi/value/ion/IonStreamTest.kt
diff --git a/docs/wiki/v1/streams.md b/docs/wiki/v1/streams.md
new file mode 100644
index 0000000000..4fac790da9
--- /dev/null
+++ b/docs/wiki/v1/streams.md
@@ -0,0 +1,97 @@
+# PartiQL Data Streams
+
+*This document defines the PSink and PSource in relation to Datum and Java primitives*
+
+* * *
+
+### Background
+
+We have defined
+an [encoding of PartiQL values using the Ion data format](https://quip-amazon.com/5Su8AQhKG5xA/PartiQL-Values-in-Ion),
+but how does this fit in? Let’s look at two questions.
+
+1. How does PartiQL represent values in memory?
+2. How does PartiQL read values from a stream into memory?
+
+An in-memory PartiQL value has a layer of indirection between the Java primitive and its view to the rest of the
+program. This is called the “Datum” and is a fat interface which allows the partiql-lang-kotlin engine to not worry
+about a value’s Java type, and instead switch on an int tag (ptype) to then pull out a value. Effectively the fat
+interface removes checking classes and casting with tag checking then accessing without a cast. It’s effectively a
+unifying interface over the old values, so how does the variant fit in?
+
+A variant is an implementation of a Datum whose value is opaque to the rest of the system. When the system checks the
+tag, it simply gets back “variant” where T might tell us a set of capabilities (or traits) this type system / value
+has. This value is not lowered into a PartiQL value such as an INT or ARRAY, but is kept in its “container” or “box”.
+Think of the variant types of other engines or jsonb of PostgreSQL.
+
+So how does PartiQL read values from a stream into Datums, and how does it handle variants? It depends because an
+encoding may include a data type or it may not. Also, the reader itself may expect a type (or not). Consider that a
+PartiQL value carries a type with it along with the value itself.
+
+## Writing Data
+
+### PSink
+
+The PSink interface is used to write PartiQL data. It has APIs just like the IonWriter, and similarly, it has different
+implementations for the actual encoding like how Ion has both a text and a binary encoding. A PSink is used without any
+assumptions about the actual encoding.
+
+### DatumWriter
+
+The DatumWriter is a class which facilitates writing datums via a PSink implementation; it is handles materializing a
+datum and calling the appropriate sink methods.
+
+**Example**
+
+```kotlin
+val writer = DatumWriter.standard(sink)
+writer.write(datum1)
+writer.write(datum2)
+writer.write(datum3)
+writer.close()
+```
+
+### IonSink
+
+This example shows how to encode a datum as Ion; type decorations are omitted where possible.
+
+```kotlin
+val sink = IonSink(System.out) // printing
+val writer = DatumWriter(sink)
+
+// bool
+writer.write(Datum.bool(true)) // >> true
+
+// ints
+writer.write(Datum.smallint(1)) // >> smallint::1
+writer.write(Datum.int(2)) // >> int::2
+writer.write(Datum.bigint(3)) // >> 3
+
+// exact and approx numeric
+writer.write(Datum.decimal(BigDecimal("3.14"), 3, 2)) // >> ((decimal 3 2) 3.14)
+writer.write(Datum.real(3.14f)) // >> real::3.14e0
+writer.write(Datum.doublePrecision(3.14)) // >> 3.14e0
+
+// char strings
+writer.write(Datum.char("abc", 3)) // >> ((char 3) "abc")
+writer.write(Datum.varchar("abc", 3)) // >> ((varchar 3) "abc")
+writer.write(Datum.string("abc")) // >> "abc"
+
+// lobs
+writer.write(Datum.clob("hello".toByteArray()), 5) // >> {{ "hello" }}
+writer.write(Datum.blob("hello".toByteArray()), 5) // >> {{ aGVsbG8= }}
+
+// datetime
+// TODO blocked on https://github.com/partiql/partiql-lang-kotlin/pull/1656
+
+// ion
+
+```
+
+## Reading Data
+
+### DatumReader
+
+### PSource
+
+PLACEHOLDER
diff --git a/partiql-spi/api/partiql-spi.api b/partiql-spi/api/partiql-spi.api
index 13636b03f6..4b4a79f7f5 100644
--- a/partiql-spi/api/partiql-spi.api
+++ b/partiql-spi/api/partiql-spi.api
@@ -464,8 +464,67 @@ public final class org/partiql/spi/function/Routine$DefaultImpls {
public static fun getParameters (Lorg/partiql/spi/function/Routine;)[Lorg/partiql/spi/function/Parameter;
}
+public abstract interface class org/partiql/spi/stream/PSink {
+ public fun close ()V
+ public fun finish ()V
+ public fun flush ()V
+ public abstract fun setType (Lorg/partiql/types/PType;)V
+ public abstract fun stepIn (I)V
+ public abstract fun stepOut ()V
+ public abstract fun writeBigint (J)V
+ public abstract fun writeBlob ([B)V
+ public abstract fun writeBool (Z)V
+ public abstract fun writeChar (Ljava/lang/String;)V
+ public abstract fun writeClob ([B)V
+ public abstract fun writeDate (Lorg/partiql/value/datetime/Date;)V
+ public abstract fun writeDecimal (Ljava/math/BigDecimal;)V
+ public abstract fun writeDouble (D)V
+ public abstract fun writeField (Ljava/lang/String;)V
+ public abstract fun writeInt (I)V
+ public abstract fun writeMissing ()V
+ public abstract fun writeNull ()V
+ public abstract fun writeNumeric (Ljava/math/BigDecimal;)V
+ public abstract fun writeReal (F)V
+ public abstract fun writeSmallint (S)V
+ public abstract fun writeString (Ljava/lang/String;)V
+ public abstract fun writeTime (Lorg/partiql/value/datetime/Time;)V
+ public abstract fun writeTimestamp (Lorg/partiql/value/datetime/Timestamp;)V
+ public abstract fun writeTimestampz (Lorg/partiql/value/datetime/Timestamp;)V
+ public abstract fun writeTimez (Lorg/partiql/value/datetime/Time;)V
+ public abstract fun writeTinyint (B)V
+ public abstract fun writeVarchar (Ljava/lang/String;)V
+ public abstract fun writeVariant (Ljava/lang/Object;)V
+}
+
+public abstract interface class org/partiql/spi/stream/PSource {
+ public fun close ()V
+ public abstract fun next ()Lorg/partiql/types/PType;
+ public abstract fun readBigint ()J
+ public abstract fun readBlob ()[B
+ public abstract fun readBool ()Z
+ public abstract fun readChar ()Ljava/lang/String;
+ public abstract fun readClob ()[B
+ public abstract fun readDate ()Lorg/partiql/value/datetime/Date;
+ public abstract fun readDecimal ()Ljava/math/BigDecimal;
+ public abstract fun readDouble ()D
+ public abstract fun readField (Ljava/lang/String;)Ljava/lang/String;
+ public abstract fun readInt ()I
+ public abstract fun readReal ()F
+ public abstract fun readSmallint ()S
+ public abstract fun readString ()Ljava/lang/String;
+ public abstract fun readTime ()Lorg/partiql/value/datetime/Time;
+ public abstract fun readTimestamp ()Lorg/partiql/value/datetime/Timestamp;
+ public abstract fun readTimestampz ()Lorg/partiql/value/datetime/Timestamp;
+ public abstract fun readTimez ()Lorg/partiql/value/datetime/Time;
+ public abstract fun readTinyint ()B
+ public abstract fun readVarchar ()Ljava/lang/String;
+ public abstract fun stepIn ()V
+ public abstract fun stepOut ()V
+}
+
public abstract interface class org/partiql/spi/value/Datum : java/lang/Iterable {
public static fun array (Ljava/lang/Iterable;)Lorg/partiql/spi/value/Datum;
+ public static fun array (Ljava/lang/Iterable;Lorg/partiql/types/PType;)Lorg/partiql/spi/value/Datum;
public static fun bag (Ljava/lang/Iterable;)Lorg/partiql/spi/value/Datum;
public static fun bigint (J)Lorg/partiql/spi/value/Datum;
public static fun blob ([B)Lorg/partiql/spi/value/Datum;
@@ -540,8 +599,10 @@ public class org/partiql/spi/value/DatumReader$Builder {
public fun register (Lorg/partiql/spi/value/Encoding;Lorg/partiql/spi/value/DatumReader;)Lorg/partiql/spi/value/DatumReader$Builder;
}
-public abstract interface class org/partiql/spi/value/DatumWriter : java/lang/AutoCloseable {
- public abstract fun write (Lorg/partiql/spi/value/Datum;)Lorg/partiql/spi/value/DatumWriter;
+public final class org/partiql/spi/value/DatumWriter : java/lang/AutoCloseable {
+ public fun (Lorg/partiql/spi/stream/PSink;)V
+ public fun close ()V
+ public final fun write (Lorg/partiql/spi/value/Datum;)V
}
public class org/partiql/spi/value/Encoding : org/partiql/spi/Enum {
@@ -557,6 +618,791 @@ public abstract interface class org/partiql/spi/value/Field {
public static fun of (Ljava/lang/String;Lorg/partiql/spi/value/Datum;)Lorg/partiql/spi/value/Field;
}
+<<<<<<< HEAD
+=======
+<<<<<<< HEAD
+=======
+public final class org/partiql/spi/value/ion/IonSink : org/partiql/spi/stream/PSink {
+ public static final field Companion Lorg/partiql/spi/value/ion/IonSink$Companion;
+ public fun (Lcom/amazon/ion/IonWriter;Ljava/util/BitSet;)V
+ public static final fun binary (Ljava/io/OutputStream;)Lorg/partiql/spi/value/ion/IonSink;
+ public static final fun binary (Ljava/io/OutputStream;[I)Lorg/partiql/spi/value/ion/IonSink;
+ public fun close ()V
+ public static final fun decorated ()Lorg/partiql/spi/value/ion/IonSink$Builder;
+ public static final fun elided ()Lorg/partiql/spi/value/ion/IonSink$Builder;
+ public fun finish ()V
+ public fun flush ()V
+ public static final fun pretty (Ljava/lang/Appendable;)Lorg/partiql/spi/value/ion/IonSink;
+ public static final fun pretty (Ljava/lang/Appendable;[I)Lorg/partiql/spi/value/ion/IonSink;
+ public fun setType (Lorg/partiql/types/PType;)V
+ public static final fun standard ()Lorg/partiql/spi/value/ion/IonSink$Builder;
+ public static final fun standard (Lcom/amazon/ion/IonWriter;)Lorg/partiql/spi/value/ion/IonSink;
+ public fun stepIn (I)V
+ public fun stepOut ()V
+ public static final fun text (Ljava/lang/Appendable;)Lorg/partiql/spi/value/ion/IonSink;
+ public static final fun text (Ljava/lang/Appendable;[I)Lorg/partiql/spi/value/ion/IonSink;
+ public fun writeBigint (J)V
+ public fun writeBlob ([B)V
+ public fun writeBool (Z)V
+ public fun writeChar (Ljava/lang/String;)V
+ public fun writeClob ([B)V
+ public fun writeDate (Lorg/partiql/value/datetime/Date;)V
+ public fun writeDecimal (Ljava/math/BigDecimal;)V
+ public fun writeDouble (D)V
+ public fun writeField (Ljava/lang/String;)V
+ public fun writeInt (I)V
+ public fun writeMissing ()V
+ public fun writeNull ()V
+ public fun writeNumeric (Ljava/math/BigDecimal;)V
+ public fun writeReal (F)V
+ public fun writeSmallint (S)V
+ public fun writeString (Ljava/lang/String;)V
+ public fun writeTime (Lorg/partiql/value/datetime/Time;)V
+ public fun writeTimestamp (Lorg/partiql/value/datetime/Timestamp;)V
+ public fun writeTimestampz (Lorg/partiql/value/datetime/Timestamp;)V
+ public fun writeTimez (Lorg/partiql/value/datetime/Time;)V
+ public fun writeTinyint (B)V
+ public fun writeVarchar (Ljava/lang/String;)V
+ public fun writeVariant (Ljava/lang/Object;)V
+}
+
+public final class org/partiql/spi/value/ion/IonSink$Builder {
+ public final fun build (Lcom/amazon/ion/IonWriter;)Lorg/partiql/spi/value/ion/IonSink;
+ public final fun decorate (I)Lorg/partiql/spi/value/ion/IonSink$Builder;
+ public final fun elide (I)Lorg/partiql/spi/value/ion/IonSink$Builder;
+}
+
+public final class org/partiql/spi/value/ion/IonSink$Companion {
+ public final fun binary (Ljava/io/OutputStream;)Lorg/partiql/spi/value/ion/IonSink;
+ public final fun binary (Ljava/io/OutputStream;[I)Lorg/partiql/spi/value/ion/IonSink;
+ public static synthetic fun binary$default (Lorg/partiql/spi/value/ion/IonSink$Companion;Ljava/io/OutputStream;[IILjava/lang/Object;)Lorg/partiql/spi/value/ion/IonSink;
+ public final fun decorated ()Lorg/partiql/spi/value/ion/IonSink$Builder;
+ public final fun elided ()Lorg/partiql/spi/value/ion/IonSink$Builder;
+ public final fun pretty (Ljava/lang/Appendable;)Lorg/partiql/spi/value/ion/IonSink;
+ public final fun pretty (Ljava/lang/Appendable;[I)Lorg/partiql/spi/value/ion/IonSink;
+ public static synthetic fun pretty$default (Lorg/partiql/spi/value/ion/IonSink$Companion;Ljava/lang/Appendable;[IILjava/lang/Object;)Lorg/partiql/spi/value/ion/IonSink;
+ public final fun standard ()Lorg/partiql/spi/value/ion/IonSink$Builder;
+ public final fun standard (Lcom/amazon/ion/IonWriter;)Lorg/partiql/spi/value/ion/IonSink;
+ public final fun text (Ljava/lang/Appendable;)Lorg/partiql/spi/value/ion/IonSink;
+ public final fun text (Ljava/lang/Appendable;[I)Lorg/partiql/spi/value/ion/IonSink;
+ public static synthetic fun text$default (Lorg/partiql/spi/value/ion/IonSink$Companion;Ljava/lang/Appendable;[IILjava/lang/Object;)Lorg/partiql/spi/value/ion/IonSink;
+}
+
+public abstract class org/partiql/value/BagValue : org/partiql/value/CollectionValue {
+ public fun ()V
+ public abstract fun copy (Ljava/util/List;)Lorg/partiql/value/BagValue;
+ public fun equals (Ljava/lang/Object;)Z
+ public fun getType ()Lorg/partiql/value/PartiQLValueType;
+ public fun hashCode ()I
+ public fun iterator ()Ljava/util/Iterator;
+ public abstract fun withAnnotations (Ljava/util/List;)Lorg/partiql/value/BagValue;
+ public abstract fun withoutAnnotations ()Lorg/partiql/value/BagValue;
+}
+
+public abstract class org/partiql/value/BinaryValue : org/partiql/value/ScalarValue {
+ public fun ()V
+ public abstract fun copy (Ljava/util/List;)Lorg/partiql/value/BinaryValue;
+ public fun getType ()Lorg/partiql/value/PartiQLValueType;
+ public fun isNull ()Z
+ public abstract fun withAnnotations (Ljava/util/List;)Lorg/partiql/value/BinaryValue;
+ public abstract fun withoutAnnotations ()Lorg/partiql/value/BinaryValue;
+}
+
+public abstract class org/partiql/value/BlobValue : org/partiql/value/ScalarValue {
+ public fun ()V
+ public abstract fun copy (Ljava/util/List;)Lorg/partiql/value/BlobValue;
+ public fun getType ()Lorg/partiql/value/PartiQLValueType;
+ public fun isNull ()Z
+ public abstract fun withAnnotations (Ljava/util/List;)Lorg/partiql/value/BlobValue;
+ public abstract fun withoutAnnotations ()Lorg/partiql/value/BlobValue;
+}
+
+public abstract class org/partiql/value/BoolValue : org/partiql/value/ScalarValue {
+ public fun ()V
+ public abstract fun copy (Ljava/util/List;)Lorg/partiql/value/BoolValue;
+ public fun getType ()Lorg/partiql/value/PartiQLValueType;
+ public fun isNull ()Z
+ public abstract fun withAnnotations (Ljava/util/List;)Lorg/partiql/value/BoolValue;
+ public abstract fun withoutAnnotations ()Lorg/partiql/value/BoolValue;
+}
+
+public abstract class org/partiql/value/ByteValue : org/partiql/value/ScalarValue {
+ public fun ()V
+ public abstract fun copy (Ljava/util/List;)Lorg/partiql/value/ByteValue;
+ public fun getType ()Lorg/partiql/value/PartiQLValueType;
+ public fun isNull ()Z
+ public abstract fun withAnnotations (Ljava/util/List;)Lorg/partiql/value/ByteValue;
+ public abstract fun withoutAnnotations ()Lorg/partiql/value/ByteValue;
+}
+
+public abstract class org/partiql/value/CharValue : org/partiql/value/TextValue {
+ public fun ()V
+ public abstract fun copy (Ljava/util/List;)Lorg/partiql/value/CharValue;
+ public fun getString ()Ljava/lang/String;
+ public fun getType ()Lorg/partiql/value/PartiQLValueType;
+ public abstract fun withAnnotations (Ljava/util/List;)Lorg/partiql/value/CharValue;
+ public abstract fun withoutAnnotations ()Lorg/partiql/value/CharValue;
+}
+
+public abstract class org/partiql/value/ClobValue : org/partiql/value/ScalarValue {
+ public fun ()V
+ public abstract fun copy (Ljava/util/List;)Lorg/partiql/value/ClobValue;
+ public fun getType ()Lorg/partiql/value/PartiQLValueType;
+ public fun isNull ()Z
+ public abstract fun withAnnotations (Ljava/util/List;)Lorg/partiql/value/ClobValue;
+ public abstract fun withoutAnnotations ()Lorg/partiql/value/ClobValue;
+}
+
+public abstract interface class org/partiql/value/CollectionValue : java/lang/Iterable, kotlin/jvm/internal/markers/KMappedMarker, org/partiql/value/PartiQLValue {
+ public abstract fun copy (Ljava/util/List;)Lorg/partiql/value/CollectionValue;
+ public abstract fun isNull ()Z
+ public abstract fun iterator ()Ljava/util/Iterator;
+ public abstract fun withAnnotations (Ljava/util/List;)Lorg/partiql/value/CollectionValue;
+ public abstract fun withoutAnnotations ()Lorg/partiql/value/CollectionValue;
+}
+
+public abstract class org/partiql/value/DateValue : org/partiql/value/ScalarValue {
+ public fun ()V
+ public abstract fun copy (Ljava/util/List;)Lorg/partiql/value/DateValue;
+ public fun getType ()Lorg/partiql/value/PartiQLValueType;
+ public fun isNull ()Z
+ public abstract fun withAnnotations (Ljava/util/List;)Lorg/partiql/value/DateValue;
+ public abstract fun withoutAnnotations ()Lorg/partiql/value/DateValue;
+}
+
+public abstract class org/partiql/value/DecimalValue : org/partiql/value/NumericValue {
+ public fun ()V
+ public abstract fun copy (Ljava/util/List;)Lorg/partiql/value/DecimalValue;
+ public fun getType ()Lorg/partiql/value/PartiQLValueType;
+ public abstract fun withAnnotations (Ljava/util/List;)Lorg/partiql/value/DecimalValue;
+ public abstract fun withoutAnnotations ()Lorg/partiql/value/DecimalValue;
+}
+
+public abstract class org/partiql/value/Float32Value : org/partiql/value/NumericValue {
+ public fun ()V
+ public abstract fun copy (Ljava/util/List;)Lorg/partiql/value/Float32Value;
+ public fun getType ()Lorg/partiql/value/PartiQLValueType;
+ public abstract fun withAnnotations (Ljava/util/List;)Lorg/partiql/value/Float32Value;
+ public abstract fun withoutAnnotations ()Lorg/partiql/value/Float32Value;
+}
+
+public abstract class org/partiql/value/Float64Value : org/partiql/value/NumericValue {
+ public fun ()V
+ public abstract fun copy (Ljava/util/List;)Lorg/partiql/value/Float64Value;
+ public fun getType ()Lorg/partiql/value/PartiQLValueType;
+ public abstract fun withAnnotations (Ljava/util/List;)Lorg/partiql/value/Float64Value;
+ public abstract fun withoutAnnotations ()Lorg/partiql/value/Float64Value;
+}
+
+public abstract class org/partiql/value/Int16Value : org/partiql/value/NumericValue {
+ public fun ()V
+ public abstract fun copy (Ljava/util/List;)Lorg/partiql/value/Int16Value;
+ public fun getType ()Lorg/partiql/value/PartiQLValueType;
+ public abstract fun withAnnotations (Ljava/util/List;)Lorg/partiql/value/Int16Value;
+ public abstract fun withoutAnnotations ()Lorg/partiql/value/Int16Value;
+}
+
+public abstract class org/partiql/value/Int32Value : org/partiql/value/NumericValue {
+ public fun ()V
+ public abstract fun copy (Ljava/util/List;)Lorg/partiql/value/Int32Value;
+ public fun getType ()Lorg/partiql/value/PartiQLValueType;
+ public abstract fun withAnnotations (Ljava/util/List;)Lorg/partiql/value/Int32Value;
+ public abstract fun withoutAnnotations ()Lorg/partiql/value/Int32Value;
+}
+
+public abstract class org/partiql/value/Int64Value : org/partiql/value/NumericValue {
+ public fun ()V
+ public abstract fun copy (Ljava/util/List;)Lorg/partiql/value/Int64Value;
+ public fun getType ()Lorg/partiql/value/PartiQLValueType;
+ public abstract fun withAnnotations (Ljava/util/List;)Lorg/partiql/value/Int64Value;
+ public abstract fun withoutAnnotations ()Lorg/partiql/value/Int64Value;
+}
+
+public abstract class org/partiql/value/Int8Value : org/partiql/value/NumericValue {
+ public fun ()V
+ public abstract fun copy (Ljava/util/List;)Lorg/partiql/value/Int8Value;
+ public fun getType ()Lorg/partiql/value/PartiQLValueType;
+ public abstract fun withAnnotations (Ljava/util/List;)Lorg/partiql/value/Int8Value;
+ public abstract fun withoutAnnotations ()Lorg/partiql/value/Int8Value;
+}
+
+public abstract class org/partiql/value/IntValue : org/partiql/value/NumericValue {
+ public fun ()V
+ public abstract fun copy (Ljava/util/List;)Lorg/partiql/value/IntValue;
+ public fun getType ()Lorg/partiql/value/PartiQLValueType;
+ public abstract fun withAnnotations (Ljava/util/List;)Lorg/partiql/value/IntValue;
+ public abstract fun withoutAnnotations ()Lorg/partiql/value/IntValue;
+}
+
+public abstract class org/partiql/value/IntervalValue : org/partiql/value/ScalarValue {
+ public fun ()V
+ public abstract fun copy (Ljava/util/List;)Lorg/partiql/value/IntervalValue;
+ public fun getType ()Lorg/partiql/value/PartiQLValueType;
+ public fun isNull ()Z
+ public abstract fun withAnnotations (Ljava/util/List;)Lorg/partiql/value/IntervalValue;
+ public abstract fun withoutAnnotations ()Lorg/partiql/value/IntervalValue;
+}
+
+public abstract class org/partiql/value/ListValue : org/partiql/value/CollectionValue {
+ public fun ()V
+ public abstract fun copy (Ljava/util/List;)Lorg/partiql/value/ListValue;
+ public fun equals (Ljava/lang/Object;)Z
+ public fun getType ()Lorg/partiql/value/PartiQLValueType;
+ public fun hashCode ()I
+ public fun iterator ()Ljava/util/Iterator;
+ public abstract fun withAnnotations (Ljava/util/List;)Lorg/partiql/value/ListValue;
+ public abstract fun withoutAnnotations ()Lorg/partiql/value/ListValue;
+}
+
+public abstract class org/partiql/value/MissingValue : org/partiql/value/PartiQLValue {
+ public fun ()V
+ public abstract fun copy (Ljava/util/List;)Lorg/partiql/value/MissingValue;
+ public fun getType ()Lorg/partiql/value/PartiQLValueType;
+ public fun isNull ()Z
+ public abstract fun withAnnotations (Ljava/util/List;)Lorg/partiql/value/MissingValue;
+ public abstract fun withoutAnnotations ()Lorg/partiql/value/MissingValue;
+}
+
+public abstract class org/partiql/value/NullValue : org/partiql/value/PartiQLValue {
+ public fun ()V
+ public abstract fun copy (Ljava/util/List;)Lorg/partiql/value/NullValue;
+ public fun getType ()Lorg/partiql/value/PartiQLValueType;
+ public fun isNull ()Z
+ public abstract fun withAnnotations (Ljava/util/List;)Lorg/partiql/value/NullValue;
+ public abstract fun withType (Lorg/partiql/value/PartiQLValueType;)Lorg/partiql/value/PartiQLValue;
+ public abstract fun withoutAnnotations ()Lorg/partiql/value/NullValue;
+}
+
+public abstract class org/partiql/value/NumericValue : org/partiql/value/ScalarValue {
+ public abstract fun copy (Ljava/util/List;)Lorg/partiql/value/NumericValue;
+ public fun isNull ()Z
+ public abstract fun toDecimal ()Lorg/partiql/value/DecimalValue;
+ public abstract fun toFloat32 ()Lorg/partiql/value/Float32Value;
+ public abstract fun toFloat64 ()Lorg/partiql/value/Float64Value;
+ public abstract fun toInt ()Lorg/partiql/value/IntValue;
+ public abstract fun toInt16 ()Lorg/partiql/value/Int16Value;
+ public abstract fun toInt32 ()Lorg/partiql/value/Int32Value;
+ public abstract fun toInt64 ()Lorg/partiql/value/Int64Value;
+ public abstract fun toInt8 ()Lorg/partiql/value/Int8Value;
+ public abstract fun withAnnotations (Ljava/util/List;)Lorg/partiql/value/NumericValue;
+ public abstract fun withoutAnnotations ()Lorg/partiql/value/NumericValue;
+}
+
+public final class org/partiql/value/PartiQL {
+ public static final fun bagValue (Ljava/lang/Iterable;)Lorg/partiql/value/BagValue;
+ public static final fun bagValue (Ljava/lang/Iterable;Ljava/util/List;)Lorg/partiql/value/BagValue;
+ public static final fun bagValue ([Lorg/partiql/value/PartiQLValue;)Lorg/partiql/value/BagValue;
+ public static final fun bagValue ([Lorg/partiql/value/PartiQLValue;Ljava/util/List;)Lorg/partiql/value/BagValue;
+ public static synthetic fun bagValue$default (Ljava/lang/Iterable;Ljava/util/List;ILjava/lang/Object;)Lorg/partiql/value/BagValue;
+ public static synthetic fun bagValue$default ([Lorg/partiql/value/PartiQLValue;Ljava/util/List;ILjava/lang/Object;)Lorg/partiql/value/BagValue;
+ public static final fun binaryValue (Ljava/util/BitSet;)Lorg/partiql/value/BinaryValue;
+ public static final fun binaryValue (Ljava/util/BitSet;Ljava/util/List;)Lorg/partiql/value/BinaryValue;
+ public static synthetic fun binaryValue$default (Ljava/util/BitSet;Ljava/util/List;ILjava/lang/Object;)Lorg/partiql/value/BinaryValue;
+ public static final fun blobValue ([B)Lorg/partiql/value/BlobValue;
+ public static final fun blobValue ([BLjava/util/List;)Lorg/partiql/value/BlobValue;
+ public static synthetic fun blobValue$default ([BLjava/util/List;ILjava/lang/Object;)Lorg/partiql/value/BlobValue;
+ public static final fun boolValue (Ljava/lang/Boolean;)Lorg/partiql/value/BoolValue;
+ public static final fun boolValue (Ljava/lang/Boolean;Ljava/util/List;)Lorg/partiql/value/BoolValue;
+ public static synthetic fun boolValue$default (Ljava/lang/Boolean;Ljava/util/List;ILjava/lang/Object;)Lorg/partiql/value/BoolValue;
+ public static final fun byteValue (Ljava/lang/Byte;)Lorg/partiql/value/ByteValue;
+ public static final fun byteValue (Ljava/lang/Byte;Ljava/util/List;)Lorg/partiql/value/ByteValue;
+ public static synthetic fun byteValue$default (Ljava/lang/Byte;Ljava/util/List;ILjava/lang/Object;)Lorg/partiql/value/ByteValue;
+ public static final fun charValue (Ljava/lang/Character;)Lorg/partiql/value/CharValue;
+ public static final fun charValue (Ljava/lang/Character;Ljava/util/List;)Lorg/partiql/value/CharValue;
+ public static synthetic fun charValue$default (Ljava/lang/Character;Ljava/util/List;ILjava/lang/Object;)Lorg/partiql/value/CharValue;
+ public static final fun clobValue ([B)Lorg/partiql/value/ClobValue;
+ public static final fun clobValue ([BLjava/util/List;)Lorg/partiql/value/ClobValue;
+ public static synthetic fun clobValue$default ([BLjava/util/List;ILjava/lang/Object;)Lorg/partiql/value/ClobValue;
+ public static final fun dateValue (Lorg/partiql/value/datetime/Date;)Lorg/partiql/value/DateValue;
+ public static final fun dateValue (Lorg/partiql/value/datetime/Date;Ljava/util/List;)Lorg/partiql/value/DateValue;
+ public static synthetic fun dateValue$default (Lorg/partiql/value/datetime/Date;Ljava/util/List;ILjava/lang/Object;)Lorg/partiql/value/DateValue;
+ public static final fun decimalValue (Ljava/math/BigDecimal;)Lorg/partiql/value/DecimalValue;
+ public static final fun decimalValue (Ljava/math/BigDecimal;Ljava/util/List;)Lorg/partiql/value/DecimalValue;
+ public static synthetic fun decimalValue$default (Ljava/math/BigDecimal;Ljava/util/List;ILjava/lang/Object;)Lorg/partiql/value/DecimalValue;
+ public static final fun float32Value (Ljava/lang/Float;)Lorg/partiql/value/Float32Value;
+ public static final fun float32Value (Ljava/lang/Float;Ljava/util/List;)Lorg/partiql/value/Float32Value;
+ public static synthetic fun float32Value$default (Ljava/lang/Float;Ljava/util/List;ILjava/lang/Object;)Lorg/partiql/value/Float32Value;
+ public static final fun float64Value (Ljava/lang/Double;)Lorg/partiql/value/Float64Value;
+ public static final fun float64Value (Ljava/lang/Double;Ljava/util/List;)Lorg/partiql/value/Float64Value;
+ public static synthetic fun float64Value$default (Ljava/lang/Double;Ljava/util/List;ILjava/lang/Object;)Lorg/partiql/value/Float64Value;
+ public static final fun int16Value (Ljava/lang/Short;)Lorg/partiql/value/Int16Value;
+ public static final fun int16Value (Ljava/lang/Short;Ljava/util/List;)Lorg/partiql/value/Int16Value;
+ public static synthetic fun int16Value$default (Ljava/lang/Short;Ljava/util/List;ILjava/lang/Object;)Lorg/partiql/value/Int16Value;
+ public static final fun int32Value (Ljava/lang/Integer;)Lorg/partiql/value/Int32Value;
+ public static final fun int32Value (Ljava/lang/Integer;Ljava/util/List;)Lorg/partiql/value/Int32Value;
+ public static synthetic fun int32Value$default (Ljava/lang/Integer;Ljava/util/List;ILjava/lang/Object;)Lorg/partiql/value/Int32Value;
+ public static final fun int64Value (Ljava/lang/Long;)Lorg/partiql/value/Int64Value;
+ public static final fun int64Value (Ljava/lang/Long;Ljava/util/List;)Lorg/partiql/value/Int64Value;
+ public static synthetic fun int64Value$default (Ljava/lang/Long;Ljava/util/List;ILjava/lang/Object;)Lorg/partiql/value/Int64Value;
+ public static final fun int8Value (Ljava/lang/Byte;)Lorg/partiql/value/Int8Value;
+ public static final fun int8Value (Ljava/lang/Byte;Ljava/util/List;)Lorg/partiql/value/Int8Value;
+ public static synthetic fun int8Value$default (Ljava/lang/Byte;Ljava/util/List;ILjava/lang/Object;)Lorg/partiql/value/Int8Value;
+ public static final fun intValue (Ljava/math/BigInteger;)Lorg/partiql/value/IntValue;
+ public static final fun intValue (Ljava/math/BigInteger;Ljava/util/List;)Lorg/partiql/value/IntValue;
+ public static synthetic fun intValue$default (Ljava/math/BigInteger;Ljava/util/List;ILjava/lang/Object;)Lorg/partiql/value/IntValue;
+ public static final fun intervalValue (Ljava/lang/Long;)Lorg/partiql/value/IntervalValue;
+ public static final fun intervalValue (Ljava/lang/Long;Ljava/util/List;)Lorg/partiql/value/IntervalValue;
+ public static synthetic fun intervalValue$default (Ljava/lang/Long;Ljava/util/List;ILjava/lang/Object;)Lorg/partiql/value/IntervalValue;
+ public static final fun listValue (Ljava/lang/Iterable;)Lorg/partiql/value/ListValue;
+ public static final fun listValue (Ljava/lang/Iterable;Ljava/util/List;)Lorg/partiql/value/ListValue;
+ public static final fun listValue ([Lorg/partiql/value/PartiQLValue;)Lorg/partiql/value/ListValue;
+ public static final fun listValue ([Lorg/partiql/value/PartiQLValue;Ljava/util/List;)Lorg/partiql/value/ListValue;
+ public static synthetic fun listValue$default (Ljava/lang/Iterable;Ljava/util/List;ILjava/lang/Object;)Lorg/partiql/value/ListValue;
+ public static synthetic fun listValue$default ([Lorg/partiql/value/PartiQLValue;Ljava/util/List;ILjava/lang/Object;)Lorg/partiql/value/ListValue;
+ public static final fun missingValue ()Lorg/partiql/value/MissingValue;
+ public static final fun missingValue (Ljava/util/List;)Lorg/partiql/value/MissingValue;
+ public static synthetic fun missingValue$default (Ljava/util/List;ILjava/lang/Object;)Lorg/partiql/value/MissingValue;
+ public static final fun nullValue ()Lorg/partiql/value/NullValue;
+ public static final fun nullValue (Ljava/util/List;)Lorg/partiql/value/NullValue;
+ public static synthetic fun nullValue$default (Ljava/util/List;ILjava/lang/Object;)Lorg/partiql/value/NullValue;
+ public static final fun sexpValue (Ljava/lang/Iterable;)Lorg/partiql/value/SexpValue;
+ public static final fun sexpValue (Ljava/lang/Iterable;Ljava/util/List;)Lorg/partiql/value/SexpValue;
+ public static final fun sexpValue ([Lorg/partiql/value/PartiQLValue;)Lorg/partiql/value/SexpValue;
+ public static final fun sexpValue ([Lorg/partiql/value/PartiQLValue;Ljava/util/List;)Lorg/partiql/value/SexpValue;
+ public static synthetic fun sexpValue$default (Ljava/lang/Iterable;Ljava/util/List;ILjava/lang/Object;)Lorg/partiql/value/SexpValue;
+ public static synthetic fun sexpValue$default ([Lorg/partiql/value/PartiQLValue;Ljava/util/List;ILjava/lang/Object;)Lorg/partiql/value/SexpValue;
+ public static final fun stringValue (Ljava/lang/String;)Lorg/partiql/value/StringValue;
+ public static final fun stringValue (Ljava/lang/String;Ljava/util/List;)Lorg/partiql/value/StringValue;
+ public static synthetic fun stringValue$default (Ljava/lang/String;Ljava/util/List;ILjava/lang/Object;)Lorg/partiql/value/StringValue;
+ public static final fun structValue (Ljava/lang/Iterable;)Lorg/partiql/value/StructValue;
+ public static final fun structValue (Ljava/lang/Iterable;Ljava/util/List;)Lorg/partiql/value/StructValue;
+ public static final fun structValue ([Lkotlin/Pair;)Lorg/partiql/value/StructValue;
+ public static final fun structValue ([Lkotlin/Pair;Ljava/util/List;)Lorg/partiql/value/StructValue;
+ public static synthetic fun structValue$default (Ljava/lang/Iterable;Ljava/util/List;ILjava/lang/Object;)Lorg/partiql/value/StructValue;
+ public static synthetic fun structValue$default ([Lkotlin/Pair;Ljava/util/List;ILjava/lang/Object;)Lorg/partiql/value/StructValue;
+ public static final fun structValueMap (Ljava/util/Map;)Lorg/partiql/value/StructValue;
+ public static final fun structValueMap (Ljava/util/Map;Ljava/util/List;)Lorg/partiql/value/StructValue;
+ public static synthetic fun structValueMap$default (Ljava/util/Map;Ljava/util/List;ILjava/lang/Object;)Lorg/partiql/value/StructValue;
+ public static final fun structValueMultiMap (Ljava/util/Map;)Lorg/partiql/value/StructValue;
+ public static final fun structValueMultiMap (Ljava/util/Map;Ljava/util/List;)Lorg/partiql/value/StructValue;
+ public static synthetic fun structValueMultiMap$default (Ljava/util/Map;Ljava/util/List;ILjava/lang/Object;)Lorg/partiql/value/StructValue;
+ public static final fun symbolValue (Ljava/lang/String;)Lorg/partiql/value/SymbolValue;
+ public static final fun symbolValue (Ljava/lang/String;Ljava/util/List;)Lorg/partiql/value/SymbolValue;
+ public static synthetic fun symbolValue$default (Ljava/lang/String;Ljava/util/List;ILjava/lang/Object;)Lorg/partiql/value/SymbolValue;
+ public static final fun timeValue (Lorg/partiql/value/datetime/Time;)Lorg/partiql/value/TimeValue;
+ public static final fun timeValue (Lorg/partiql/value/datetime/Time;Ljava/util/List;)Lorg/partiql/value/TimeValue;
+ public static synthetic fun timeValue$default (Lorg/partiql/value/datetime/Time;Ljava/util/List;ILjava/lang/Object;)Lorg/partiql/value/TimeValue;
+ public static final fun timestampValue (Lorg/partiql/value/datetime/Timestamp;)Lorg/partiql/value/TimestampValue;
+ public static final fun timestampValue (Lorg/partiql/value/datetime/Timestamp;Ljava/util/List;)Lorg/partiql/value/TimestampValue;
+ public static synthetic fun timestampValue$default (Lorg/partiql/value/datetime/Timestamp;Ljava/util/List;ILjava/lang/Object;)Lorg/partiql/value/TimestampValue;
+}
+
+public abstract interface class org/partiql/value/PartiQLValue {
+ public static final field Companion Lorg/partiql/value/PartiQLValue$Companion;
+ public abstract fun accept (Lorg/partiql/value/util/PartiQLValueVisitor;Ljava/lang/Object;)Ljava/lang/Object;
+ public static fun comparator ()Ljava/util/Comparator;
+ public static fun comparator (Z)Ljava/util/Comparator;
+ public abstract fun copy (Ljava/util/List;)Lorg/partiql/value/PartiQLValue;
+ public abstract fun getAnnotations ()Ljava/util/List;
+ public abstract fun getType ()Lorg/partiql/value/PartiQLValueType;
+ public abstract fun isNull ()Z
+ public abstract fun withAnnotations (Ljava/util/List;)Lorg/partiql/value/PartiQLValue;
+ public abstract fun withoutAnnotations ()Lorg/partiql/value/PartiQLValue;
+}
+
+public final class org/partiql/value/PartiQLValue$Companion {
+ public final fun comparator ()Ljava/util/Comparator;
+ public final fun comparator (Z)Ljava/util/Comparator;
+ public static synthetic fun comparator$default (Lorg/partiql/value/PartiQLValue$Companion;ZILjava/lang/Object;)Ljava/util/Comparator;
+}
+
+public final class org/partiql/value/PartiQLValue$DefaultImpls {
+ public static synthetic fun copy$default (Lorg/partiql/value/PartiQLValue;Ljava/util/List;ILjava/lang/Object;)Lorg/partiql/value/PartiQLValue;
+}
+
+public abstract interface annotation class org/partiql/value/PartiQLValueExperimental : java/lang/annotation/Annotation {
+}
+
+public final class org/partiql/value/PartiQLValueKt {
+ public static final fun toIon (Lorg/partiql/value/PartiQLValue;)Lcom/amazon/ionelement/api/IonElement;
+}
+
+public final class org/partiql/value/PartiQLValueType : java/lang/Enum {
+ public static final field ANY Lorg/partiql/value/PartiQLValueType;
+ public static final field BAG Lorg/partiql/value/PartiQLValueType;
+ public static final field BINARY Lorg/partiql/value/PartiQLValueType;
+ public static final field BLOB Lorg/partiql/value/PartiQLValueType;
+ public static final field BOOL Lorg/partiql/value/PartiQLValueType;
+ public static final field BYTE Lorg/partiql/value/PartiQLValueType;
+ public static final field CHAR Lorg/partiql/value/PartiQLValueType;
+ public static final field CLOB Lorg/partiql/value/PartiQLValueType;
+ public static final field DATE Lorg/partiql/value/PartiQLValueType;
+ public static final field DECIMAL Lorg/partiql/value/PartiQLValueType;
+ public static final field DECIMAL_ARBITRARY Lorg/partiql/value/PartiQLValueType;
+ public static final field FLOAT32 Lorg/partiql/value/PartiQLValueType;
+ public static final field FLOAT64 Lorg/partiql/value/PartiQLValueType;
+ public static final field INT Lorg/partiql/value/PartiQLValueType;
+ public static final field INT16 Lorg/partiql/value/PartiQLValueType;
+ public static final field INT32 Lorg/partiql/value/PartiQLValueType;
+ public static final field INT64 Lorg/partiql/value/PartiQLValueType;
+ public static final field INT8 Lorg/partiql/value/PartiQLValueType;
+ public static final field INTERVAL Lorg/partiql/value/PartiQLValueType;
+ public static final field LIST Lorg/partiql/value/PartiQLValueType;
+ public static final field MISSING Lorg/partiql/value/PartiQLValueType;
+ public static final field NULL Lorg/partiql/value/PartiQLValueType;
+ public static final field SEXP Lorg/partiql/value/PartiQLValueType;
+ public static final field STRING Lorg/partiql/value/PartiQLValueType;
+ public static final field STRUCT Lorg/partiql/value/PartiQLValueType;
+ public static final field SYMBOL Lorg/partiql/value/PartiQLValueType;
+ public static final field TIME Lorg/partiql/value/PartiQLValueType;
+ public static final field TIMESTAMP Lorg/partiql/value/PartiQLValueType;
+ public static fun getEntries ()Lkotlin/enums/EnumEntries;
+ public final fun toPType ()Lorg/partiql/types/PType;
+ public static fun valueOf (Ljava/lang/String;)Lorg/partiql/value/PartiQLValueType;
+ public static fun values ()[Lorg/partiql/value/PartiQLValueType;
+}
+
+public abstract interface class org/partiql/value/ScalarValue : org/partiql/value/PartiQLValue {
+ public abstract fun copy (Ljava/util/List;)Lorg/partiql/value/ScalarValue;
+ public abstract fun getValue ()Ljava/lang/Object;
+ public abstract fun isNull ()Z
+ public abstract fun withAnnotations (Ljava/util/List;)Lorg/partiql/value/ScalarValue;
+ public abstract fun withoutAnnotations ()Lorg/partiql/value/ScalarValue;
+}
+
+public final class org/partiql/value/ScalarValue$DefaultImpls {
+ public static fun isNull (Lorg/partiql/value/ScalarValue;)Z
+}
+
+public abstract class org/partiql/value/SexpValue : org/partiql/value/CollectionValue {
+ public fun ()V
+ public abstract fun copy (Ljava/util/List;)Lorg/partiql/value/SexpValue;
+ public fun equals (Ljava/lang/Object;)Z
+ public fun getType ()Lorg/partiql/value/PartiQLValueType;
+ public fun hashCode ()I
+ public fun iterator ()Ljava/util/Iterator;
+ public abstract fun withAnnotations (Ljava/util/List;)Lorg/partiql/value/SexpValue;
+ public abstract fun withoutAnnotations ()Lorg/partiql/value/SexpValue;
+}
+
+public abstract class org/partiql/value/StringValue : org/partiql/value/TextValue {
+ public fun ()V
+ public abstract fun copy (Ljava/util/List;)Lorg/partiql/value/StringValue;
+ public fun getString ()Ljava/lang/String;
+ public fun getType ()Lorg/partiql/value/PartiQLValueType;
+ public abstract fun withAnnotations (Ljava/util/List;)Lorg/partiql/value/StringValue;
+ public abstract fun withoutAnnotations ()Lorg/partiql/value/StringValue;
+}
+
+public abstract class org/partiql/value/StructValue : org/partiql/value/PartiQLValue {
+ public fun ()V
+ public abstract fun copy (Ljava/util/List;)Lorg/partiql/value/StructValue;
+ public fun equals (Ljava/lang/Object;)Z
+ public abstract fun get (Ljava/lang/String;)Lorg/partiql/value/PartiQLValue;
+ public abstract fun getAll (Ljava/lang/String;)Ljava/lang/Iterable;
+ public abstract fun getEntries ()Ljava/lang/Iterable;
+ public abstract fun getFields ()Ljava/lang/Iterable;
+ public fun getType ()Lorg/partiql/value/PartiQLValueType;
+ public abstract fun getValues ()Ljava/lang/Iterable;
+ public fun hashCode ()I
+ public fun toString ()Ljava/lang/String;
+ public abstract fun withAnnotations (Ljava/util/List;)Lorg/partiql/value/StructValue;
+ public abstract fun withoutAnnotations ()Lorg/partiql/value/StructValue;
+}
+
+public abstract class org/partiql/value/SymbolValue : org/partiql/value/TextValue {
+ public fun ()V
+ public abstract fun copy (Ljava/util/List;)Lorg/partiql/value/SymbolValue;
+ public fun getString ()Ljava/lang/String;
+ public fun getType ()Lorg/partiql/value/PartiQLValueType;
+ public abstract fun withAnnotations (Ljava/util/List;)Lorg/partiql/value/SymbolValue;
+ public abstract fun withoutAnnotations ()Lorg/partiql/value/SymbolValue;
+}
+
+public abstract class org/partiql/value/TextValue : org/partiql/value/ScalarValue {
+ public abstract fun copy (Ljava/util/List;)Lorg/partiql/value/TextValue;
+ public abstract fun getString ()Ljava/lang/String;
+ public fun isNull ()Z
+ public abstract fun withAnnotations (Ljava/util/List;)Lorg/partiql/value/TextValue;
+ public abstract fun withoutAnnotations ()Lorg/partiql/value/TextValue;
+}
+
+public abstract class org/partiql/value/TimeValue : org/partiql/value/ScalarValue {
+ public fun ()V
+ public abstract fun copy (Ljava/util/List;)Lorg/partiql/value/TimeValue;
+ public fun getType ()Lorg/partiql/value/PartiQLValueType;
+ public fun isNull ()Z
+ public abstract fun withAnnotations (Ljava/util/List;)Lorg/partiql/value/TimeValue;
+ public abstract fun withoutAnnotations ()Lorg/partiql/value/TimeValue;
+}
+
+public abstract class org/partiql/value/TimestampValue : org/partiql/value/ScalarValue {
+ public fun ()V
+ public abstract fun copy (Ljava/util/List;)Lorg/partiql/value/TimestampValue;
+ public fun getType ()Lorg/partiql/value/PartiQLValueType;
+ public fun isNull ()Z
+ public abstract fun withAnnotations (Ljava/util/List;)Lorg/partiql/value/TimestampValue;
+ public abstract fun withoutAnnotations ()Lorg/partiql/value/TimestampValue;
+}
+
+>>>>>>> d94a4afd7 (Adds DatumWriter for most types)
+public abstract interface class org/partiql/value/datetime/Date : java/lang/Comparable, org/partiql/value/datetime/DateTime {
+ public abstract fun atTime (Lorg/partiql/value/datetime/Time;)Lorg/partiql/value/datetime/Timestamp;
+ public abstract fun compareTo (Lorg/partiql/value/datetime/Date;)I
+ public abstract fun getDay ()Ljava/lang/Integer;
+ public abstract fun getDecimalSecond ()Ljava/math/BigDecimal;
+ public abstract fun getHour ()Ljava/lang/Integer;
+ public abstract fun getMinute ()Ljava/lang/Integer;
+ public abstract fun getMonth ()Ljava/lang/Integer;
+ public abstract fun getTimeZone ()Lorg/partiql/value/datetime/TimeZone;
+ public abstract fun getYear ()Ljava/lang/Integer;
+ public abstract fun plusDays (J)Lorg/partiql/value/datetime/Date;
+ public abstract fun plusMonths (J)Lorg/partiql/value/datetime/Date;
+ public abstract fun plusYears (J)Lorg/partiql/value/datetime/Date;
+}
+
+public final class org/partiql/value/datetime/Date$DefaultImpls {
+ public static fun compareTo (Lorg/partiql/value/datetime/Date;Lorg/partiql/value/datetime/Date;)I
+ public static fun getDecimalSecond (Lorg/partiql/value/datetime/Date;)Ljava/math/BigDecimal;
+ public static fun getHour (Lorg/partiql/value/datetime/Date;)Ljava/lang/Integer;
+ public static fun getMinute (Lorg/partiql/value/datetime/Date;)Ljava/lang/Integer;
+ public static fun getTimeZone (Lorg/partiql/value/datetime/Date;)Lorg/partiql/value/datetime/TimeZone;
+}
+
+public abstract class org/partiql/value/datetime/DateImpl : java/lang/Comparable, org/partiql/value/datetime/Date {
+ public fun ()V
+ public synthetic fun compareTo (Ljava/lang/Object;)I
+ public fun compareTo (Lorg/partiql/value/datetime/Date;)I
+ public final fun equals (Ljava/lang/Object;)Z
+ public fun getDecimalSecond ()Ljava/math/BigDecimal;
+ public fun getHour ()Ljava/lang/Integer;
+ public fun getMinute ()Ljava/lang/Integer;
+ public fun getTimeZone ()Lorg/partiql/value/datetime/TimeZone;
+ public final fun hashCode ()I
+ public final fun toString ()Ljava/lang/String;
+}
+
+public abstract interface class org/partiql/value/datetime/DateTime {
+ public abstract fun equals (Ljava/lang/Object;)Z
+ public abstract fun getDay ()Ljava/lang/Integer;
+ public abstract fun getDecimalSecond ()Ljava/math/BigDecimal;
+ public abstract fun getHour ()Ljava/lang/Integer;
+ public abstract fun getMinute ()Ljava/lang/Integer;
+ public abstract fun getMonth ()Ljava/lang/Integer;
+ public abstract fun getTimeZone ()Lorg/partiql/value/datetime/TimeZone;
+ public abstract fun getYear ()Ljava/lang/Integer;
+ public abstract fun hashCode ()I
+ public abstract fun toString ()Ljava/lang/String;
+}
+
+public final class org/partiql/value/datetime/DateTimeException : java/lang/RuntimeException {
+ public fun ()V
+ public fun (Ljava/lang/String;Ljava/lang/Throwable;)V
+ public synthetic fun (Ljava/lang/String;Ljava/lang/Throwable;ILkotlin/jvm/internal/DefaultConstructorMarker;)V
+ public fun getCause ()Ljava/lang/Throwable;
+ public fun getMessage ()Ljava/lang/String;
+}
+
+public final class org/partiql/value/datetime/DateTimeValue {
+ public static final field INSTANCE Lorg/partiql/value/datetime/DateTimeValue;
+ public static final fun date (III)Lorg/partiql/value/datetime/Date;
+ public final fun time (III)Lorg/partiql/value/datetime/Time;
+ public final fun time (IIII)Lorg/partiql/value/datetime/Time;
+ public final fun time (IIIILorg/partiql/value/datetime/TimeZone;)Lorg/partiql/value/datetime/Time;
+ public final fun time (IIILorg/partiql/value/datetime/TimeZone;)Lorg/partiql/value/datetime/Time;
+ public final fun time (IILjava/math/BigDecimal;)Lorg/partiql/value/datetime/Time;
+ public final fun time (IILjava/math/BigDecimal;Lorg/partiql/value/datetime/TimeZone;)Lorg/partiql/value/datetime/Time;
+ public static synthetic fun time$default (Lorg/partiql/value/datetime/DateTimeValue;IIIILorg/partiql/value/datetime/TimeZone;ILjava/lang/Object;)Lorg/partiql/value/datetime/Time;
+ public static synthetic fun time$default (Lorg/partiql/value/datetime/DateTimeValue;IIILorg/partiql/value/datetime/TimeZone;ILjava/lang/Object;)Lorg/partiql/value/datetime/Time;
+ public static synthetic fun time$default (Lorg/partiql/value/datetime/DateTimeValue;IILjava/math/BigDecimal;Lorg/partiql/value/datetime/TimeZone;ILjava/lang/Object;)Lorg/partiql/value/datetime/Time;
+ public final fun timestamp (I)Lorg/partiql/value/datetime/Timestamp;
+ public final fun timestamp (II)Lorg/partiql/value/datetime/Timestamp;
+ public final fun timestamp (III)Lorg/partiql/value/datetime/Timestamp;
+ public final fun timestamp (IIII)Lorg/partiql/value/datetime/Timestamp;
+ public final fun timestamp (IIIII)Lorg/partiql/value/datetime/Timestamp;
+ public final fun timestamp (IIIIII)Lorg/partiql/value/datetime/Timestamp;
+ public final fun timestamp (IIIIIILorg/partiql/value/datetime/TimeZone;)Lorg/partiql/value/datetime/Timestamp;
+ public final fun timestamp (IIIIILjava/math/BigDecimal;)Lorg/partiql/value/datetime/Timestamp;
+ public final fun timestamp (IIIIILjava/math/BigDecimal;Lorg/partiql/value/datetime/TimeZone;)Lorg/partiql/value/datetime/Timestamp;
+ public final fun timestamp (Lcom/amazon/ion/Timestamp;)Lorg/partiql/value/datetime/TimestampWithTimeZone;
+ public final fun timestamp (Ljava/math/BigDecimal;Lorg/partiql/value/datetime/TimeZone;)Lorg/partiql/value/datetime/TimestampWithTimeZone;
+ public final fun timestamp (Lorg/partiql/value/datetime/Date;Lorg/partiql/value/datetime/Time;)Lorg/partiql/value/datetime/Timestamp;
+ public static synthetic fun timestamp$default (Lorg/partiql/value/datetime/DateTimeValue;IIIIIILorg/partiql/value/datetime/TimeZone;ILjava/lang/Object;)Lorg/partiql/value/datetime/Timestamp;
+ public static synthetic fun timestamp$default (Lorg/partiql/value/datetime/DateTimeValue;IIIIILjava/math/BigDecimal;Lorg/partiql/value/datetime/TimeZone;ILjava/lang/Object;)Lorg/partiql/value/datetime/Timestamp;
+}
+
+public abstract interface class org/partiql/value/datetime/Time : java/lang/Comparable, org/partiql/value/datetime/DateTime {
+ public abstract fun atDate (Lorg/partiql/value/datetime/Date;)Lorg/partiql/value/datetime/Timestamp;
+ public abstract fun compareTo (Lorg/partiql/value/datetime/Time;)I
+ public abstract fun getDay ()Ljava/lang/Integer;
+ public abstract fun getDecimalSecond ()Ljava/math/BigDecimal;
+ public abstract fun getElapsedSecond ()Ljava/math/BigDecimal;
+ public abstract fun getHour ()Ljava/lang/Integer;
+ public abstract fun getMinute ()Ljava/lang/Integer;
+ public abstract fun getMonth ()Ljava/lang/Integer;
+ public abstract fun getTimeZone ()Lorg/partiql/value/datetime/TimeZone;
+ public abstract fun getYear ()Ljava/lang/Integer;
+ public abstract fun plusHours (J)Lorg/partiql/value/datetime/Time;
+ public abstract fun plusMinutes (J)Lorg/partiql/value/datetime/Time;
+ public abstract fun plusSeconds (J)Lorg/partiql/value/datetime/Time;
+ public abstract fun plusSeconds (Ljava/math/BigDecimal;)Lorg/partiql/value/datetime/Time;
+ public abstract fun toPrecision (I)Lorg/partiql/value/datetime/Time;
+}
+
+public final class org/partiql/value/datetime/Time$DefaultImpls {
+ public static fun compareTo (Lorg/partiql/value/datetime/Time;Lorg/partiql/value/datetime/Time;)I
+ public static fun getDay (Lorg/partiql/value/datetime/Time;)Ljava/lang/Integer;
+ public static fun getMonth (Lorg/partiql/value/datetime/Time;)Ljava/lang/Integer;
+ public static fun getYear (Lorg/partiql/value/datetime/Time;)Ljava/lang/Integer;
+}
+
+public abstract class org/partiql/value/datetime/TimeWithTimeZone : org/partiql/value/datetime/Time {
+ public fun ()V
+ public abstract fun atDate (Lorg/partiql/value/datetime/Date;)Lorg/partiql/value/datetime/TimestampWithTimeZone;
+ public abstract fun atTimeZone (Lorg/partiql/value/datetime/TimeZone;)Lorg/partiql/value/datetime/TimeWithTimeZone;
+ public synthetic fun compareTo (Ljava/lang/Object;)I
+ public fun compareTo (Lorg/partiql/value/datetime/Time;)I
+ public final fun equals (Ljava/lang/Object;)Z
+ public fun getDay ()Ljava/lang/Integer;
+ public fun getMonth ()Ljava/lang/Integer;
+ public abstract fun getTimeZone ()Lorg/partiql/value/datetime/TimeZone;
+ public fun getYear ()Ljava/lang/Integer;
+ public final fun hashCode ()I
+ public abstract fun plusHours (J)Lorg/partiql/value/datetime/TimeWithTimeZone;
+ public abstract fun plusMinutes (J)Lorg/partiql/value/datetime/TimeWithTimeZone;
+ public final fun plusSeconds (J)Lorg/partiql/value/datetime/Time;
+ public abstract fun plusSeconds (Ljava/math/BigDecimal;)Lorg/partiql/value/datetime/TimeWithTimeZone;
+ public synthetic fun toPrecision (I)Lorg/partiql/value/datetime/Time;
+ public final fun toPrecision (I)Lorg/partiql/value/datetime/TimeWithTimeZone;
+ public final fun toString ()Ljava/lang/String;
+ public abstract fun toTimeWithoutTimeZone (Lorg/partiql/value/datetime/TimeZone;)Lorg/partiql/value/datetime/TimeWithoutTimeZone;
+}
+
+public abstract class org/partiql/value/datetime/TimeWithoutTimeZone : org/partiql/value/datetime/Time {
+ public fun ()V
+ public abstract fun atDate (Lorg/partiql/value/datetime/Date;)Lorg/partiql/value/datetime/TimestampWithoutTimeZone;
+ public synthetic fun compareTo (Ljava/lang/Object;)I
+ public fun compareTo (Lorg/partiql/value/datetime/Time;)I
+ public final fun equals (Ljava/lang/Object;)Z
+ public fun getDay ()Ljava/lang/Integer;
+ public fun getMonth ()Ljava/lang/Integer;
+ public final fun getTimeZone ()Lorg/partiql/value/datetime/TimeZone;
+ public fun getYear ()Ljava/lang/Integer;
+ public final fun hashCode ()I
+ public abstract fun plusHours (J)Lorg/partiql/value/datetime/TimeWithoutTimeZone;
+ public abstract fun plusMinutes (J)Lorg/partiql/value/datetime/TimeWithoutTimeZone;
+ public final fun plusSeconds (J)Lorg/partiql/value/datetime/Time;
+ public abstract fun plusSeconds (Ljava/math/BigDecimal;)Lorg/partiql/value/datetime/TimeWithoutTimeZone;
+ public synthetic fun toPrecision (I)Lorg/partiql/value/datetime/Time;
+ public final fun toPrecision (I)Lorg/partiql/value/datetime/TimeWithoutTimeZone;
+ public final fun toString ()Ljava/lang/String;
+ public abstract fun withTimeZone (Lorg/partiql/value/datetime/TimeZone;)Lorg/partiql/value/datetime/TimeWithTimeZone;
+}
+
+public abstract class org/partiql/value/datetime/TimeZone {
+}
+
+public final class org/partiql/value/datetime/TimeZone$UnknownTimeZone : org/partiql/value/datetime/TimeZone {
+ public static final field INSTANCE Lorg/partiql/value/datetime/TimeZone$UnknownTimeZone;
+}
+
+public final class org/partiql/value/datetime/TimeZone$UtcOffset : org/partiql/value/datetime/TimeZone {
+ public static final field Companion Lorg/partiql/value/datetime/TimeZone$UtcOffset$Companion;
+ public synthetic fun (ILkotlin/jvm/internal/DefaultConstructorMarker;)V
+ public final fun component1 ()I
+ public final fun copy (I)Lorg/partiql/value/datetime/TimeZone$UtcOffset;
+ public static synthetic fun copy$default (Lorg/partiql/value/datetime/TimeZone$UtcOffset;IILjava/lang/Object;)Lorg/partiql/value/datetime/TimeZone$UtcOffset;
+ public fun equals (Ljava/lang/Object;)Z
+ public final fun getTotalOffsetMinutes ()I
+ public final fun getTzHour ()I
+ public final fun getTzMinute ()I
+ public fun hashCode ()I
+ public static final fun of (I)Lorg/partiql/value/datetime/TimeZone$UtcOffset;
+ public static final fun of (II)Lorg/partiql/value/datetime/TimeZone$UtcOffset;
+ public fun toString ()Ljava/lang/String;
+}
+
+public final class org/partiql/value/datetime/TimeZone$UtcOffset$Companion {
+ public final fun of (I)Lorg/partiql/value/datetime/TimeZone$UtcOffset;
+ public final fun of (II)Lorg/partiql/value/datetime/TimeZone$UtcOffset;
+}
+
+public abstract interface class org/partiql/value/datetime/Timestamp : java/lang/Comparable, org/partiql/value/datetime/DateTime {
+ public abstract fun compareTo (Lorg/partiql/value/datetime/Timestamp;)I
+ public abstract fun getDay ()Ljava/lang/Integer;
+ public abstract fun getDecimalSecond ()Ljava/math/BigDecimal;
+ public abstract fun getHour ()Ljava/lang/Integer;
+ public abstract fun getMinute ()Ljava/lang/Integer;
+ public abstract fun getMonth ()Ljava/lang/Integer;
+ public abstract fun getTimeZone ()Lorg/partiql/value/datetime/TimeZone;
+ public abstract fun getYear ()Ljava/lang/Integer;
+ public abstract fun plusDays (J)Lorg/partiql/value/datetime/Timestamp;
+ public abstract fun plusHours (J)Lorg/partiql/value/datetime/Timestamp;
+ public abstract fun plusMinutes (J)Lorg/partiql/value/datetime/Timestamp;
+ public abstract fun plusMonths (J)Lorg/partiql/value/datetime/Timestamp;
+ public abstract fun plusSeconds (J)Lorg/partiql/value/datetime/Timestamp;
+ public abstract fun plusSeconds (Ljava/math/BigDecimal;)Lorg/partiql/value/datetime/Timestamp;
+ public abstract fun plusYears (J)Lorg/partiql/value/datetime/Timestamp;
+ public abstract fun toDate ()Lorg/partiql/value/datetime/Date;
+ public abstract fun toPrecision (I)Lorg/partiql/value/datetime/Timestamp;
+ public abstract fun toTime ()Lorg/partiql/value/datetime/Time;
+}
+
+public final class org/partiql/value/datetime/Timestamp$DefaultImpls {
+ public static fun compareTo (Lorg/partiql/value/datetime/Timestamp;Lorg/partiql/value/datetime/Timestamp;)I
+ public static fun toDate (Lorg/partiql/value/datetime/Timestamp;)Lorg/partiql/value/datetime/Date;
+}
+
+public abstract class org/partiql/value/datetime/TimestampWithTimeZone : org/partiql/value/datetime/Timestamp {
+ public static final field Companion Lorg/partiql/value/datetime/TimestampWithTimeZone$Companion;
+ public fun ()V
+ public abstract fun atTimeZone (Lorg/partiql/value/datetime/TimeZone;)Lorg/partiql/value/datetime/TimestampWithTimeZone;
+ public synthetic fun compareTo (Ljava/lang/Object;)I
+ public fun compareTo (Lorg/partiql/value/datetime/Timestamp;)I
+ public final fun equals (Ljava/lang/Object;)Z
+ public final fun getEpochMillis ()Ljava/math/BigDecimal;
+ public abstract fun getEpochSecond ()Ljava/math/BigDecimal;
+ public abstract fun getIonRaw ()Lcom/amazon/ion/Timestamp;
+ public final fun getIonTimestampValue ()Lcom/amazon/ion/Timestamp;
+ public abstract fun getTimeZone ()Lorg/partiql/value/datetime/TimeZone;
+ public final fun hashCode ()I
+ public static final fun nowZ ()Lorg/partiql/value/datetime/TimestampWithTimeZone;
+ public abstract fun plusDays (J)Lorg/partiql/value/datetime/TimestampWithTimeZone;
+ public abstract fun plusHours (J)Lorg/partiql/value/datetime/TimestampWithTimeZone;
+ public abstract fun plusMinutes (J)Lorg/partiql/value/datetime/TimestampWithTimeZone;
+ public abstract fun plusMonths (J)Lorg/partiql/value/datetime/TimestampWithTimeZone;
+ public synthetic fun plusSeconds (J)Lorg/partiql/value/datetime/Timestamp;
+ public final fun plusSeconds (J)Lorg/partiql/value/datetime/TimestampWithTimeZone;
+ public abstract fun plusSeconds (Ljava/math/BigDecimal;)Lorg/partiql/value/datetime/TimestampWithTimeZone;
+ public abstract fun plusYears (J)Lorg/partiql/value/datetime/TimestampWithTimeZone;
+ public fun toDate ()Lorg/partiql/value/datetime/Date;
+ public synthetic fun toPrecision (I)Lorg/partiql/value/datetime/Timestamp;
+ public final fun toPrecision (I)Lorg/partiql/value/datetime/TimestampWithTimeZone;
+ public final fun toString ()Ljava/lang/String;
+ public synthetic fun toTime ()Lorg/partiql/value/datetime/Time;
+ public final fun toTime ()Lorg/partiql/value/datetime/TimeWithTimeZone;
+ public abstract fun toTimeWithoutTimeZone (Lorg/partiql/value/datetime/TimeZone;)Lorg/partiql/value/datetime/TimestampWithoutTimeZone;
+}
+
+public final class org/partiql/value/datetime/TimestampWithTimeZone$Companion {
+ public final fun nowZ ()Lorg/partiql/value/datetime/TimestampWithTimeZone;
+}
+
+public abstract class org/partiql/value/datetime/TimestampWithoutTimeZone : org/partiql/value/datetime/Timestamp {
+ public fun ()V
+ public synthetic fun compareTo (Ljava/lang/Object;)I
+ public fun compareTo (Lorg/partiql/value/datetime/Timestamp;)I
+ public final fun equals (Ljava/lang/Object;)Z
+ public fun getTimeZone ()Lorg/partiql/value/datetime/TimeZone;
+ public final fun hashCode ()I
+ public abstract fun plusDays (J)Lorg/partiql/value/datetime/TimestampWithoutTimeZone;
+ public abstract fun plusHours (J)Lorg/partiql/value/datetime/TimestampWithoutTimeZone;
+ public abstract fun plusMinutes (J)Lorg/partiql/value/datetime/TimestampWithoutTimeZone;
+ public abstract fun plusMonths (J)Lorg/partiql/value/datetime/TimestampWithoutTimeZone;
+ public synthetic fun plusSeconds (J)Lorg/partiql/value/datetime/Timestamp;
+ public fun plusSeconds (J)Lorg/partiql/value/datetime/TimestampWithoutTimeZone;
+ public abstract fun plusSeconds (Ljava/math/BigDecimal;)Lorg/partiql/value/datetime/TimestampWithoutTimeZone;
+ public abstract fun plusYears (J)Lorg/partiql/value/datetime/TimestampWithoutTimeZone;
+ public fun toDate ()Lorg/partiql/value/datetime/Date;
+ public synthetic fun toPrecision (I)Lorg/partiql/value/datetime/Timestamp;
+ public final fun toPrecision (I)Lorg/partiql/value/datetime/TimestampWithoutTimeZone;
+ public final fun toString ()Ljava/lang/String;
+ public synthetic fun toTime ()Lorg/partiql/value/datetime/Time;
+ public final fun toTime ()Lorg/partiql/value/datetime/TimeWithoutTimeZone;
+ public abstract fun withTimeZone (Lorg/partiql/value/datetime/TimeZone;)Lorg/partiql/value/datetime/TimestampWithTimeZone;
+}
+
+>>>>>>> e24962f29 (Adds DatumWriter for most types)
public final class org/partiql/value/util/NumberExtensionsKt {
public static final fun coerceNumbers (Ljava/lang/Number;Ljava/lang/Number;)Lkotlin/Pair;
}
diff --git a/partiql-spi/src/main/java/org/partiql/spi/stream/PSink.java b/partiql-spi/src/main/java/org/partiql/spi/stream/PSink.java
new file mode 100644
index 0000000000..0e083d5835
--- /dev/null
+++ b/partiql-spi/src/main/java/org/partiql/spi/stream/PSink.java
@@ -0,0 +1,159 @@
+package org.partiql.spi.stream;
+
+import org.jetbrains.annotations.NotNull;
+import org.partiql.types.PType;
+import org.partiql.value.datetime.Date;
+import org.partiql.value.datetime.Time;
+import org.partiql.value.datetime.Timestamp;
+
+import java.math.BigDecimal;
+
+/**
+ * This is a PartiQL value stream sink.
+ *
+ * Each value can be written with or without type decoration based upon the actual encoding.
+ */
+public interface PSink {
+
+ default void close() {
+ // no-op
+ }
+
+ default void finish() {
+ // no-op
+ }
+
+ default void flush() {
+ // no-op
+ }
+
+ /**
+ * Set the PType for the next written value; cleared after write.
+ */
+ void setType(@NotNull PType type);
+
+ /**
+ * Write NULL value.
+ */
+ void writeNull();
+
+ /**
+ * Write MISSING value.
+ */
+ void writeMissing();
+
+ /**
+ * Write BOOL value.
+ */
+ void writeBool(boolean value);
+
+ /**
+ * Write TINYINT value.
+ */
+ void writeTinyint(byte value);
+
+ /**
+ * Write SMALLINT value.
+ */
+ void writeSmallint(short value);
+
+ /**
+ * Write INT value.
+ */
+ void writeInt(int value);
+
+ /**
+ * Write BIGINT value.
+ */
+ void writeBigint(long value);
+
+ /**
+ * Write NUMERIC value.
+ */
+ void writeNumeric(@NotNull BigDecimal value);
+
+ /**
+ * Write DECIMAL value.
+ */
+ void writeDecimal(@NotNull BigDecimal value);
+
+ /**
+ * Write REAL value.
+ */
+ void writeReal(float value);
+
+ /**
+ * Write DOUBLE PRECISION value.
+ */
+ void writeDouble(double value);
+
+ /**
+ * Write CHAR value.
+ */
+ void writeChar(@NotNull String value);
+
+ /**
+ * Write VARCHAR value.
+ */
+ void writeVarchar(@NotNull String value);
+
+ /**
+ * Write STRING value.
+ */
+ void writeString(@NotNull String value);
+
+ /**
+ * Write BLOB value.
+ */
+ void writeBlob(@NotNull byte[] value);
+
+ /**
+ * Write CLOB value.
+ */
+ void writeClob(@NotNull byte[] value);
+
+ /**
+ * Write DATE value.
+ */
+ void writeDate(@NotNull Date value);
+
+ /**
+ * Write TIME value.
+ */
+ void writeTime(@NotNull Time value);
+
+ /**
+ * Write TIMEZ value.
+ */
+ void writeTimez(@NotNull Time value);
+
+ /**
+ * Write TIMESTAMP value.
+ */
+ void writeTimestamp(@NotNull Timestamp value);
+
+ /**
+ * Write TIMESTAMPZ with given precision.
+ */
+ void writeTimestampz(@NotNull Timestamp value);
+
+ /**
+ * Write a VARIANT type.
+ */
+ void writeVariant(@NotNull T value);
+
+ /**
+ * Write STRUCT or ROW field name.
+ */
+ void writeField(@NotNull String name);
+
+ /**
+ * Step into container, given as PType code.
+ */
+ void stepIn(@NotNull int container);
+
+ /**
+ * Step out of container type.
+ */
+ void stepOut();
+}
diff --git a/partiql-spi/src/main/java/org/partiql/spi/stream/PSource.java b/partiql-spi/src/main/java/org/partiql/spi/stream/PSource.java
new file mode 100644
index 0000000000..f45e8ae4a9
--- /dev/null
+++ b/partiql-spi/src/main/java/org/partiql/spi/stream/PSource.java
@@ -0,0 +1,83 @@
+package org.partiql.spi.stream;
+
+import org.jetbrains.annotations.NotNull;
+import org.partiql.types.PType;
+import org.partiql.value.datetime.Date;
+import org.partiql.value.datetime.Time;
+import org.partiql.value.datetime.Timestamp;
+
+import java.math.BigDecimal;
+
+/**
+ * This is a PartiQL value stream source.
+ *
+ * Developer Note:
+ * - There should be a method for every Datum *java* value and all PType arguments.
+ * - Method names are derived from PType.Kind as pascal case.
+ */
+public interface PSource {
+
+ default void close() {
+ // no-op
+ }
+
+ /**
+ * Positions the source internal pointer to the next value, return its type.
+ */
+ @NotNull
+ PType next();
+
+ boolean readBool();
+
+ byte readTinyint();
+
+ short readSmallint();
+
+ int readInt();
+
+ long readBigint();
+
+ @NotNull
+ BigDecimal readDecimal();
+
+ float readReal();
+
+ double readDouble();
+
+ @NotNull
+ String readChar();
+
+ @NotNull
+ String readVarchar();
+
+ @NotNull
+ String readString();
+
+ @NotNull
+ byte[] readBlob();
+
+ @NotNull
+ byte[] readClob();
+
+ @NotNull
+ Date readDate();
+
+ @NotNull
+ Time readTime();
+
+ @NotNull
+ Time readTimez();
+
+ @NotNull
+ Timestamp readTimestamp();
+
+ @NotNull
+ Timestamp readTimestampz();
+
+ @NotNull
+ String readField(@NotNull String name);
+
+ void stepIn();
+
+ void stepOut();
+}
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 76470b361b..c9ef59894a 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
@@ -83,6 +83,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 PType#BLOB},
* {@link PType#CLOB}
@@ -91,7 +92,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.
*/
@@ -102,6 +103,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 PType#TINYINT}
* @throws UnsupportedOperationException if the operation is not applicable to the type returned from
@@ -109,7 +111,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
@@ -355,6 +357,11 @@ static Datum nullValue(@NotNull PType type) {
/**
* Returns a typed missing value
+<<<<<<< HEAD
+=======
+ * ! EXPERIMENTAL ! This is subject to breaking changes and/or removal without prior notice.
+ *
+>>>>>>> d94a4afd7 (Adds DatumWriter for most types)
* @param type the type of the value
* @return a typed missing value
*/
@@ -390,6 +397,9 @@ static Datum bigint(long value) {
return new DatumLong(value);
}
+ /**
+ * TODO implement or remove NUMERIC.
+ */
@Deprecated
@NotNull
static Datum numeric(@NotNull BigInteger value) {
@@ -429,7 +439,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
*/
@@ -439,7 +448,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.
@@ -461,7 +469,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
*/
@@ -471,7 +478,6 @@ static Datum character(@NotNull String value) {
}
/**
- *
* @param value the string to place in the char
* @return a char value
*/
@@ -552,6 +558,11 @@ static Datum array(@NotNull Iterable values) {
return new DatumCollection(values, PType.array());
}
+ @NotNull
+ static Datum array(@NotNull Iterable values, @NotNull PType typeParam) {
+ return new DatumCollection(values, PType.array(typeParam));
+ }
+
// STRUCTURAL
@NotNull
@@ -581,6 +592,7 @@ static Datum ion(@NotNull String value) {
* {@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
@@ -601,6 +613,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/java/org/partiql/spi/value/DatumWriter.java b/partiql-spi/src/main/java/org/partiql/spi/value/DatumWriter.java
deleted file mode 100644
index f68b45f2b4..0000000000
--- a/partiql-spi/src/main/java/org/partiql/spi/value/DatumWriter.java
+++ /dev/null
@@ -1,16 +0,0 @@
-package org.partiql.spi.value;
-
-/**
- * The {@link DatumWriter} interface is a low-level writer interface for writing streams of PartiQL data.
- *
- * @see java.io.Writer
- */
-public interface DatumWriter extends AutoCloseable {
-
- /**
- * Like java.io.Reader with combined `append` and `write` since this does not implement Appendable.
- *
- * @param datum to write.
- */
- public DatumWriter write(Datum datum);
-}
diff --git a/partiql-spi/src/main/kotlin/org/partiql/spi/value/DatumWriter.kt b/partiql-spi/src/main/kotlin/org/partiql/spi/value/DatumWriter.kt
new file mode 100644
index 0000000000..2d9d4a5a45
--- /dev/null
+++ b/partiql-spi/src/main/kotlin/org/partiql/spi/value/DatumWriter.kt
@@ -0,0 +1,98 @@
+package org.partiql.spi.value
+
+import org.partiql.spi.stream.PSink
+import org.partiql.types.PType
+
+/**
+ * The {@link DatumWriter} provides a high-level interface for writing to a {@link PSink} implementation.
+ */
+public class DatumWriter : AutoCloseable {
+
+ /**
+ * The underlying value encoder.
+ */
+ private val sink: PSink
+
+ /**
+ * Create a DatumWriter (private)
+ */
+ @Suppress("ConvertSecondaryConstructorToPrimary")
+ public constructor(sink: PSink) {
+ this.sink = sink
+ }
+
+ /**
+ * Like java.io.Writer with combined `append` and `write` since this does not implement Appendable.
+ */
+ public fun write(datum: Datum) {
+ write(datum, true)
+ }
+
+ /**
+ * TODO
+ *
+ * @param datum
+ * @param typed
+ */
+ private fun write(datum: Datum, typed: Boolean) {
+ val type = datum.getType()
+ val code = type.code()
+ // always check MISSING
+ if (datum.isMissing) {
+ sink.writeMissing()
+ return
+ }
+ // types can be omitted in homogenous collections (heterogeneous is array)
+ if (typed) {
+ sink.setType(type)
+ }
+ // always check NULL
+ if (datum.isNull) {
+ sink.writeNull()
+ return
+ }
+ // delegate to sink
+ when (code) {
+ PType.DYNAMIC -> error("Unexpected runtime dynamic")
+ PType.BOOL -> sink.writeBool(datum.boolean)
+ PType.TINYINT -> sink.writeTinyint(datum.byte)
+ PType.SMALLINT -> sink.writeSmallint(datum.short)
+ PType.INTEGER -> sink.writeInt(datum.int)
+ PType.BIGINT -> sink.writeBigint(datum.long)
+ PType.NUMERIC -> sink.writeNumeric(datum.bigDecimal)
+ PType.DECIMAL -> sink.writeDecimal(datum.bigDecimal)
+ PType.REAL -> sink.writeReal(datum.float)
+ PType.DOUBLE -> sink.writeDouble(datum.double)
+ PType.CHAR -> sink.writeChar(datum.string)
+ PType.VARCHAR -> sink.writeVarchar(datum.string)
+ PType.STRING -> sink.writeString(datum.string)
+ PType.BLOB -> sink.writeBlob(datum.bytes)
+ PType.CLOB -> sink.writeClob(datum.bytes)
+ PType.DATE,
+ PType.TIME,
+ PType.TIMEZ,
+ PType.TIMESTAMP,
+ PType.TIMESTAMPZ,
+ -> {
+ TODO("datetime blocked on https://github.com/partiql/partiql-lang-kotlin/pull/1656")
+ }
+ PType.ARRAY,
+ PType.BAG,
+ -> {
+ sink.stepIn(code)
+ val dynamic = type.typeParameter.code() == PType.DYNAMIC
+ for (child in datum.iterator()) {
+ write(child, dynamic)
+ }
+ sink.stepOut()
+ }
+ else -> {
+ TODO("unsupported PTYPE")
+ }
+ }
+ }
+
+ public override fun close() {
+ sink.close()
+ }
+}
diff --git a/partiql-spi/src/main/kotlin/org/partiql/spi/value/ion/IonDatumWriter.kt b/partiql-spi/src/main/kotlin/org/partiql/spi/value/ion/IonDatumWriter.kt
deleted file mode 100644
index 92b6374a75..0000000000
--- a/partiql-spi/src/main/kotlin/org/partiql/spi/value/ion/IonDatumWriter.kt
+++ /dev/null
@@ -1,15 +0,0 @@
-package org.partiql.spi.value.ion
-
-import org.partiql.spi.value.Datum
-import org.partiql.spi.value.DatumWriter
-
-internal class IonDatumWriter : DatumWriter {
-
- override fun close() {
- TODO("Not yet implemented")
- }
-
- override fun write(datum: Datum?): DatumWriter {
- TODO("Not yet implemented")
- }
-}
diff --git a/partiql-spi/src/main/kotlin/org/partiql/spi/value/ion/IonSink.kt b/partiql-spi/src/main/kotlin/org/partiql/spi/value/ion/IonSink.kt
new file mode 100644
index 0000000000..eb0eb2e7d3
--- /dev/null
+++ b/partiql-spi/src/main/kotlin/org/partiql/spi/value/ion/IonSink.kt
@@ -0,0 +1,364 @@
+package org.partiql.spi.value.ion
+
+import com.amazon.ion.IonType
+import com.amazon.ion.IonWriter
+import com.amazon.ion.system.IonBinaryWriterBuilder
+import com.amazon.ion.system.IonTextWriterBuilder
+import org.partiql.spi.stream.PSink
+import org.partiql.types.PType
+import org.partiql.value.datetime.Date
+import org.partiql.value.datetime.Time
+import org.partiql.value.datetime.Timestamp
+import java.io.OutputStream
+import java.lang.Double.parseDouble
+import java.math.BigDecimal
+import java.util.BitSet
+
+/**
+ * IonSink is an encoder for PartiQL values using an IonWriter.
+ */
+public class IonSink : PSink {
+
+ /**
+ * The underlying IonWriter
+ */
+ private val writer: IonWriter
+
+ /**
+ * The type elisions.
+ */
+ private val elisions: BitSet
+
+ /**
+ * Create an IonSink from an IonWriter
+ */
+ @Suppress("ConvertSecondaryConstructorToPrimary")
+ public constructor(writer: IonWriter, elisions: BitSet) {
+ this.writer = writer
+ this.elisions = elisions
+ }
+
+ public companion object {
+
+ /**
+ * The standard Ion elisions.
+ */
+ @JvmStatic
+ private val elisions = intArrayOf(
+ PType.BOOL,
+ PType.BIGINT,
+ PType.DOUBLE,
+ PType.STRING,
+ PType.CLOB,
+ PType.BLOB,
+ PType.ARRAY,
+ PType.TIMESTAMP,
+ PType.TIMESTAMPZ,
+ )
+
+ /**
+ * Create a standard IonSink backed by an Ion text writer.
+ */
+ @JvmStatic
+ @JvmOverloads
+ public fun text(out: Appendable, elisions: IntArray? = null): IonSink {
+ return Builder(elisions ?: this.elisions).build((IonTextWriterBuilder.standard().build(out)))
+ }
+
+ /**
+ * Create an IonSink backed by an Ion pretty text writer.
+ */
+ @JvmStatic
+ @JvmOverloads
+ public fun pretty(out: Appendable, elisions: IntArray? = null): IonSink {
+ return Builder(elisions ?: this.elisions).build((IonTextWriterBuilder.pretty().build(out)))
+ }
+
+ /**
+ * Create an IonSink backed by an Ion binary writer.
+ */
+ @JvmStatic
+ @JvmOverloads
+ public fun binary(out: OutputStream, elisions: IntArray? = null): IonSink {
+ return Builder(elisions ?: this.elisions).build((IonBinaryWriterBuilder.standard().build(out)))
+ }
+
+ /**
+ * Create an IonSink backed by the given IonWriter with standard type decorators.
+ */
+ @JvmStatic
+ public fun standard(writer: IonWriter): IonSink {
+ return standard().build(writer)
+ }
+
+ /**
+ * @return a new IonSink.Builder with standard type decorators.
+ */
+ @JvmStatic
+ public fun standard(): Builder = Builder(elisions)
+
+ /**
+ * @return a new IonSink.Builder with all type decorators.
+ */
+ @JvmStatic
+ public fun decorated(): Builder {
+ return Builder(intArrayOf())
+ }
+
+ /**
+ * @return a new IonSink.Builder with all type elisions.
+ */
+ @JvmStatic
+ public fun elided(): Builder {
+ return Builder(PType.codes())
+ }
+ }
+
+ override fun close() {
+ this.writer.close()
+ }
+
+ override fun finish() {
+ this.writer.finish()
+ }
+
+ override fun flush() {
+ this.writer.flush()
+ }
+
+ override fun setType(type: PType) {
+ if (type.code() == PType.UNKNOWN) {
+ return // skip
+ }
+ this.writer.setTypeAnnotations(symbol(type))
+ }
+
+ override fun writeNull() {
+ this.writer.writeNull()
+ }
+
+ override fun writeMissing() {
+ this.writer.writeSymbol("missing")
+ }
+
+ override fun writeBool(value: Boolean) {
+ if (elisions[PType.BOOL]) {
+ this.writer.setTypeAnnotations()
+ }
+ this.writer.writeBool(value)
+ }
+
+ override fun writeTinyint(value: Byte) {
+ if (elisions[PType.TINYINT]) {
+ this.writer.setTypeAnnotations()
+ }
+ this.writer.writeInt(value.toLong())
+ }
+
+ override fun writeSmallint(value: Short) {
+ if (elisions[PType.SMALLINT]) {
+ this.writer.setTypeAnnotations()
+ }
+ this.writer.writeInt(value.toLong())
+ }
+
+ override fun writeInt(value: Int) {
+ if (elisions[PType.INTEGER]) {
+ this.writer.setTypeAnnotations()
+ }
+ this.writer.writeInt(value.toLong())
+ }
+
+ override fun writeBigint(value: Long) {
+ if (elisions[PType.BIGINT]) {
+ this.writer.setTypeAnnotations()
+ }
+ this.writer.writeInt(value)
+ }
+
+ override fun writeNumeric(value: BigDecimal) {
+ if (elisions[PType.NUMERIC]) {
+ this.writer.setTypeAnnotations()
+ }
+ this.writer.writeDecimal(value)
+ }
+
+ override fun writeDecimal(value: BigDecimal) {
+ if (elisions[PType.DECIMAL]) {
+ this.writer.setTypeAnnotations()
+ }
+ this.writer.writeDecimal(value)
+ }
+
+ override fun writeReal(value: Float) {
+ if (elisions[PType.REAL]) {
+ this.writer.setTypeAnnotations()
+ }
+ // IonWriter expects a double,
+ // 1. parseDouble((3.14f).toString()) -> PASS: real:3.14e0
+ // 2. (3.14f).toDouble() -> FAIL: Expected: real::3.14e0, Actual: real::3.140000104904175e0
+ val v = parseDouble(value.toString())
+ this.writer.writeFloat(v)
+ }
+
+ override fun writeDouble(value: Double) {
+ if (elisions[PType.DOUBLE]) {
+ this.writer.setTypeAnnotations()
+ }
+ this.writer.writeFloat(value)
+ }
+
+ override fun writeChar(value: String) {
+ if (elisions[PType.CHAR]) {
+ this.writer.setTypeAnnotations()
+ }
+ this.writer.writeString(value)
+ }
+
+ override fun writeVarchar(value: String) {
+ if (elisions[PType.VARCHAR]) {
+ this.writer.setTypeAnnotations()
+ }
+ this.writer.writeString(value)
+ }
+
+ override fun writeString(value: String) {
+ if (elisions[PType.STRING]) {
+ this.writer.setTypeAnnotations()
+ }
+ this.writer.writeString(value)
+ }
+
+ override fun writeBlob(value: ByteArray) {
+ if (elisions[PType.BLOB]) {
+ this.writer.setTypeAnnotations()
+ }
+ this.writer.writeBlob(value)
+ }
+
+ override fun writeClob(value: ByteArray) {
+ if (elisions[PType.CLOB]) {
+ this.writer.setTypeAnnotations()
+ }
+ this.writer.writeClob(value)
+ }
+
+ override fun writeDate(value: Date) {
+ TODO("datetime blocked on https://github.com/partiql/partiql-lang-kotlin/pull/1656")
+ }
+
+ override fun writeTime(value: Time) {
+ TODO("datetime blocked on https://github.com/partiql/partiql-lang-kotlin/pull/1656")
+ }
+
+ override fun writeTimez(value: Time) {
+ TODO("datetime blocked on https://github.com/partiql/partiql-lang-kotlin/pull/1656")
+ }
+
+ override fun writeTimestamp(value: Timestamp) {
+ TODO("datetime blocked on https://github.com/partiql/partiql-lang-kotlin/pull/1656")
+ }
+
+ override fun writeTimestampz(value: Timestamp) {
+ TODO("datetime blocked on https://github.com/partiql/partiql-lang-kotlin/pull/1656")
+ }
+
+ override fun writeVariant(value: T) {
+ TODO("Not yet implemented")
+ }
+
+ override fun writeField(name: String) {
+ this.writer.setFieldName(name)
+ }
+
+ override fun stepIn(container: Int) {
+ when (container) {
+ PType.ARRAY -> this.writer.stepIn(IonType.LIST)
+ PType.BAG -> this.writer.stepIn(IonType.LIST)
+ PType.ROW -> this.writer.stepIn(IonType.STRUCT)
+ PType.STRUCT -> this.writer.stepIn(IonType.STRUCT)
+ else -> error("Expected ARRAY, BAG, ROW, or STRUCT, found code: $container")
+ }
+ }
+
+ override fun stepOut() {
+ this.writer.stepOut()
+ }
+
+ /**
+ * Writes a PartiQL type as an Ion symbol.
+ */
+ private fun symbol(type: PType): String = when (type.code()) {
+ PType.BOOL -> "bool"
+ PType.TINYINT -> "tinyint"
+ PType.SMALLINT -> "smallint"
+ PType.INTEGER -> "int"
+ PType.BIGINT -> "bigint"
+ PType.NUMERIC -> "numeric(${type.precision},${type.scale})"
+ PType.DECIMAL -> "decimal(${type.precision},${type.scale})"
+ PType.REAL -> "real"
+ PType.DOUBLE -> "double"
+ PType.CHAR -> "char(${type.length})"
+ PType.VARCHAR -> "varchar(${type.length})"
+ PType.STRING -> "string"
+ PType.BLOB -> "blob(${type.length})"
+ PType.CLOB -> "clob(${type.length})"
+ PType.DATE -> "date"
+ PType.TIME -> "time(${type.precision})"
+ PType.TIMEZ -> "timez(${type.precision})"
+ PType.TIMESTAMP -> "timestamp(${type.precision})"
+ PType.TIMESTAMPZ -> "timestampz(${type.precision})"
+ PType.ARRAY -> "array<${symbol(type.typeParameter)}>"
+ PType.BAG -> "bag"
+ PType.ROW -> "row"
+ PType.STRUCT -> "struct"
+ PType.DYNAMIC -> "dynamic"
+ PType.UNKNOWN -> error("Unexpected UNKNOWN type")
+ else -> error("Unexpected ptype code: ${type.code()}")
+ }
+
+ /**
+ * A builder to configure an IonSink.
+ */
+ public class Builder internal constructor(elisions: IntArray) {
+
+ /**
+ * You could make this a bit flag for some throughput gains (maybe).
+ */
+ private val elisions = BitSet()
+
+ init {
+ for (code in elisions) {
+ this.elide(code)
+ }
+ }
+
+ /**
+ * Adds a type elision (removes the type decorator if it exists).
+ *
+ * @return this builder
+ */
+ public fun elide(code: Int): Builder {
+ elisions[code] = true
+ return this
+ }
+
+ /**
+ * Adds a type decorator (removes the type elision if it exists).
+ *
+ * @return this builder
+ */
+ public fun decorate(code: Int): Builder {
+ elisions[code] = false
+ return this
+ }
+
+ /**
+ * @return a new IonSink instance.
+ */
+ public fun build(writer: IonWriter): IonSink {
+ // impls could be smart about which direction to put branches or omit them altogether
+ return IonSink(writer, elisions)
+ }
+ }
+}
diff --git a/partiql-spi/src/test/kotlin/org/partiql/spi/value/ion/IonStreamTest.kt b/partiql-spi/src/test/kotlin/org/partiql/spi/value/ion/IonStreamTest.kt
new file mode 100644
index 0000000000..0b5f01050a
--- /dev/null
+++ b/partiql-spi/src/test/kotlin/org/partiql/spi/value/ion/IonStreamTest.kt
@@ -0,0 +1,168 @@
+package org.partiql.spi.value.ion
+
+import com.amazon.ionelement.api.loadSingleElement
+import org.junit.jupiter.api.Test
+import org.partiql.spi.value.Datum
+import org.partiql.spi.value.DatumWriter
+import org.partiql.types.PType
+import java.math.BigDecimal
+
+/**
+ * Round-trip tests for encoding PartiQL values in Ion; this currently uses all decorators.
+ */
+class IonStreamTest {
+
+ /**
+ * Apply all directions and round-trip.
+ */
+ private fun case(ion: String, datum: Datum) {
+ // assertRead(ion, datum)
+ assertWrite(ion, datum)
+ // assertRoundTrip(datum)
+ }
+
+ @Test
+ fun testNull() {
+ case("null", Datum.nullValue())
+ case("'bool'::null", Datum.nullValue(PType.bool()))
+ case("'decimal(2,0)'::null", Datum.nullValue(PType.decimal(2, 0)))
+ }
+
+ @Test
+ fun testBool() {
+ case("'bool'::null", Datum.nullValue(PType.bool()))
+ case("'bool'::true", Datum.bool(true))
+ case("'bool'::false", Datum.bool(false))
+ }
+
+ @Test
+ fun testNumbers() {
+ // tinyint
+ case("'tinyint'::42", Datum.tinyint(42))
+ case("'tinyint'::-42", Datum.tinyint(-42))
+ // smallint
+ case("'smallint'::42", Datum.smallint(42))
+ case("'smallint'::-42", Datum.smallint(-42))
+ // int
+ case("'int'::42", Datum.integer(42))
+ case("'int'::-42", Datum.integer(-42))
+ // bigint
+ case("'bigint'::42", Datum.bigint(42))
+ case("'bigint'::-42", Datum.bigint(-42))
+ // decimal
+ case("'decimal(3,1)'::10.5", Datum.decimal(BigDecimal("10.5"), 3, 1))
+ case("'decimal(3,1)'::-10.5", Datum.decimal(BigDecimal("-10.5"), 3, 1))
+ // real
+ case("'real'::3.14e0", Datum.real(3.14f))
+ case("'real'::-3.14e0", Datum.real(-3.14f))
+ // double
+ case("'double'::3.1415e0", Datum.doublePrecision(3.1415))
+ case("'double'::-3.1415e0", Datum.doublePrecision(-3.1415))
+ }
+
+ @Test
+ fun testText() {
+ // char
+ case("'char(1)'::\"a\"", Datum.character("a", 1))
+ case("'char(3)'::\"abc\"", Datum.character("abc", 3))
+ // varchar
+ case("'varchar(3)'::\"abc\"", Datum.varchar("abc", 3))
+ case("'varchar(5)'::\"abc \"", Datum.varchar("abc ", 5))
+ // string
+ case("'string'::\"hello\"", Datum.string("hello"))
+ }
+
+ @Test
+ fun testLob() {
+ // clob
+ case("'clob(7)'::{{\"goodbye\"}}", Datum.clob("goodbye".toByteArray(), 7))
+ // blob
+ case("'blob(5)'::{{aGVsbG8=}}", Datum.blob("hello".toByteArray(), 5))
+ }
+
+ @Test
+ fun testDatetime() {
+ // TODO blocked on https://github.com/partiql/partiql-lang-kotlin/pull/1656
+ }
+
+ @Test
+ fun testArray() {
+ // DYNAMIC ARRAY
+ case(
+ "'array'::[int::1, int::2, int::3]",
+ Datum.array(listOf(Datum.integer(1), Datum.integer(2), Datum.integer(3)))
+ )
+ // INT ARRAY (should omit element types)
+ case(
+ "'array'::[1,2,3]",
+ Datum.array(listOf(Datum.integer(1), Datum.integer(2), Datum.integer(3)), PType.integer())
+ )
+ // ARRAY>
+ }
+
+ /**
+ * Assert ion -> datum via IonSource (PSource).
+ */
+ private fun assertRead(ion: String, datum: Datum) {
+ TODO()
+ }
+
+ /**
+ * Assert datum -> ion via IonSink (PSink).
+ *
+ * @param ion
+ * @param datum
+ */
+ private fun assertWrite(ion: String, datum: Datum) {
+ assertEquals(ion, write(datum))
+ }
+
+ /**
+ * Assert round-trip datum->ion->datum with no loss of information.
+ *
+ * @param datum
+ */
+ private fun assertRoundTrip(datum: Datum) {
+ val e: Datum = datum
+ val a: Datum = read(write(e))
+ assertEquals(e, a)
+ }
+
+ private fun write(datum: Datum): String {
+ val sb = StringBuilder()
+ val sink = IonSink.text(sb, elisions = IntArray(0))
+ val writer = DatumWriter(sink)
+ writer.write(datum)
+ return sb.toString()
+ }
+
+ private fun read(ion: String): Datum {
+ // val source = IonSource.decorated().build(ion)
+ // val reader = DatumReader(source)
+ // return reader.read()
+ return Datum.nullValue()
+ }
+
+ /**
+ * Assert ion elements are equal.
+ */
+ private fun assertEquals(expected: String, actual: String) {
+ val e = loadSingleElement(expected)
+ val a = loadSingleElement(actual)
+ if (e != a) {
+ throw AssertionError("Expected: $expected, Actual: $actual")
+ }
+ }
+
+ /**
+ * Assert ion elements are equal.
+ */
+ private fun assertEquals(expected: Datum, actual: Datum) {
+ val comparator = Datum.comparator()
+ if (comparator.compare(expected, actual) != 0) {
+ val e = write(expected)
+ val a = write(actual)
+ throw AssertionError("Expected: $e, Actual: $a")
+ }
+ }
+}
diff --git a/partiql-types/src/main/java/org/partiql/types/PType.java b/partiql-types/src/main/java/org/partiql/types/PType.java
index 89e351b4c8..b2ce4d939a 100644
--- a/partiql-types/src/main/java/org/partiql/types/PType.java
+++ b/partiql-types/src/main/java/org/partiql/types/PType.java
@@ -743,6 +743,7 @@ public static PType array() {
*/
@NotNull
public static PType array(@NotNull PType typeParam) {
+ // TODO optional length https://github.com/partiql/partiql-lang-kotlin/issues/1686
return new PTypeCollection(ARRAY, typeParam);
}
@@ -760,6 +761,7 @@ public static PType bag() {
*/
@NotNull
public static PType bag(@NotNull PType typeParam) {
+ // TODO optional length https://github.com/partiql/partiql-lang-kotlin/issues/1686
return new PTypeCollection(BAG, typeParam);
}
From c2a90f8cd0a7c69a239433e7bee8b21de71ed347 Mon Sep 17 00:00:00 2001
From: "R. C. Howell"
Date: Tue, 7 Jan 2025 09:58:52 -0800
Subject: [PATCH 2/3] Backup
---
docs/wiki/v1/streams.md | 97 +++++++++++++++++++
.../java/org/partiql/spi/stream/PSink.java | 2 +-
2 files changed, 98 insertions(+), 1 deletion(-)
diff --git a/docs/wiki/v1/streams.md b/docs/wiki/v1/streams.md
index 4fac790da9..bb25192020 100644
--- a/docs/wiki/v1/streams.md
+++ b/docs/wiki/v1/streams.md
@@ -28,6 +28,103 @@ So how does PartiQL read values from a stream into Datums, and how does it handl
encoding may include a data type or it may not. Also, the reader itself may expect a type (or not). Consider that a
PartiQL value carries a type with it along with the value itself.
+## Type Syntax
+
+PartiQL values can be annotated with their exact types; this section defines the type annotation syntax.
+
+```
+type_t ::= bool_t
+ | tinyint_t
+ | smallint_t
+ | int_t
+ | bigint_t
+ | numeric_t
+ | decimal_t
+ | float_t
+ | real_t
+ | double_t
+ | char_t
+ | varchar_t
+ | string_t
+ | blob_t
+ | clob_t
+ | date_t
+ | time_t
+ | timez_t
+ | timestamp_t
+ | timestampz_t
+ | array_t
+ | bag_t
+ | struct_t
+ | variant_t
+
+bool_t ::= 'bool'
+
+tinyint_t ::= 'tinyint'
+
+smallint_t ::= 'smallint'
+
+int_t ::= 'int'
+
+bigint_t ::= 'bigint'
+
+numeric_t ::= 'numeric' '(' uint ',' uint ')'
+
+decimal_t ::= 'decimal' '(' uint ',' uint ')'
+
+float_t ::= 'float' '(' uint ')'
+
+real_t ::= 'real'
+
+double_t ::= 'double'
+
+char_t ::= 'char' '(' uint ')'
+
+varchar_t ::= 'varchar' '(' uint ')'
+
+string_t ::= 'string'
+
+blob_t ::= 'blob' '(' uint ')'
+
+clob_t ::= 'clob' '(' uint ')'
+
+date_t ::= 'date'
+
+time_t ::= 'time' '(' uint ')'
+
+timez_t ::= 'timez' '(' uint ')'
+
+timestamp_t ::= 'timestamp' '(' uint ')'
+
+timestampz_t ::= 'timestampz' '(' uint ')'
+
+array_t
+ ::= 'array'
+ | 'array' '<' type_t '>'
+ | 'array' '<' type_t '>' '(' uint ')'
+
+bag_t
+ ::= 'bag'
+ | 'bag' '<' type_t '>'
+ | 'bag' '<' type_t '>' '(' uint ')'
+
+struct_t
+ ::= 'struct'
+ | 'struct' '<' struct_t_fields '>'
+
+struct_t_fields ::= struct_t_field (',' struct_t_field )
+
+struct_t_field ::= name ':' type_t
+
+variant_t ::= 'variant' '(' name ')'
+
+uint = [0-9]+
+
+name = [A-Za-z]
+```
+
+> This does NOT include things like union types, map types, and the row type.
+
## Writing Data
### PSink
diff --git a/partiql-spi/src/main/java/org/partiql/spi/stream/PSink.java b/partiql-spi/src/main/java/org/partiql/spi/stream/PSink.java
index 0e083d5835..495a0a482b 100644
--- a/partiql-spi/src/main/java/org/partiql/spi/stream/PSink.java
+++ b/partiql-spi/src/main/java/org/partiql/spi/stream/PSink.java
@@ -150,7 +150,7 @@ default void flush() {
/**
* Step into container, given as PType code.
*/
- void stepIn(@NotNull int container);
+ void stepIn(int container);
/**
* Step out of container type.
From 779387b861b996d1f406fbb96ee8f9628b4afb5c Mon Sep 17 00:00:00 2001
From: "R. C. Howell"
Date: Tue, 7 Jan 2025 10:19:27 -0800
Subject: [PATCH 3/3] Backup
---
.../java/org/partiql/spi/stream/PSink.java | 18 ++++---
.../org/partiql/spi/value/ion/IonSink.kt | 49 ++++++++++++++-----
.../partiql/spi/value/ion/IonStreamTest.kt | 11 ++++-
3 files changed, 56 insertions(+), 22 deletions(-)
diff --git a/partiql-spi/src/main/java/org/partiql/spi/stream/PSink.java b/partiql-spi/src/main/java/org/partiql/spi/stream/PSink.java
index 495a0a482b..95665bcf95 100644
--- a/partiql-spi/src/main/java/org/partiql/spi/stream/PSink.java
+++ b/partiql-spi/src/main/java/org/partiql/spi/stream/PSink.java
@@ -2,11 +2,13 @@
import org.jetbrains.annotations.NotNull;
import org.partiql.types.PType;
-import org.partiql.value.datetime.Date;
-import org.partiql.value.datetime.Time;
-import org.partiql.value.datetime.Timestamp;
import java.math.BigDecimal;
+import java.time.LocalDate;
+import java.time.LocalDateTime;
+import java.time.LocalTime;
+import java.time.OffsetDateTime;
+import java.time.OffsetTime;
/**
* This is a PartiQL value stream sink.
@@ -115,27 +117,27 @@ default void flush() {
/**
* Write DATE value.
*/
- void writeDate(@NotNull Date value);
+ void writeDate(@NotNull LocalDate value);
/**
* Write TIME value.
*/
- void writeTime(@NotNull Time value);
+ void writeTime(@NotNull LocalTime value);
/**
* Write TIMEZ value.
*/
- void writeTimez(@NotNull Time value);
+ void writeTimez(@NotNull OffsetTime value);
/**
* Write TIMESTAMP value.
*/
- void writeTimestamp(@NotNull Timestamp value);
+ void writeTimestamp(@NotNull LocalDateTime value);
/**
* Write TIMESTAMPZ with given precision.
*/
- void writeTimestampz(@NotNull Timestamp value);
+ void writeTimestampz(@NotNull OffsetDateTime value);
/**
* Write a VARIANT type.
diff --git a/partiql-spi/src/main/kotlin/org/partiql/spi/value/ion/IonSink.kt b/partiql-spi/src/main/kotlin/org/partiql/spi/value/ion/IonSink.kt
index eb0eb2e7d3..23e70047e5 100644
--- a/partiql-spi/src/main/kotlin/org/partiql/spi/value/ion/IonSink.kt
+++ b/partiql-spi/src/main/kotlin/org/partiql/spi/value/ion/IonSink.kt
@@ -2,16 +2,19 @@ package org.partiql.spi.value.ion
import com.amazon.ion.IonType
import com.amazon.ion.IonWriter
+import com.amazon.ion.Timestamp
import com.amazon.ion.system.IonBinaryWriterBuilder
import com.amazon.ion.system.IonTextWriterBuilder
import org.partiql.spi.stream.PSink
import org.partiql.types.PType
-import org.partiql.value.datetime.Date
-import org.partiql.value.datetime.Time
-import org.partiql.value.datetime.Timestamp
import java.io.OutputStream
import java.lang.Double.parseDouble
import java.math.BigDecimal
+import java.time.LocalDate
+import java.time.LocalDateTime
+import java.time.LocalTime
+import java.time.OffsetDateTime
+import java.time.OffsetTime
import java.util.BitSet
/**
@@ -243,24 +246,44 @@ public class IonSink : PSink {
this.writer.writeClob(value)
}
- override fun writeDate(value: Date) {
- TODO("datetime blocked on https://github.com/partiql/partiql-lang-kotlin/pull/1656")
+ override fun writeDate(value: LocalDate) {
+ if (elisions[PType.DATE]) {
+ this.writer.setTypeAnnotations()
+ }
+ val iso8601 = value.toString()
+ this.writer.writeString(iso8601)
}
- override fun writeTime(value: Time) {
- TODO("datetime blocked on https://github.com/partiql/partiql-lang-kotlin/pull/1656")
+ override fun writeTime(value: LocalTime) {
+ if (elisions[PType.TIME]) {
+ this.writer.setTypeAnnotations()
+ }
+ val iso8601 = value.toString()
+ this.writer.writeString(iso8601)
}
- override fun writeTimez(value: Time) {
- TODO("datetime blocked on https://github.com/partiql/partiql-lang-kotlin/pull/1656")
+ override fun writeTimez(value: OffsetTime) {
+ if (elisions[PType.TIMEZ]) {
+ this.writer.setTypeAnnotations()
+ }
+ val iso8601 = value.toString()
+ this.writer.writeString(iso8601)
}
- override fun writeTimestamp(value: Timestamp) {
- TODO("datetime blocked on https://github.com/partiql/partiql-lang-kotlin/pull/1656")
+ override fun writeTimestamp(value: LocalDateTime) {
+ if (elisions[PType.TIMESTAMP]) {
+ this.writer.setTypeAnnotations()
+ }
+ val iso8601 = value.toString()
+ this.writer.writeString(iso8601)
}
- override fun writeTimestampz(value: Timestamp) {
- TODO("datetime blocked on https://github.com/partiql/partiql-lang-kotlin/pull/1656")
+ override fun writeTimestampz(value: OffsetDateTime) {
+ if (elisions[PType.TIMESTAMPZ]) {
+ this.writer.setTypeAnnotations()
+ }
+ val iso8601 = value.toString()
+ this.writer.writeString(iso8601)
}
override fun writeVariant(value: T) {
diff --git a/partiql-spi/src/test/kotlin/org/partiql/spi/value/ion/IonStreamTest.kt b/partiql-spi/src/test/kotlin/org/partiql/spi/value/ion/IonStreamTest.kt
index 0b5f01050a..6817e96bd8 100644
--- a/partiql-spi/src/test/kotlin/org/partiql/spi/value/ion/IonStreamTest.kt
+++ b/partiql-spi/src/test/kotlin/org/partiql/spi/value/ion/IonStreamTest.kt
@@ -82,7 +82,16 @@ class IonStreamTest {
@Test
fun testDatetime() {
- // TODO blocked on https://github.com/partiql/partiql-lang-kotlin/pull/1656
+ // date
+
+ // time
+
+ // timez
+
+ // timestamp
+
+ // timestampz
+ case("'timestamp'::2017-01-01T00:00:00Z", Datum.timestamp(2017, 1, 1, 0, 0, 0, 0, 0))
}
@Test