>From Ritik Raj <[email protected]>:
Ritik Raj has uploaded this change for review. (
https://asterix-gerrit.ics.uci.edu/c/asterixdb/+/20792?usp=email )
Change subject: [ASTERIXDB-3684][STO] Added testcases related to temporal types
......................................................................
[ASTERIXDB-3684][STO] Added testcases related to temporal types
- user model changes: no
- storage format changes: no
- interface changes: no
Ext-ref: MB-66257
Change-Id: I35231099dc48077f61a5cff32c58232461edf82e
---
M
asterixdb/asterix-column/src/test/java/org/apache/asterix/column/common/test/TestBase.java
A
asterixdb/asterix-column/src/test/java/org/apache/asterix/column/encdec/ParquetDeltaBinaryPackingValuesWriterForIntegerTest.java
A asterixdb/asterix-column/src/test/resources/data/400-temporal.json
A asterixdb/asterix-column/src/test/resources/data/401-array-temporal.json
A asterixdb/asterix-column/src/test/resources/data/402-union-temporal.json
A
asterixdb/asterix-column/src/test/resources/data/403-union-temporal-nontemporal.json
A
asterixdb/asterix-column/src/test/resources/data/404-array-mixed-temporal-nontemporal.json
M asterixdb/asterix-column/src/test/resources/only.txt
A asterixdb/asterix-column/src/test/resources/result/assembler/400-temporal.json
A
asterixdb/asterix-column/src/test/resources/result/assembler/401-array-temporal.json
A
asterixdb/asterix-column/src/test/resources/result/assembler/402-union-temporal.json
A
asterixdb/asterix-column/src/test/resources/result/assembler/403-union-temporal-nontemporal.json
A
asterixdb/asterix-column/src/test/resources/result/assembler/404-array-mixed-temporal-nontemporal.json
A asterixdb/asterix-column/src/test/resources/result/small/400-temporal.json
A
asterixdb/asterix-column/src/test/resources/result/small/401-array-temporal.json
A
asterixdb/asterix-column/src/test/resources/result/small/402-union-temporal.json
A
asterixdb/asterix-column/src/test/resources/result/small/403-union-temporal-nontemporal.json
A
asterixdb/asterix-column/src/test/resources/result/small/404-array-mixed-temporal-nontemporal.json
A
asterixdb/asterix-column/src/test/resources/result/transformer/400-temporal.schema
A
asterixdb/asterix-column/src/test/resources/result/transformer/401-array-temporal.schema
A
asterixdb/asterix-column/src/test/resources/result/transformer/402-union-temporal.schema
A
asterixdb/asterix-column/src/test/resources/result/transformer/403-union-temporal-nontemporal.schema
A
asterixdb/asterix-column/src/test/resources/result/transformer/404-array-mixed-temporal-nontemporal.schema
23 files changed, 526 insertions(+), 9 deletions(-)
git pull ssh://asterix-gerrit.ics.uci.edu:29418/asterixdb
refs/changes/92/20792/1
diff --git
a/asterixdb/asterix-column/src/test/java/org/apache/asterix/column/common/test/TestBase.java
b/asterixdb/asterix-column/src/test/java/org/apache/asterix/column/common/test/TestBase.java
index 28571b2..e9381d1 100644
---
a/asterixdb/asterix-column/src/test/java/org/apache/asterix/column/common/test/TestBase.java
+++
b/asterixdb/asterix-column/src/test/java/org/apache/asterix/column/common/test/TestBase.java
@@ -38,13 +38,12 @@
import java.util.function.Predicate;
import java.util.stream.Collectors;
-import org.apache.asterix.external.parser.JSONDataParser;
+import org.apache.asterix.external.api.IStreamDataParser;
+import org.apache.asterix.external.parser.ADMDataParser;
import org.apache.asterix.om.pointables.base.DefaultOpenFieldType;
import org.apache.hyracks.api.exceptions.HyracksDataException;
import org.apache.hyracks.api.util.IoUtil;
-import com.fasterxml.jackson.core.JsonFactory;
-
public abstract class TestBase {
public static final File OUTPUT_PATH;
public static final File DATA_PATH;
@@ -54,13 +53,14 @@
private static final Map<Class<?>, TestPath> TEST_PATH_MAP;
protected final TestCase testCase;
- protected final JSONDataParser parser;
+ protected final IStreamDataParser parser;
static {
TEST_PATH_MAP = new HashMap<>();
ClassLoader classLoader = TestBase.class.getClassLoader();
OUTPUT_PATH = new File("target", "result");
+
TESTS = new
File(Objects.requireNonNull(classLoader.getResource("only.txt")).getPath());
DATA_PATH = new
File(Objects.requireNonNull(classLoader.getResource("data")).getPath());
RESULT_PATH = new
File(Objects.requireNonNull(classLoader.getResource("result")).getPath());
@@ -68,14 +68,13 @@
protected TestBase(TestCase testCase) throws HyracksDataException {
this.testCase = testCase;
- JsonFactory jsonFactory = new JsonFactory();
- parser = new
JSONDataParser(DefaultOpenFieldType.NESTED_OPEN_RECORD_TYPE, jsonFactory);
+ parser = new
ADMDataParser(DefaultOpenFieldType.NESTED_OPEN_RECORD_TYPE, true);
}
protected void prepareParser(File testFile) throws IOException {
//Prepare parser
FileInputStream inputStream = new FileInputStream(testFile);
- parser.reset(inputStream);
+ parser.setInputStream(inputStream);
}
protected static void setup(Class<?> clazz) throws IOException {
@@ -115,8 +114,12 @@
}
private static Set<String> getOnly() throws FileNotFoundException {
- BufferedReader reader = new BufferedReader(new FileReader(TESTS));
- return reader.lines().filter(l -> !l.trim().isEmpty() && l.charAt(0)
!= '#').collect(Collectors.toSet());
+ try (BufferedReader reader = new BufferedReader(new
FileReader(TESTS))) {
+ return reader.lines().filter(l -> !l.trim().isEmpty() &&
l.charAt(0) != '#').collect(Collectors.toSet());
+ } catch (IOException e) {
+ // FileReader/BufferedReader creation should only fail due to IO
errors; preserve method signature.
+ throw new RuntimeException(e);
+ }
}
private static class TestPath {
diff --git
a/asterixdb/asterix-column/src/test/java/org/apache/asterix/column/encdec/ParquetDeltaBinaryPackingValuesWriterForIntegerTest.java
b/asterixdb/asterix-column/src/test/java/org/apache/asterix/column/encdec/ParquetDeltaBinaryPackingValuesWriterForIntegerTest.java
new file mode 100644
index 0000000..e8c44a8
--- /dev/null
+++
b/asterixdb/asterix-column/src/test/java/org/apache/asterix/column/encdec/ParquetDeltaBinaryPackingValuesWriterForIntegerTest.java
@@ -0,0 +1,375 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.asterix.column.encdec;
+
+import java.io.ByteArrayOutputStream;
+import java.nio.ByteBuffer;
+import java.util.Arrays;
+import java.util.Queue;
+import java.util.Random;
+
+import
org.apache.asterix.column.bytes.decoder.ParquetDeltaBinaryPackingValuesReader;
+import
org.apache.asterix.column.bytes.encoder.ParquetDeltaBinaryPackingValuesWriterForInteger;
+import org.apache.asterix.column.bytes.stream.in.ByteBufferInputStream;
+import org.apache.asterix.column.common.buffer.DummyBufferCache;
+import org.apache.asterix.column.common.buffer.TestWriteMultiPageOp;
+import org.apache.commons.lang3.mutable.Mutable;
+import org.apache.commons.lang3.mutable.MutableObject;
+import
org.apache.hyracks.storage.am.lsm.btree.column.api.IColumnBufferProvider;
+import
org.apache.hyracks.storage.am.lsm.btree.column.api.IColumnWriteMultiPageOp;
+import org.apache.parquet.bytes.BytesInput;
+import org.apache.parquet.io.ParquetDecodingException;
+import org.junit.Assert;
+import org.junit.Test;
+
+public class ParquetDeltaBinaryPackingValuesWriterForIntegerTest {
+ private static final int PAGE_SIZE = 256 * 1024;
+
+ @Test
+ public void testEmptyPageRoundTrip() throws Exception {
+ // Not a typical production case (writers usually know the tuple
count),
+ // but we still want deterministic behavior and no crashes.
+ int[] values = new int[0];
+ assertRoundTrip(values);
+ }
+
+ @Test
+ public void testSingleValueRoundTripAndReadBeyondThrows() throws Exception
{
+ int[] values = new int[] { 42 };
+ assertRoundTrip(values);
+ }
+
+ @Test
+ public void testConstantValuesWithPaddingAndZeroBitWidth() throws
Exception {
+ // Ensure: deltas are always 0 -> bit width can be 0, and tuple count
isn't aligned to miniblock size (32).
+ int[] values = new int[35];
+ for (int i = 0; i < values.length; i++) {
+ values[i] = 7;
+ }
+ assertRoundTrip(values);
+ }
+
+ @Test
+ public void testOverflowDeltasRoundTrip() throws Exception {
+ // Forces delta overflow cases (int modular arithmetic), which this
writer explicitly claims to handle.
+ int[] values = new int[] { Integer.MAX_VALUE, Integer.MIN_VALUE, 0,
-1, Integer.MAX_VALUE, Integer.MIN_VALUE };
+ assertRoundTrip(values);
+ }
+
+ @Test
+ public void testRandomValuesRoundTripAcrossMultipleBlocks() throws
Exception {
+ // Default block size is 128, so this crosses multiple blocks and
triggers internal flushes.
+ Random rnd = new Random(0xC0FFEE);
+ int[] values = new int[2048];
+ for (int i = 0; i < values.length; i++) {
+ values[i] = rnd.nextInt();
+ }
+ assertRoundTrip(values);
+ }
+
+ @Test
+ public void testExactMiniBlockAndBlockBoundaries() throws Exception {
+ // Mini block size is 32 (DEFAULT_NUM_BLOCK_VALUES=128,
DEFAULT_NUM_MINIBLOCKS=4).
+ assertRoundTrip(increasingSequence(32));
+ assertRoundTrip(increasingSequence(128));
+ // Crosses exactly into the next block and requires block flush + new
block header.
+ assertRoundTrip(increasingSequence(129));
+ }
+
+ @Test
+ public void testBitWidthSwingWithinBlock() throws Exception {
+ // Small deltas for a while, then a huge delta to force a larger bit
width.
+ int[] values = new int[96];
+ values[0] = 0;
+ for (int i = 1; i < 64; i++) {
+ values[i] = values[i - 1] + 1;
+ }
+ // Force a big jump but without int overflow.
+ values[64] = Integer.MAX_VALUE / 2;
+ for (int i = 65; i < values.length; i++) {
+ values[i] = values[i - 1] + 1;
+ }
+ assertRoundTrip(values);
+ }
+
+ @Test
+ public void testTruncatedPageFailsFast() throws Exception {
+ int[] values = increasingSequence(256);
+ WriterAndReaderFactory factory = new WriterAndReaderFactory();
+ ParquetDeltaBinaryPackingValuesWriterForInteger writer =
factory.createWriter();
+ for (int v : values) {
+ writer.writeInteger(v);
+ }
+ byte[] page = toByteArray(writer.getBytes());
+
+ // Truncate at multiple points (including some inside the delta
blocks).
+ // Expect initFromPage() or subsequent reads to fail.
+ for (int cut = 0; cut < page.length; cut += Math.max(1, page.length /
25)) {
+ byte[] truncated = Arrays.copyOf(page, cut);
+ assertCorruptPageDoesNotRoundTrip(truncated, values, 512);
+ }
+ }
+
+ @Test
+ public void testBodyBitFlipCorruptionDoesNotSilentlyRoundTrip() throws
Exception {
+ // Important: only corrupt bytes after the header
(config/count/firstValue) to avoid
+ // pathological allocations from a corrupted config.
+ int[] values = new int[512];
+ Random rnd = new Random(0xBADC0DE);
+ values[0] = rnd.nextInt();
+ for (int i = 1; i < values.length; i++) {
+ // Use small deltas to keep encoding compact and deterministic
+ values[i] = values[i - 1] + (rnd.nextInt(5) - 2);
+ }
+
+ WriterAndReaderFactory factory = new WriterAndReaderFactory();
+ ParquetDeltaBinaryPackingValuesWriterForInteger writer =
factory.createWriter();
+ for (int v : values) {
+ writer.writeInteger(v);
+ }
+ byte[] page = toByteArray(writer.getBytes());
+ int headerLen = headerLength(page);
+
+ // Flip random bits in the body and ensure we either throw or don't
decode back to the same values.
+ for (int i = 0; i < 200; i++) {
+ byte[] mutated = Arrays.copyOf(page, page.length);
+ // Corrupt close to the start of the body to avoid flipping bytes
that only affect padded/unread values.
+ int start = Math.min(headerLen, mutated.length - 1);
+ int endExclusive = Math.min(mutated.length, headerLen + 128);
+ if (endExclusive <= start) {
+ endExclusive = mutated.length;
+ }
+ int idx = start + rnd.nextInt(Math.max(1, endExclusive - start));
+ mutated[idx] ^= (byte) (1 << (rnd.nextInt(8)));
+ assertCorruptPageDoesNotRoundTrip(mutated, values, 2048);
+ }
+ }
+
+ @Test
+ public void testResetProducesIndependentPages() throws Exception {
+ WriterAndReaderFactory factory = new WriterAndReaderFactory();
+ ParquetDeltaBinaryPackingValuesWriterForInteger writer =
factory.createWriter();
+
+ int[] first = new int[] { -10, -9, -8, -7, -7, -7, 0, 3, 10 };
+ for (int v : first) {
+ writer.writeInteger(v);
+ }
+ byte[] firstPage = toByteArray(writer.getBytes());
+
+ writer.reset();
+
+ int[] second = new int[] { 100, 50, 25, 0, -25, -50, -100 };
+ for (int v : second) {
+ writer.writeInteger(v);
+ }
+ byte[] secondPage = toByteArray(writer.getBytes());
+
+ Assert.assertArrayEquals(first, decodePage(firstPage));
+ Assert.assertArrayEquals(second, decodePage(secondPage));
+ }
+
+ private static void assertRoundTrip(int[] values) throws Exception {
+ WriterAndReaderFactory factory = new WriterAndReaderFactory();
+ ParquetDeltaBinaryPackingValuesWriterForInteger writer =
factory.createWriter();
+ for (int v : values) {
+ writer.writeInteger(v);
+ }
+
+ byte[] page = toByteArray(writer.getBytes());
+ Assert.assertArrayEquals(values, decodePage(page));
+ }
+
+ private static int[] decodePage(byte[] pageBytes) throws Exception {
+ ParquetDeltaBinaryPackingValuesReader reader = new
ParquetDeltaBinaryPackingValuesReader();
+ ByteBufferInputStream in = new ByteBufferInputStream();
+ in.reset(new SingleBufferProvider(ByteBuffer.wrap(pageBytes)));
+ reader.initFromPage(in);
+
+ // Decode exactly the values we wrote by reading until the reader
signals "no more values" via exception.
+ // The encoded format contains the totalValueCount, so attempting to
read beyond it must fail.
+ int[] out = new int[0];
+ int size = 0;
+ while (true) {
+ try {
+ int v = reader.readInteger();
+ if (size == out.length) {
+ int[] grown = new int[Math.max(8, out.length * 2)];
+ System.arraycopy(out, 0, grown, 0, out.length);
+ out = grown;
+ }
+ out[size++] = v;
+ } catch (ParquetDecodingException e) {
+ break;
+ }
+ }
+
+ int[] exact = new int[size];
+ System.arraycopy(out, 0, exact, 0, size);
+
+ // Must throw again if we try to read once more.
+ try {
+ reader.readInteger();
+ Assert.fail("Expected ParquetDecodingException when reading beyond
totalValueCount");
+ } catch (ParquetDecodingException expected) {
+ // expected
+ }
+
+ return exact;
+ }
+
+ private static int[] increasingSequence(int length) {
+ int[] values = new int[length];
+ for (int i = 0; i < length; i++) {
+ values[i] = i;
+ }
+ return values;
+ }
+
+ private static byte[] toByteArray(BytesInput bytesInput) throws Exception {
+ ByteArrayOutputStream bos = new ByteArrayOutputStream();
+ bytesInput.writeAllTo(bos);
+ return bos.toByteArray();
+ }
+
+ private static void assertCorruptPageDoesNotRoundTrip(byte[]
corruptedPage, int[] expectedValues, int maxReads)
+ throws Exception {
+ try {
+ int[] decoded = decodePageWithReadLimit(corruptedPage, maxReads);
+ // If it didn't throw, it must not silently round-trip to the
exact same values.
+ Assert.assertFalse("Corrupted page unexpectedly decoded to the
original values",
+ Arrays.equals(expectedValues, decoded));
+ } catch (Exception e) {
+ // Any decoding exception is acceptable. We only want to ensure we
don't silently succeed.
+ }
+ }
+
+ private static int[] decodePageWithReadLimit(byte[] pageBytes, int
maxReads) throws Exception {
+ ParquetDeltaBinaryPackingValuesReader reader = new
ParquetDeltaBinaryPackingValuesReader();
+ ByteBufferInputStream in = new ByteBufferInputStream();
+ in.reset(new SingleBufferProvider(ByteBuffer.wrap(pageBytes)));
+ reader.initFromPage(in);
+
+ int[] out = new int[Math.max(8, Math.min(256, maxReads))];
+ int size = 0;
+ for (int i = 0; i < maxReads; i++) {
+ try {
+ int v = reader.readInteger();
+ if (size == out.length) {
+ int[] grown = new int[Math.min(maxReads, out.length * 2)];
+ System.arraycopy(out, 0, grown, 0, out.length);
+ out = grown;
+ }
+ out[size++] = v;
+ } catch (ParquetDecodingException e) {
+ int[] exact = new int[size];
+ System.arraycopy(out, 0, exact, 0, size);
+ return exact;
+ }
+ }
+ // If we managed to read maxReads values without an exception, treat
it as a failure signal.
+ throw new AssertionError("Decoded " + maxReads + " integers from a
corrupted page without failing");
+ }
+
+ /**
+ * Computes the encoded header length: blockSize(varint) +
miniBlockNum(varint) + totalValueCount(varint)
+ * + firstValue(zigzag varint).
+ *
+ * <p>
+ * This is used to avoid corrupting the config in fuzz tests (which could
lead to huge allocations).
+ */
+ private static int headerLength(byte[] page) throws Exception {
+ int p = 0;
+ p = skipUnsignedVarInt(page, p);
+ p = skipUnsignedVarInt(page, p);
+ p = skipUnsignedVarInt(page, p);
+ p = skipZigZagVarInt(page, p);
+ return p;
+ }
+
+ private static int skipUnsignedVarInt(byte[] b, int p) throws Exception {
+ // Max 5 bytes for int32 varint.
+ for (int i = 0; i < 5; i++) {
+ if (p >= b.length) {
+ throw new java.io.EOFException();
+ }
+ int v = b[p++] & 0xFF;
+ if ((v & 0x80) == 0) {
+ return p;
+ }
+ }
+ throw new IllegalArgumentException("Invalid varint (too long)");
+ }
+
+ private static int skipZigZagVarInt(byte[] b, int p) throws Exception {
+ // Same encoding width as unsigned varint for int32.
+ return skipUnsignedVarInt(b, p);
+ }
+
+ private static final class WriterAndReaderFactory {
+ private final Mutable<IColumnWriteMultiPageOp> multiPageOpRef;
+
+ private WriterAndReaderFactory() {
+ DummyBufferCache dummyBufferCache = new
DummyBufferCache(PAGE_SIZE);
+ int fileId = dummyBufferCache.createFile();
+ this.multiPageOpRef = new MutableObject<>(new
TestWriteMultiPageOp(dummyBufferCache, fileId));
+ }
+
+ private ParquetDeltaBinaryPackingValuesWriterForInteger createWriter()
{
+ return new
ParquetDeltaBinaryPackingValuesWriterForInteger(multiPageOpRef);
+ }
+ }
+
+ private static final class SingleBufferProvider implements
IColumnBufferProvider {
+ private final ByteBuffer buffer;
+
+ private SingleBufferProvider(ByteBuffer buffer) {
+ this.buffer = buffer;
+ }
+
+ @Override
+ public void
reset(org.apache.hyracks.storage.am.lsm.btree.column.impls.btree.ColumnBTreeReadLeafFrame
frame) {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public void readAll(Queue<ByteBuffer> buffers) {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public void releaseAll() {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public ByteBuffer getBuffer() {
+ return buffer;
+ }
+
+ @Override
+ public int getLength() {
+ return buffer.remaining();
+ }
+
+ @Override
+ public int getColumnIndex() {
+ return 0;
+ }
+ }
+}
diff --git a/asterixdb/asterix-column/src/test/resources/data/400-temporal.json
b/asterixdb/asterix-column/src/test/resources/data/400-temporal.json
new file mode 100644
index 0000000..75a042b
--- /dev/null
+++ b/asterixdb/asterix-column/src/test/resources/data/400-temporal.json
@@ -0,0 +1,4 @@
+{"date":date("2024-01-02"),"time":time("12:34:56.789Z"),"datetime":datetime("2024-01-02T03:04:05.006Z"),"ymd":year-month-duration("P2Y3M"),"dtd":day-time-duration("PT36H"),"duration":duration("P1Y2M3DT4H5M6.007S")}
+{"date":date("1970-01-01"),"time":time("00:00:00.000Z"),"datetime":datetime("1970-01-01T00:00:00.000Z"),"ymd":year-month-duration("P0Y0M"),"dtd":day-time-duration("PT0S"),"duration":duration("P0D")}
+{"date":date("9999-12-31"),"time":time("23:59:59.999Z"),"datetime":datetime("9999-12-31T23:59:59.999Z"),"ymd":year-month-duration("P120Y11M"),"dtd":day-time-duration("PT999999S"),"duration":duration("P3650D")}
+{"date":null,"time":time("12:00:00.000Z"),"datetime":null,"ymd":null,"dtd":day-time-duration("PT1S"),"duration":null}
diff --git
a/asterixdb/asterix-column/src/test/resources/data/401-array-temporal.json
b/asterixdb/asterix-column/src/test/resources/data/401-array-temporal.json
new file mode 100644
index 0000000..5c028a9
--- /dev/null
+++ b/asterixdb/asterix-column/src/test/resources/data/401-array-temporal.json
@@ -0,0 +1,2 @@
+{"dates":[date("2024-01-02"),date("1970-01-01"),null],"times":[time("12:34:56.789Z"),time("00:00:00.000Z")],"datetimes":[datetime("2024-01-02T03:04:05.006Z"),null],"ymds":[year-month-duration("P2Y3M"),year-month-duration("P0Y0M")],"dtds":[day-time-duration("PT36H"),day-time-duration("PT0S")],"durations":[duration("P1Y2M3DT4H5M6.007S"),duration("P0D"),null]}
+{"dates":[],"times":[],"datetimes":[],"ymds":[],"dtds":[],"durations":[]}
diff --git
a/asterixdb/asterix-column/src/test/resources/data/402-union-temporal.json
b/asterixdb/asterix-column/src/test/resources/data/402-union-temporal.json
new file mode 100644
index 0000000..ce495c0
--- /dev/null
+++ b/asterixdb/asterix-column/src/test/resources/data/402-union-temporal.json
@@ -0,0 +1,6 @@
+{"t":date("2024-01-02")}
+{"t":time("12:34:56.789Z")}
+{"t":datetime("2024-01-02T03:04:05.006Z")}
+{"t":year-month-duration("P2Y3M")}
+{"t":day-time-duration("PT36H")}
+{"t":duration("P1Y2M3DT4H5M6.007S")}
diff --git
a/asterixdb/asterix-column/src/test/resources/data/403-union-temporal-nontemporal.json
b/asterixdb/asterix-column/src/test/resources/data/403-union-temporal-nontemporal.json
new file mode 100644
index 0000000..b80f926
--- /dev/null
+++
b/asterixdb/asterix-column/src/test/resources/data/403-union-temporal-nontemporal.json
@@ -0,0 +1,6 @@
+{"u":date("2024-01-02")}
+{"u":1}
+{"u":1.25}
+{"u":year-month-duration("P2Y3M")}
+{"u":true}
+{"u":null}
diff --git
a/asterixdb/asterix-column/src/test/resources/data/404-array-mixed-temporal-nontemporal.json
b/asterixdb/asterix-column/src/test/resources/data/404-array-mixed-temporal-nontemporal.json
new file mode 100644
index 0000000..af8b5e2
--- /dev/null
+++
b/asterixdb/asterix-column/src/test/resources/data/404-array-mixed-temporal-nontemporal.json
@@ -0,0 +1 @@
+{"m":[date("2024-01-02"),1,1.25,true,null,year-month-duration("P2Y3M")],"n":[1,datetime("2024-01-02T03:04:05.006Z"),null]}
diff --git a/asterixdb/asterix-column/src/test/resources/only.txt
b/asterixdb/asterix-column/src/test/resources/only.txt
index 4d5d97f..fb9460c 100644
--- a/asterixdb/asterix-column/src/test/resources/only.txt
+++ b/asterixdb/asterix-column/src/test/resources/only.txt
@@ -46,4 +46,9 @@
#325-null-array5
#326-null-array6
#327-null-array7
+#400-temporal
+#401-array-temporal
+#402-union-temporal
+#403-union-temporal-nontemporal
+#404-array-mixed-temporal-nontemporal
#900-dummy-tweet
\ No newline at end of file
diff --git
a/asterixdb/asterix-column/src/test/resources/result/assembler/400-temporal.json
b/asterixdb/asterix-column/src/test/resources/result/assembler/400-temporal.json
new file mode 100644
index 0000000..854e7b7
--- /dev/null
+++
b/asterixdb/asterix-column/src/test/resources/result/assembler/400-temporal.json
@@ -0,0 +1,4 @@
+{"date":"2024-01-02","time":"12:34:56.789","datetime":"2024-01-02T03:04:05.006","ymd":{
"year-month-duration": 27},"dtd":"P1DT12H"),"duration":"P1Y2M3DT4H5M6.7S"}
+{"date":"1970-01-01","time":"00:00:00.000","datetime":"1970-01-01T00:00:00.000","ymd":{
"year-month-duration": 0},"dtd":"P"),"duration":"P"}
+{"date":"9999-12-31","time":"23:59:59.999","datetime":"9999-12-31T23:59:59.999","ymd":{
"year-month-duration": 1451},"dtd":"P11DT13H46M39S"),"duration":"P3650D"}
+{"date":null,"time":"12:00:00.000","datetime":null,"ymd":null,"dtd":"PT1S"),"duration":null}
diff --git
a/asterixdb/asterix-column/src/test/resources/result/assembler/401-array-temporal.json
b/asterixdb/asterix-column/src/test/resources/result/assembler/401-array-temporal.json
new file mode 100644
index 0000000..b382d61
--- /dev/null
+++
b/asterixdb/asterix-column/src/test/resources/result/assembler/401-array-temporal.json
@@ -0,0 +1,2 @@
+{"dates":["2024-01-02","1970-01-01",null],"times":["12:34:56.789","00:00:00.000"],"datetimes":["2024-01-02T03:04:05.006",null],"ymds":[{
"year-month-duration": 27},{ "year-month-duration":
0}],"dtds":["P1DT12H"),"P")],"durations":["P1Y2M3DT4H5M6.7S","P",null]}
+{"dates":[],"times":[],"datetimes":[],"ymds":[],"dtds":[],"durations":[]}
diff --git
a/asterixdb/asterix-column/src/test/resources/result/assembler/402-union-temporal.json
b/asterixdb/asterix-column/src/test/resources/result/assembler/402-union-temporal.json
new file mode 100644
index 0000000..e871c7a
--- /dev/null
+++
b/asterixdb/asterix-column/src/test/resources/result/assembler/402-union-temporal.json
@@ -0,0 +1,6 @@
+{"t":"2024-01-02"}
+{"t":"12:34:56.789"}
+{"t":"2024-01-02T03:04:05.006"}
+{"t":{ "year-month-duration": 27}}
+{"t":"P1DT12H")}
+{"t":"P1Y2M3DT4H5M6.7S"}
diff --git
a/asterixdb/asterix-column/src/test/resources/result/assembler/403-union-temporal-nontemporal.json
b/asterixdb/asterix-column/src/test/resources/result/assembler/403-union-temporal-nontemporal.json
new file mode 100644
index 0000000..a1b5960
--- /dev/null
+++
b/asterixdb/asterix-column/src/test/resources/result/assembler/403-union-temporal-nontemporal.json
@@ -0,0 +1,6 @@
+{"u":"2024-01-02"}
+{"u":1}
+{"u":1.25}
+{"u":{ "year-month-duration": 27}}
+{"u":true}
+{"u":null}
diff --git
a/asterixdb/asterix-column/src/test/resources/result/assembler/404-array-mixed-temporal-nontemporal.json
b/asterixdb/asterix-column/src/test/resources/result/assembler/404-array-mixed-temporal-nontemporal.json
new file mode 100644
index 0000000..9c6b1d9
--- /dev/null
+++
b/asterixdb/asterix-column/src/test/resources/result/assembler/404-array-mixed-temporal-nontemporal.json
@@ -0,0 +1 @@
+{"m":["2024-01-02",1,1.25,true,null,{ "year-month-duration":
27}],"n":[1,"2024-01-02T03:04:05.006",null]}
diff --git
a/asterixdb/asterix-column/src/test/resources/result/small/400-temporal.json
b/asterixdb/asterix-column/src/test/resources/result/small/400-temporal.json
new file mode 100644
index 0000000..854e7b7
--- /dev/null
+++ b/asterixdb/asterix-column/src/test/resources/result/small/400-temporal.json
@@ -0,0 +1,4 @@
+{"date":"2024-01-02","time":"12:34:56.789","datetime":"2024-01-02T03:04:05.006","ymd":{
"year-month-duration": 27},"dtd":"P1DT12H"),"duration":"P1Y2M3DT4H5M6.7S"}
+{"date":"1970-01-01","time":"00:00:00.000","datetime":"1970-01-01T00:00:00.000","ymd":{
"year-month-duration": 0},"dtd":"P"),"duration":"P"}
+{"date":"9999-12-31","time":"23:59:59.999","datetime":"9999-12-31T23:59:59.999","ymd":{
"year-month-duration": 1451},"dtd":"P11DT13H46M39S"),"duration":"P3650D"}
+{"date":null,"time":"12:00:00.000","datetime":null,"ymd":null,"dtd":"PT1S"),"duration":null}
diff --git
a/asterixdb/asterix-column/src/test/resources/result/small/401-array-temporal.json
b/asterixdb/asterix-column/src/test/resources/result/small/401-array-temporal.json
new file mode 100644
index 0000000..b382d61
--- /dev/null
+++
b/asterixdb/asterix-column/src/test/resources/result/small/401-array-temporal.json
@@ -0,0 +1,2 @@
+{"dates":["2024-01-02","1970-01-01",null],"times":["12:34:56.789","00:00:00.000"],"datetimes":["2024-01-02T03:04:05.006",null],"ymds":[{
"year-month-duration": 27},{ "year-month-duration":
0}],"dtds":["P1DT12H"),"P")],"durations":["P1Y2M3DT4H5M6.7S","P",null]}
+{"dates":[],"times":[],"datetimes":[],"ymds":[],"dtds":[],"durations":[]}
diff --git
a/asterixdb/asterix-column/src/test/resources/result/small/402-union-temporal.json
b/asterixdb/asterix-column/src/test/resources/result/small/402-union-temporal.json
new file mode 100644
index 0000000..e871c7a
--- /dev/null
+++
b/asterixdb/asterix-column/src/test/resources/result/small/402-union-temporal.json
@@ -0,0 +1,6 @@
+{"t":"2024-01-02"}
+{"t":"12:34:56.789"}
+{"t":"2024-01-02T03:04:05.006"}
+{"t":{ "year-month-duration": 27}}
+{"t":"P1DT12H")}
+{"t":"P1Y2M3DT4H5M6.7S"}
diff --git
a/asterixdb/asterix-column/src/test/resources/result/small/403-union-temporal-nontemporal.json
b/asterixdb/asterix-column/src/test/resources/result/small/403-union-temporal-nontemporal.json
new file mode 100644
index 0000000..a1b5960
--- /dev/null
+++
b/asterixdb/asterix-column/src/test/resources/result/small/403-union-temporal-nontemporal.json
@@ -0,0 +1,6 @@
+{"u":"2024-01-02"}
+{"u":1}
+{"u":1.25}
+{"u":{ "year-month-duration": 27}}
+{"u":true}
+{"u":null}
diff --git
a/asterixdb/asterix-column/src/test/resources/result/small/404-array-mixed-temporal-nontemporal.json
b/asterixdb/asterix-column/src/test/resources/result/small/404-array-mixed-temporal-nontemporal.json
new file mode 100644
index 0000000..9c6b1d9
--- /dev/null
+++
b/asterixdb/asterix-column/src/test/resources/result/small/404-array-mixed-temporal-nontemporal.json
@@ -0,0 +1 @@
+{"m":["2024-01-02",1,1.25,true,null,{ "year-month-duration":
27}],"n":[1,"2024-01-02T03:04:05.006",null]}
diff --git
a/asterixdb/asterix-column/src/test/resources/result/transformer/400-temporal.schema
b/asterixdb/asterix-column/src/test/resources/result/transformer/400-temporal.schema
new file mode 100644
index 0000000..909c101
--- /dev/null
+++
b/asterixdb/asterix-column/src/test/resources/result/transformer/400-temporal.schema
@@ -0,0 +1,13 @@
+root
+|-- date: date <level: 1, index: 0>
+| |-- Def size: 4 [(1,3),(2,1)]
+|-- time: time <level: 1, index: 1>
+| |-- Def size: 4 [(1,4)]
+|-- datetime: datetime <level: 1, index: 2>
+| |-- Def size: 4 [(1,3),(2,1)]
+|-- ymd: yearmonthduration <level: 1, index: 3>
+| |-- Def size: 4 [(1,3),(2,1)]
+|-- dtd: daytimeduration <level: 1, index: 4>
+| |-- Def size: 4 [(1,4)]
+|-- duration: duration <level: 1, index: 5>
+| |-- Def size: 4 [(1,3),(2,1)]
diff --git
a/asterixdb/asterix-column/src/test/resources/result/transformer/401-array-temporal.schema
b/asterixdb/asterix-column/src/test/resources/result/transformer/401-array-temporal.schema
new file mode 100644
index 0000000..99c576e
--- /dev/null
+++
b/asterixdb/asterix-column/src/test/resources/result/transformer/401-array-temporal.schema
@@ -0,0 +1,19 @@
+root
+|-- dates: array <level: 1>
+| |-- item: date <level: 2, index: 0>
+| | |-- Def size: 7 [(2,2),(5,1),(1,1),(0,1),(1,1),(0,1)]
+|-- times: array <level: 1>
+| |-- item: time <level: 2, index: 1>
+| | |-- Def size: 6 [(2,2),(1,1),(0,1),(1,1),(0,1)]
+|-- datetimes: array <level: 1>
+| |-- item: datetime <level: 2, index: 2>
+| | |-- Def size: 6 [(2,1),(5,1),(1,1),(0,1),(1,1),(0,1)]
+|-- ymds: array <level: 1>
+| |-- item: yearmonthduration <level: 2, index: 3>
+| | |-- Def size: 6 [(2,2),(1,1),(0,1),(1,1),(0,1)]
+|-- dtds: array <level: 1>
+| |-- item: daytimeduration <level: 2, index: 4>
+| | |-- Def size: 6 [(2,2),(1,1),(0,1),(1,1),(0,1)]
+|-- durations: array <level: 1>
+| |-- item: duration <level: 2, index: 5>
+| | |-- Def size: 7 [(2,2),(5,1),(1,1),(0,1),(1,1),(0,1)]
diff --git
a/asterixdb/asterix-column/src/test/resources/result/transformer/402-union-temporal.schema
b/asterixdb/asterix-column/src/test/resources/result/transformer/402-union-temporal.schema
new file mode 100644
index 0000000..ce43c50
--- /dev/null
+++
b/asterixdb/asterix-column/src/test/resources/result/transformer/402-union-temporal.schema
@@ -0,0 +1,14 @@
+root
+|-- t: union <level: 1>
+| |-- datetime: datetime <level: 1, index: 2>
+| | |-- Def size: 6 [(0,2),(1,1),(0,3)]
+| |-- date: date <level: 1, index: 0>
+| | |-- Def size: 6 [(1,1),(0,5)]
+| |-- time: time <level: 1, index: 1>
+| | |-- Def size: 6 [(0,1),(1,1),(0,4)]
+| |-- duration: duration <level: 1, index: 5>
+| | |-- Def size: 6 [(0,5),(1,1)]
+| |-- yearmonthduration: yearmonthduration <level: 1, index: 3>
+| | |-- Def size: 6 [(0,3),(1,1),(0,2)]
+| |-- daytimeduration: daytimeduration <level: 1, index: 4>
+| | |-- Def size: 6 [(0,4),(1,1),(0,1)]
diff --git
a/asterixdb/asterix-column/src/test/resources/result/transformer/403-union-temporal-nontemporal.schema
b/asterixdb/asterix-column/src/test/resources/result/transformer/403-union-temporal-nontemporal.schema
new file mode 100644
index 0000000..23a997f
--- /dev/null
+++
b/asterixdb/asterix-column/src/test/resources/result/transformer/403-union-temporal-nontemporal.schema
@@ -0,0 +1,12 @@
+root
+|-- u: union <level: 1>
+| |-- bigint: bigint <level: 1, index: 1>
+| | |-- Def size: 6 [(0,1),(1,1),(0,4)]
+| |-- double: double <level: 1, index: 2>
+| | |-- Def size: 6 [(0,2),(1,1),(0,3)]
+| |-- boolean: boolean <level: 1, index: 4>
+| | |-- Def size: 6 [(0,4),(1,1),(0,1)]
+| |-- date: date <level: 1, index: 0>
+| | |-- Def size: 6 [(1,1),(0,4),(2,1)]
+| |-- yearmonthduration: yearmonthduration <level: 1, index: 3>
+| | |-- Def size: 6 [(0,3),(1,1),(0,2)]
diff --git
a/asterixdb/asterix-column/src/test/resources/result/transformer/404-array-mixed-temporal-nontemporal.schema
b/asterixdb/asterix-column/src/test/resources/result/transformer/404-array-mixed-temporal-nontemporal.schema
new file mode 100644
index 0000000..ddd5ad2
--- /dev/null
+++
b/asterixdb/asterix-column/src/test/resources/result/transformer/404-array-mixed-temporal-nontemporal.schema
@@ -0,0 +1,19 @@
+root
+|-- m: array <level: 1>
+| |-- item: union <level: 2>
+| | |-- bigint: bigint <level: 2, index: 1>
+| | | |-- Def size: 8 [(1,1),(2,1),(1,5),(0,1)]
+| | |-- double: double <level: 2, index: 2>
+| | | |-- Def size: 8 [(1,2),(2,1),(1,4),(0,1)]
+| | |-- boolean: boolean <level: 2, index: 3>
+| | | |-- Def size: 8 [(1,3),(2,1),(1,3),(0,1)]
+| | |-- date: date <level: 2, index: 0>
+| | | |-- Def size: 8 [(2,1),(1,3),(5,1),(1,2),(0,1)]
+| | |-- yearmonthduration: yearmonthduration <level: 2, index: 4>
+| | | |-- Def size: 8 [(1,5),(2,1),(1,1),(0,1)]
+|-- n: array <level: 1>
+| |-- item: union <level: 2>
+| | |-- bigint: bigint <level: 2, index: 5>
+| | | |-- Def size: 5 [(2,1),(1,1),(5,1),(1,1),(0,1)]
+| | |-- datetime: datetime <level: 2, index: 6>
+| | | |-- Def size: 5 [(1,1),(2,1),(1,2),(0,1)]
--
To view, visit https://asterix-gerrit.ics.uci.edu/c/asterixdb/+/20792?usp=email
To unsubscribe, or for help writing mail filters, visit
https://asterix-gerrit.ics.uci.edu/settings?usp=email
Gerrit-MessageType: newchange
Gerrit-Project: asterixdb
Gerrit-Branch: master
Gerrit-Change-Id: I35231099dc48077f61a5cff32c58232461edf82e
Gerrit-Change-Number: 20792
Gerrit-PatchSet: 1
Gerrit-Owner: Ritik Raj <[email protected]>