From 71ecfdee2d46c6a55174c5644fb8757f964816fe Mon Sep 17 00:00:00 2001 From: Daniel Henneberger Date: Fri, 8 Nov 2024 15:01:27 -0800 Subject: [PATCH] Avro array datatype support Signed-off-by: Daniel Henneberger --- .../dialect/ExtendedPostgresSqlDialect.java | 2 +- .../jdbc/SqrlBaseJdbcRowConverter.java | 21 -- .../SqrlFieldNamedPreparedStatementImpl.java | 252 ------------------ .../jdbc/SqrlPostgresRowConverter.java | 13 - .../jdbc/PostgresRowConverterTest.java | 152 ----------- .../jdbc/FlinkPostgresDataTypeMapper.java | 2 +- .../jdbc/FlinkSqrlPostgresDataTypeMapper.java | 5 +- .../graphql/inference/SchemaWalker.java | 40 ++- .../avro-schema_avro-schema.txt | 2 +- .../avro-schema--package.txt | 18 +- .../avro-schema/avro-schema/schema.avsc | 49 ++-- .../snapshots-avro-schema/MySchema.snapshot | 2 +- .../MySchemaQuery.snapshot | 2 +- .../tests-avro-schema/MySchemaQuery.graphql | 8 +- 14 files changed, 82 insertions(+), 486 deletions(-) delete mode 100644 sqrl-flink-lib/sqrl-jdbc-1.19/src/main/java/com/datasqrl/jdbc/SqrlFieldNamedPreparedStatementImpl.java delete mode 100644 sqrl-flink-lib/sqrl-jdbc-1.19/src/test/java/com/datasqrl/jdbc/PostgresRowConverterTest.java diff --git a/sqrl-calcite/src/main/java/com/datasqrl/calcite/dialect/ExtendedPostgresSqlDialect.java b/sqrl-calcite/src/main/java/com/datasqrl/calcite/dialect/ExtendedPostgresSqlDialect.java index f35c0753f..378a802f2 100644 --- a/sqrl-calcite/src/main/java/com/datasqrl/calcite/dialect/ExtendedPostgresSqlDialect.java +++ b/sqrl-calcite/src/main/java/com/datasqrl/calcite/dialect/ExtendedPostgresSqlDialect.java @@ -99,7 +99,7 @@ public SqlDataTypeSpec getCastSpec(RelDataType type) { castSpec = "TIMESTAMP WITH TIME ZONE"; break; case ARRAY: - castSpec = getCastSpec(type.getComponentType()) + "[]"; + castSpec = "jsonb"; break; case BINARY: case VARBINARY: diff --git a/sqrl-flink-lib/sqrl-jdbc-1.19/src/main/java/com/datasqrl/jdbc/SqrlBaseJdbcRowConverter.java b/sqrl-flink-lib/sqrl-jdbc-1.19/src/main/java/com/datasqrl/jdbc/SqrlBaseJdbcRowConverter.java index d3d896d49..a3e9c244f 100644 --- a/sqrl-flink-lib/sqrl-jdbc-1.19/src/main/java/com/datasqrl/jdbc/SqrlBaseJdbcRowConverter.java +++ b/sqrl-flink-lib/sqrl-jdbc-1.19/src/main/java/com/datasqrl/jdbc/SqrlBaseJdbcRowConverter.java @@ -50,10 +50,6 @@ protected JdbcSerializationConverter wrapIntoNullableExternalConverter( jdbcSerializationConverter.serialize(val, index, statement); } }; - } else if (type.getTypeRoot() == ROW) { - return (val, index, statement) -> setRow(type, val, index, statement); - } else if (type.getTypeRoot() == MAP) { - return (val, index, statement) -> setRow(type, val, index, statement); } return super.wrapIntoNullableExternalConverter(jdbcSerializationConverter, type); } @@ -87,12 +83,6 @@ protected JdbcSerializationConverter createExternalConverter(LogicalType type) { return (val, index, statement) -> statement.setTimestamp( index, val.getTimestamp(index, tsPrecision).toTimestamp()); - case ARRAY: - return (val, index, statement) -> setArray(type, val, index, statement); - case ROW: - return (val, index, statement) -> setRow(type, val, index, statement); - case MAP: - return (val, index, statement) -> setRow(type, val, index, statement); case MULTISET: case RAW: default: @@ -100,17 +90,6 @@ protected JdbcSerializationConverter createExternalConverter(LogicalType type) { } } - public abstract void setRow(LogicalType type, RowData val, int index, - FieldNamedPreparedStatement statement); - @SneakyThrows - public void setArray(LogicalType type, RowData val, int index, FieldNamedPreparedStatement statement) { - SqrlFieldNamedPreparedStatementImpl flinkPreparedStatement = (SqrlFieldNamedPreparedStatementImpl) statement; - for (int idx : flinkPreparedStatement.getIndexMapping()[index]) { - ArrayData arrayData = val.getArray(index); - createSqlArrayObject(type, arrayData, idx, flinkPreparedStatement.getStatement()); - } - } - @SneakyThrows private void createSqlArrayObject(LogicalType type, ArrayData data, int idx, PreparedStatement statement) { diff --git a/sqrl-flink-lib/sqrl-jdbc-1.19/src/main/java/com/datasqrl/jdbc/SqrlFieldNamedPreparedStatementImpl.java b/sqrl-flink-lib/sqrl-jdbc-1.19/src/main/java/com/datasqrl/jdbc/SqrlFieldNamedPreparedStatementImpl.java deleted file mode 100644 index 8e9f02c6e..000000000 --- a/sqrl-flink-lib/sqrl-jdbc-1.19/src/main/java/com/datasqrl/jdbc/SqrlFieldNamedPreparedStatementImpl.java +++ /dev/null @@ -1,252 +0,0 @@ -/* - * 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 com.datasqrl.jdbc; - -import java.math.BigDecimal; -import java.sql.Connection; -import java.sql.Date; -import java.sql.PreparedStatement; -import java.sql.ResultSet; -import java.sql.SQLException; -import java.sql.Time; -import java.sql.Timestamp; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import org.apache.flink.connector.jdbc.statement.FieldNamedPreparedStatement; - -import static org.apache.flink.util.Preconditions.checkArgument; -import static org.apache.flink.util.Preconditions.checkNotNull; -/** - * SQRL: added getStatement - */ - -/** Simple implementation of {@link FieldNamedPreparedStatement}. */ -public class SqrlFieldNamedPreparedStatementImpl implements FieldNamedPreparedStatement { - - private final PreparedStatement statement; - private final int[][] indexMapping; - - private SqrlFieldNamedPreparedStatementImpl(PreparedStatement statement, int[][] indexMapping) { - this.statement = statement; - this.indexMapping = indexMapping; - } - - public PreparedStatement getStatement() { - return statement; - } - - public int[][] getIndexMapping() { - return indexMapping; - } - - @Override - public void clearParameters() throws SQLException { - statement.clearParameters(); - } - - @Override - public ResultSet executeQuery() throws SQLException { - return statement.executeQuery(); - } - - @Override - public void addBatch() throws SQLException { - statement.addBatch(); - } - - @Override - public int[] executeBatch() throws SQLException { - return statement.executeBatch(); - } - - @Override - public void setNull(int fieldIndex, int sqlType) throws SQLException { - for (int index : indexMapping[fieldIndex]) { - statement.setNull(index, sqlType); - } - } - - @Override - public void setBoolean(int fieldIndex, boolean x) throws SQLException { - for (int index : indexMapping[fieldIndex]) { - statement.setBoolean(index, x); - } - } - - @Override - public void setByte(int fieldIndex, byte x) throws SQLException { - for (int index : indexMapping[fieldIndex]) { - statement.setByte(index, x); - } - } - - @Override - public void setShort(int fieldIndex, short x) throws SQLException { - for (int index : indexMapping[fieldIndex]) { - statement.setShort(index, x); - } - } - - @Override - public void setInt(int fieldIndex, int x) throws SQLException { - for (int index : indexMapping[fieldIndex]) { - statement.setInt(index, x); - } - } - - @Override - public void setLong(int fieldIndex, long x) throws SQLException { - for (int index : indexMapping[fieldIndex]) { - statement.setLong(index, x); - } - } - - @Override - public void setFloat(int fieldIndex, float x) throws SQLException { - for (int index : indexMapping[fieldIndex]) { - statement.setFloat(index, x); - } - } - - @Override - public void setDouble(int fieldIndex, double x) throws SQLException { - for (int index : indexMapping[fieldIndex]) { - statement.setDouble(index, x); - } - } - - @Override - public void setBigDecimal(int fieldIndex, BigDecimal x) throws SQLException { - for (int index : indexMapping[fieldIndex]) { - statement.setBigDecimal(index, x); - } - } - - @Override - public void setString(int fieldIndex, String x) throws SQLException { - for (int index : indexMapping[fieldIndex]) { - statement.setString(index, x); - } - } - - @Override - public void setBytes(int fieldIndex, byte[] x) throws SQLException { - for (int index : indexMapping[fieldIndex]) { - statement.setBytes(index, x); - } - } - - @Override - public void setDate(int fieldIndex, Date x) throws SQLException { - for (int index : indexMapping[fieldIndex]) { - statement.setDate(index, x); - } - } - - @Override - public void setTime(int fieldIndex, Time x) throws SQLException { - for (int index : indexMapping[fieldIndex]) { - statement.setTime(index, x); - } - } - - @Override - public void setTimestamp(int fieldIndex, Timestamp x) throws SQLException { - for (int index : indexMapping[fieldIndex]) { - statement.setTimestamp(index, x); - } - } - - @Override - public void setObject(int fieldIndex, Object x) throws SQLException { - for (int index : indexMapping[fieldIndex]) { - statement.setObject(index, x); - } - } - - @Override - public void close() throws SQLException { - statement.close(); - } - - // ---------------------------------------------------------------------------------------- - - public static FieldNamedPreparedStatement prepareStatement( - Connection connection, String sql, String[] fieldNames) throws SQLException { - checkNotNull(connection, "connection must not be null."); - checkNotNull(sql, "sql must not be null."); - checkNotNull(fieldNames, "fieldNames must not be null."); - - if (sql.contains("?")) { - throw new IllegalArgumentException("SQL statement must not contain ? character."); - } - - HashMap> parameterMap = new HashMap<>(); - String parsedSQL = parseNamedStatement(sql, parameterMap); - // currently, the statements must contain all the field parameters - checkArgument(parameterMap.size() == fieldNames.length); - int[][] indexMapping = new int[fieldNames.length][]; - for (int i = 0; i < fieldNames.length; i++) { - String fieldName = fieldNames[i]; - checkArgument( - parameterMap.containsKey(fieldName), - fieldName + " doesn't exist in the parameters of SQL statement: " + sql); - indexMapping[i] = parameterMap.get(fieldName).stream().mapToInt(v -> v).toArray(); - } - - return new SqrlFieldNamedPreparedStatementImpl( - connection.prepareStatement(parsedSQL), indexMapping); - } - - /** - * Parses a sql with named parameters. The parameter-index mappings are put into the map, and - * the parsed sql is returned. - * - * @param sql sql to parse - * @param paramMap map to hold parameter-index mappings - * @return the parsed sql - */ - public static String parseNamedStatement(String sql, Map> paramMap) { - StringBuilder parsedSql = new StringBuilder(); - int fieldIndex = 1; // SQL statement parameter index starts from 1 - int length = sql.length(); - for (int i = 0; i < length; i++) { - char c = sql.charAt(i); - if (':' == c) { - int j = i + 1; - while (j < length && Character.isJavaIdentifierPart(sql.charAt(j))) { - j++; - } - String parameterName = sql.substring(i + 1, j); - checkArgument( - !parameterName.isEmpty(), - "Named parameters in SQL statement must not be empty."); - paramMap.computeIfAbsent(parameterName, n -> new ArrayList<>()).add(fieldIndex); - fieldIndex++; - i = j - 1; - parsedSql.append('?'); - } else { - parsedSql.append(c); - } - } - return parsedSql.toString(); - } -} diff --git a/sqrl-flink-lib/sqrl-jdbc-1.19/src/main/java/com/datasqrl/jdbc/SqrlPostgresRowConverter.java b/sqrl-flink-lib/sqrl-jdbc-1.19/src/main/java/com/datasqrl/jdbc/SqrlPostgresRowConverter.java index 7d74cb463..b3894aad6 100644 --- a/sqrl-flink-lib/sqrl-jdbc-1.19/src/main/java/com/datasqrl/jdbc/SqrlPostgresRowConverter.java +++ b/sqrl-flink-lib/sqrl-jdbc-1.19/src/main/java/com/datasqrl/jdbc/SqrlPostgresRowConverter.java @@ -63,19 +63,6 @@ public SqrlPostgresRowConverter(RowType rowType) { super(rowType); } - @SneakyThrows - public void setRow(LogicalType type, RowData val, int index, - FieldNamedPreparedStatement statement) { - SqrlFieldNamedPreparedStatementImpl flinkPreparedStatement = (SqrlFieldNamedPreparedStatementImpl) statement; - for (int idx : flinkPreparedStatement.getIndexMapping()[index]) { -// RowData row = val.getRow(index, ((RowType) type).getFieldCount()); -// java.sql.Array sqlArray = flinkPreparedStatement.getStatement() -// .getConnection().createArrayOf("bytea", ); - flinkPreparedStatement.getStatement().setBytes(idx, new byte[0]); - } - } - - @Override public JdbcDeserializationConverter createInternalConverter(LogicalType type) { if (sqrlSerializers.containsKey(type.getDefaultConversion())) { diff --git a/sqrl-flink-lib/sqrl-jdbc-1.19/src/test/java/com/datasqrl/jdbc/PostgresRowConverterTest.java b/sqrl-flink-lib/sqrl-jdbc-1.19/src/test/java/com/datasqrl/jdbc/PostgresRowConverterTest.java deleted file mode 100644 index 7a665a232..000000000 --- a/sqrl-flink-lib/sqrl-jdbc-1.19/src/test/java/com/datasqrl/jdbc/PostgresRowConverterTest.java +++ /dev/null @@ -1,152 +0,0 @@ -package com.datasqrl.jdbc; - -import static org.junit.jupiter.api.Assertions.assertArrayEquals; -import static org.junit.jupiter.api.Assertions.assertEquals; -import static org.junit.jupiter.api.Assertions.assertNotNull; -import static org.junit.jupiter.api.Assertions.assertTrue; - -import java.sql.Array; -import java.sql.Connection; -import java.sql.ResultSet; -import java.sql.Statement; -import java.util.Arrays; -import java.util.List; -import org.apache.flink.connector.jdbc.converter.AbstractJdbcRowConverter.JdbcSerializationConverter; -import org.apache.flink.connector.jdbc.statement.FieldNamedPreparedStatement; -import org.apache.flink.table.data.GenericArrayData; -import org.apache.flink.table.data.GenericRowData; -import org.apache.flink.table.data.TimestampData; -import org.apache.flink.table.data.binary.BinaryArrayData; -import org.apache.flink.table.data.writer.BinaryArrayWriter; -import org.apache.flink.table.types.logical.ArrayType; -import org.apache.flink.table.types.logical.DoubleType; -import org.apache.flink.table.types.logical.IntType; -import org.apache.flink.table.types.logical.LocalZonedTimestampType; -import org.apache.flink.table.types.logical.RowType; -import org.apache.flink.table.types.logical.TimestampType; -import org.apache.flink.table.types.logical.VarCharType; -import org.junit.jupiter.api.AfterAll; -import org.junit.jupiter.api.BeforeAll; -import org.junit.jupiter.api.Test; -import org.testcontainers.containers.PostgreSQLContainer; - -class PostgresRowConverterTest { - private static final PostgreSQLContainer postgres = new PostgreSQLContainer("postgres:15.4"); - - @BeforeAll - public static void setUp() { - postgres.start(); - } - - @AfterAll - public static void tearDown() { - postgres.stop(); - } - - private ArrayType doubleArrayType = new ArrayType(new DoubleType()); - private ArrayType timestampArrayType = new ArrayType(new LocalZonedTimestampType()); - private ArrayType doubleArray2DType = new ArrayType(doubleArrayType); - private RowType sampleRowType = RowType.of(new IntType(), new VarCharType()); - - private void executeUpdate(Connection connection, String query) throws Exception { - try (Statement stmt = connection.createStatement()) { - stmt.executeUpdate(query); - } - } - - @Test - public void testArraySerializationAndDeserialization() throws Exception { - try (Connection connection = postgres.createConnection("")) { - executeUpdate(connection, "CREATE TABLE test (id int, int_data int[], double_data double precision[], ts_data timestamptz[], double_data_2d double precision[][], row_data bytea)"); - - // Set up the converter - RowType rowType = RowType.of(new IntType(), new ArrayType(new IntType()), doubleArrayType, timestampArrayType, doubleArray2DType, sampleRowType); - SqrlPostgresRowConverter converter = new SqrlPostgresRowConverter(rowType); - - // Sample data - GenericRowData rowData = new GenericRowData(6); - rowData.setField(0, 1); - - // Integer Array - GenericArrayData - GenericArrayData intArray = new GenericArrayData(new int[]{1, 2, 3}); - rowData.setField(1, intArray); - - // Double Array - GenericArrayData - GenericArrayData doubleArray = new GenericArrayData(new double[]{1.1, 2.2, 3.3}); - rowData.setField(2, doubleArray); - - // Timestamp Array - GenericArrayData - BinaryArrayData array = new BinaryArrayData(); - BinaryArrayWriter writer = new BinaryArrayWriter(array, 2, 8); - final int precision = 3; - writer.reset(); - writer.writeTimestamp(0, TimestampData.fromEpochMillis(123000L), precision); - writer.writeTimestamp(1, TimestampData.fromEpochMillis(123000L), precision); - writer.complete(); - rowData.setField(3, array); - - // 2D Double Array - GenericArrayData - GenericArrayData doubleArray2d = new GenericArrayData(new double[][]{{1.1, 2.2}, {3.3, 4.4}}); - rowData.setField(4, doubleArray2d); - - // RowType not being an array - GenericRowData sampleRow = new GenericRowData(2); - sampleRow.setField(0, 10); - sampleRow.setField(1, "test"); - rowData.setField(5, sampleRow); - - FieldNamedPreparedStatement statement = - SqrlFieldNamedPreparedStatementImpl.prepareStatement(connection, - "INSERT INTO test (id, int_data, double_data, ts_data, double_data_2d, row_data) VALUES (:id, :int_data, :double_data, :ts_data, :double_data_2d, :row_data)", - List.of("id", "int_data", "double_data", "ts_data", "double_data_2d", "row_data").toArray(String[]::new)); - - for (int i = 0; i < rowType.getFieldCount(); i++) { - JdbcSerializationConverter externalConverter = - converter.createExternalConverter(rowType.getTypeAt(i)); - externalConverter.serialize(rowData, i, statement); - } - statement.addBatch(); - - int[] result = statement.executeBatch(); - assertEquals(1, result.length); - - Statement stmt = connection.createStatement(); - // Deserialize - ResultSet rs = stmt.executeQuery("SELECT int_data, double_data, ts_data, double_data_2d, row_data FROM test WHERE id=1"); - assertTrue(rs.next()); - - // Assert Integer Array - Array intArrayRetrieved = rs.getArray("int_data"); - Object intDataDeserialized = converter.createArrayConverter(new ArrayType(new IntType())) - .deserialize(intArrayRetrieved); - assertArrayEquals(((GenericArrayData)rowData.getField(1)).toIntArray(), - ((GenericArrayData)intDataDeserialized).toIntArray()); - - // Assert Double Array - Array doubleArrayRetrieved = rs.getArray("double_data"); - Object doubleDataDeserialized = converter.createArrayConverter(doubleArrayType) - .deserialize(doubleArrayRetrieved); - assertArrayEquals(((GenericArrayData)rowData.getField(2)).toDoubleArray(), - ((GenericArrayData)doubleDataDeserialized).toDoubleArray()); - - // Assert Timestamp Array - Array timestampArrayRetrieved = rs.getArray("ts_data"); - Object timestampDataDeserialized = converter.createArrayConverter(timestampArrayType) - .deserialize(timestampArrayRetrieved); - assertArrayEquals(((GenericArrayData) timestampDataDeserialized).toObjectArray(), - Arrays.stream(((BinaryArrayData) rowData.getField(3)).toObjectArray(new TimestampType())).toArray() - ); - // Assert 2D Double Array (it's a bit tricky given the 2D nature) - Array double2DArrayRetrieved = rs.getArray("double_data_2d"); - Object double2DDataDeserialized = converter.createArrayConverter(doubleArray2DType) - .deserialize(double2DArrayRetrieved); - //todo: 2d arrays are not well supported - GenericArrayData field = (GenericArrayData) rowData.getField(4); - assertNotNull(field); - - //todo: Row type not well supported - Object rowRetrieved = rs.getObject("row_data"); - assertNotNull(rowRetrieved); - } - } -} \ No newline at end of file diff --git a/sqrl-planner/src/main/java/com/datasqrl/datatype/flink/jdbc/FlinkPostgresDataTypeMapper.java b/sqrl-planner/src/main/java/com/datasqrl/datatype/flink/jdbc/FlinkPostgresDataTypeMapper.java index c18dde952..a6594fb08 100644 --- a/sqrl-planner/src/main/java/com/datasqrl/datatype/flink/jdbc/FlinkPostgresDataTypeMapper.java +++ b/sqrl-planner/src/main/java/com/datasqrl/datatype/flink/jdbc/FlinkPostgresDataTypeMapper.java @@ -66,7 +66,7 @@ public boolean nativeTypeSupport(RelDataType type) { case VARBINARY: return true; case ARRAY: - return nativeTypeSupport(type.getComponentType()); + return false; case MAP: return false; case ROW: diff --git a/sqrl-planner/src/main/java/com/datasqrl/datatype/flink/jdbc/FlinkSqrlPostgresDataTypeMapper.java b/sqrl-planner/src/main/java/com/datasqrl/datatype/flink/jdbc/FlinkSqrlPostgresDataTypeMapper.java index 2ef24158d..50bf056ef 100644 --- a/sqrl-planner/src/main/java/com/datasqrl/datatype/flink/jdbc/FlinkSqrlPostgresDataTypeMapper.java +++ b/sqrl-planner/src/main/java/com/datasqrl/datatype/flink/jdbc/FlinkSqrlPostgresDataTypeMapper.java @@ -74,7 +74,7 @@ public boolean nativeTypeSupport(RelDataType type) { } return false; case ARRAY: - return nativeTypeSupport(type.getComponentType()); + return false; case MAP: return false; case ROW: @@ -85,8 +85,7 @@ public boolean nativeTypeSupport(RelDataType type) { @Override public Optional convertType(RelDataType type) { - if (type.getSqlTypeName() == SqlTypeName.ROW || - (type.getSqlTypeName() == SqlTypeName.ARRAY && type.getComponentType().getSqlTypeName() == SqlTypeName.ROW)) { + if (type.getSqlTypeName() == SqlTypeName.ROW || type.getSqlTypeName() == SqlTypeName.ARRAY) { return Optional.of(new CastFunction(ToJson.class.getName(), convert(new ToJson()))); } // diff --git a/sqrl-planner/src/main/java/com/datasqrl/graphql/inference/SchemaWalker.java b/sqrl-planner/src/main/java/com/datasqrl/graphql/inference/SchemaWalker.java index 3dcf4b0e4..1a53a0645 100644 --- a/sqrl-planner/src/main/java/com/datasqrl/graphql/inference/SchemaWalker.java +++ b/sqrl-planner/src/main/java/com/datasqrl/graphql/inference/SchemaWalker.java @@ -11,7 +11,10 @@ import com.datasqrl.graphql.APIConnectorManager; import com.datasqrl.plan.queries.APISource; import graphql.language.FieldDefinition; +import graphql.language.ListType; +import graphql.language.NonNullType; import graphql.language.ObjectTypeDefinition; +import graphql.language.Type; import graphql.language.TypeDefinition; import graphql.schema.idl.SchemaParser; import graphql.schema.idl.TypeDefinitionRegistry; @@ -110,8 +113,33 @@ private void walk(ObjectTypeDefinition type, FieldDefinition field, NamePath pat walk(type1, path, Optional.of(relRecordType), registry); return; } else if (relDataTypeField.getType().getComponentType() != null) { - //array todo - throw new RuntimeException(); + RelDataType componentType = relDataTypeField.getType().getComponentType(); + + // Unwrap the field's type to get the element type + Type fieldType = field.getType(); + fieldType = unwrapNonNullType(fieldType); + + if (fieldType instanceof ListType) { + Type elementType = ((ListType) fieldType).getType(); + elementType = unwrapNonNullType(elementType); + + if (componentType instanceof RelRecordType) { + // The array contains records + ObjectTypeDefinition type1 = registry.getType(elementType) + .filter(f -> f instanceof ObjectTypeDefinition) + .map(f -> (ObjectTypeDefinition) f) + .orElseThrow(); // Ensure it is an object type + + RelRecordType relRecordType = (RelRecordType) componentType; + walk(type1, path, Optional.of(relRecordType), registry); + } else { + // The array contains scalar types + visitScalar(type, field, path, rel.get(), relDataTypeField); + } + } else { + throw new RuntimeException("Expected ListType for array field"); + } + return; } visitScalar(type, field, path, rel.get(), relDataTypeField); @@ -123,7 +151,13 @@ private void walk(ObjectTypeDefinition type, FieldDefinition field, NamePath pat //Is not a scalar or a table function, do nothing } - + private Type unwrapNonNullType(Type type) { + if (type instanceof NonNullType) { + return unwrapNonNullType(((NonNullType) type).getType()); + } else { + return type; + } + } protected abstract void visitUnknownObject(ObjectTypeDefinition type, FieldDefinition field, NamePath path, Optional rel); diff --git a/sqrl-testing/sqrl-integration-tests/src/test/resources/snapshots/com/datasqrl/FullUsecasesIT/avro-schema_avro-schema.txt b/sqrl-testing/sqrl-integration-tests/src/test/resources/snapshots/com/datasqrl/FullUsecasesIT/avro-schema_avro-schema.txt index 42371d2e5..ae6590ae7 100644 --- a/sqrl-testing/sqrl-integration-tests/src/test/resources/snapshots/com/datasqrl/FullUsecasesIT/avro-schema_avro-schema.txt +++ b/sqrl-testing/sqrl-integration-tests/src/test/resources/snapshots/com/datasqrl/FullUsecasesIT/avro-schema_avro-schema.txt @@ -1,2 +1,2 @@ >>>MySchemaQuery.graphql -{"data":{"Schema":[{"uuidField":"223e4567-e89b-12d3-a456-426614174001","timestampMillisField":"2023-08-09T21:16:19.000Z","nullableTimestampMillisField":"2023-08-09T21:16:19.000Z","timestampMicrosField":"2023-08-09T21:16:19.000Z","nullableTimestampMicrosField":"2023-08-09T21:16:19.000Z","dateField":"2020-01-01","nullableDateField":null,"timeMillisField":"23:59:59","nullableTimeMillisField":"23:59:59","timeMicrosField":"23:59:59","nullableTimeMicrosField":"23:59:59","stringField":"example2","nullableStringField":"optional","intField":84,"nullableIntField":21,"longField":9.8765432109876E13,"nullableLongField":9.87654321E9,"floatField":6.28000021,"nullableFloatField":1.57000005,"doubleField":1.414,"nullableDoubleField":0.707,"booleanField":false,"nullableBooleanField":true,"enumField":"TWO","nullableEnumField":"FOUR","decimalField":7890.12,"complexArrayField":[{"itemFieldOne":2,"itemFieldTwo":"another"}],"multiNestedRecord":{"nestedLevelOne":{"levelOneField":"nestedLevel1","nestedLevelTwo":{"levelTwoField":20}}},"nullableComplexArrayField":[{"nullableItemFieldOne":3.5,"nullableItemFieldTwo":true}],"nestedRecord":{"nestedStringField":"nestedExample","nestedIntField":15},"nullableNestedRecord":{"nullableNestedStringField":"nullable","nullableNestedLongField":5.67890123456E11}},{"uuidField":"123e4567-e89b-12d3-a456-426614174000","timestampMillisField":"2023-08-08T17:29:39.000Z","nullableTimestampMillisField":null,"timestampMicrosField":"2023-08-08T17:29:39.000Z","nullableTimestampMicrosField":null,"dateField":"2020-01-01","nullableDateField":null,"timeMillisField":"23:59:59","nullableTimeMillisField":null,"timeMicrosField":"23:59:59","nullableTimeMicrosField":null,"stringField":"example","nullableStringField":null,"intField":42,"nullableIntField":null,"longField":1.23456789012345E14,"nullableLongField":null,"floatField":3.1400001,"nullableFloatField":null,"doubleField":2.718,"nullableDoubleField":null,"booleanField":true,"nullableBooleanField":null,"enumField":"ONE","nullableEnumField":null,"decimalField":1234.56,"complexArrayField":[{"itemFieldOne":1,"itemFieldTwo":"example"}],"multiNestedRecord":{"nestedLevelOne":{"levelOneField":"level1","nestedLevelTwo":{"levelTwoField":10}}},"nullableComplexArrayField":null,"nestedRecord":{"nestedStringField":"nested","nestedIntField":5},"nullableNestedRecord":null}]}} +{"data":{"Schema":[{"uuidField":"223e4567-e89b-12d3-a456-426614174001","timestampMillisField":"2023-08-09T21:16:19.000Z","nullableTimestampMillisField":"2023-08-09T21:16:19.000Z","timestampMicrosField":"2023-08-09T21:16:19.000Z","nullableTimestampMicrosField":"2023-08-09T21:16:19.000Z","dateField":"2020-01-01","nullableDateField":null,"timeMillisField":"23:59:59","nullableTimeMillisField":"23:59:59","timeMicrosField":"23:59:59","nullableTimeMicrosField":"23:59:59","stringField":"example2","nullableStringField":"optional","intField":84,"nullableIntField":21,"longField":9.8765432109876E13,"nullableLongField":9.87654321E9,"floatField":6.28000021,"nullableFloatField":1.57000005,"doubleField":1.414,"nullableDoubleField":0.707,"booleanField":false,"nullableBooleanField":true,"enumField":"TWO","arrayField":["x","y","z"],"nullableArrayField":[10,20,30],"nullableEnumField":"FOUR","decimalField":7890.12,"complexArrayField":[{"itemFieldOne":2,"itemFieldTwo":"another"}],"multiNestedRecord":{"nestedLevelOne":{"levelOneField":"nestedLevel1","nestedLevelTwo":{"levelTwoField":20}}},"nullableComplexArrayField":[{"nullableItemFieldOne":3.5,"nullableItemFieldTwo":true}],"nestedRecord":{"nestedStringField":"nestedExample","nestedIntField":15,"nestedArrayField":[4.4,5.5]},"nullableNestedRecord":{"nullableNestedStringField":"nullable","nullableNestedLongField":5.67890123456E11}},{"uuidField":"123e4567-e89b-12d3-a456-426614174000","timestampMillisField":"2023-08-08T17:29:39.000Z","nullableTimestampMillisField":null,"timestampMicrosField":"2023-08-08T17:29:39.000Z","nullableTimestampMicrosField":null,"dateField":"2020-01-01","nullableDateField":null,"timeMillisField":"23:59:59","nullableTimeMillisField":null,"timeMicrosField":"23:59:59","nullableTimeMicrosField":null,"stringField":"example","nullableStringField":null,"intField":42,"nullableIntField":null,"longField":1.23456789012345E14,"nullableLongField":null,"floatField":3.1400001,"nullableFloatField":null,"doubleField":2.718,"nullableDoubleField":null,"booleanField":true,"nullableBooleanField":null,"enumField":"ONE","arrayField":["a","b","c"],"nullableArrayField":null,"nullableEnumField":null,"decimalField":1234.56,"complexArrayField":[{"itemFieldOne":1,"itemFieldTwo":"example"}],"multiNestedRecord":{"nestedLevelOne":{"levelOneField":"level1","nestedLevelTwo":{"levelTwoField":10}}},"nullableComplexArrayField":null,"nestedRecord":{"nestedStringField":"nested","nestedIntField":5,"nestedArrayField":[1.1,2.2,3.3]},"nullableNestedRecord":null}]}} diff --git a/sqrl-testing/sqrl-integration-tests/src/test/resources/snapshots/com/datasqrl/UseCaseCompileTest/avro-schema--package.txt b/sqrl-testing/sqrl-integration-tests/src/test/resources/snapshots/com/datasqrl/UseCaseCompileTest/avro-schema--package.txt index baad43210..31bb7de0f 100644 --- a/sqrl-testing/sqrl-integration-tests/src/test/resources/snapshots/com/datasqrl/UseCaseCompileTest/avro-schema--package.txt +++ b/sqrl-testing/sqrl-integration-tests/src/test/resources/snapshots/com/datasqrl/UseCaseCompileTest/avro-schema--package.txt @@ -34,7 +34,9 @@ Schema: - nullableBooleanField: BOOLEAN - enumField: VARCHAR(2147483647) CHARACTER SET "UTF-16LE" NOT NULL - nullableEnumField: VARCHAR(2147483647) CHARACTER SET "UTF-16LE" - - nestedRecord: RecordType:peek_no_expand(VARCHAR(2147483647) CHARACTER SET "UTF-16LE" NOT NULL nestedStringField, INTEGER NOT NULL nestedIntField) NOT NULL + - arrayField: VARCHAR(2147483647) CHARACTER SET "UTF-16LE" NOT NULL ARRAY NOT NULL + - nullableArrayField: INTEGER NOT NULL ARRAY + - nestedRecord: RecordType:peek_no_expand(VARCHAR(2147483647) CHARACTER SET "UTF-16LE" NOT NULL nestedStringField, INTEGER NOT NULL nestedIntField, FLOAT NOT NULL ARRAY NOT NULL nestedArrayField) NOT NULL - nullableNestedRecord: RecordType:peek_no_expand(VARCHAR(2147483647) CHARACTER SET "UTF-16LE" nullableNestedStringField, BIGINT nullableNestedLongField) - decimalField: DECIMAL(10, 2) NOT NULL Plan: @@ -44,9 +46,9 @@ LogicalTableScan(table=[[schema_1]]) { "flinkSql" : [ "CREATE TEMPORARY FUNCTION IF NOT EXISTS `ToJson` AS 'com.datasqrl.json.ToJson' LANGUAGE JAVA;", - "CREATE TEMPORARY TABLE `schema_1` (\n `uuidField` VARCHAR(2147483647) CHARACTER SET `UTF-16LE` NOT NULL,\n `timestampMillisField` TIMESTAMP(3) WITH LOCAL TIME ZONE NOT NULL,\n `nullableTimestampMillisField` TIMESTAMP(3) WITH LOCAL TIME ZONE,\n `timestampMicrosField` TIMESTAMP(6) WITH LOCAL TIME ZONE NOT NULL,\n `nullableTimestampMicrosField` TIMESTAMP(6) WITH LOCAL TIME ZONE,\n `dateField` DATE NOT NULL,\n `nullableDateField` DATE,\n `timeMillisField` TIME(0) NOT NULL,\n `nullableTimeMillisField` TIME(0),\n `timeMicrosField` TIME(0) NOT NULL,\n `nullableTimeMicrosField` TIME(0),\n `complexArrayField` ROW(`itemFieldOne` INTEGER NOT NULL, `itemFieldTwo` VARCHAR(2147483647) CHARACTER SET `UTF-16LE` NOT NULL) NOT NULL ARRAY NOT NULL,\n `nullableComplexArrayField` ROW(`nullableItemFieldOne` DOUBLE, `nullableItemFieldTwo` BOOLEAN) ARRAY,\n `multiNestedRecord` ROW(`nestedLevelOne` ROW(`levelOneField` VARCHAR(2147483647) CHARACTER SET `UTF-16LE` NOT NULL, `nestedLevelTwo` ROW(`levelTwoField` INTEGER NOT NULL) NOT NULL) NOT NULL) NOT NULL,\n `stringField` VARCHAR(2147483647) CHARACTER SET `UTF-16LE` NOT NULL,\n `nullableStringField` VARCHAR(2147483647) CHARACTER SET `UTF-16LE`,\n `intField` INTEGER NOT NULL,\n `nullableIntField` INTEGER,\n `longField` BIGINT NOT NULL,\n `nullableLongField` BIGINT,\n `floatField` FLOAT NOT NULL,\n `nullableFloatField` FLOAT,\n `doubleField` DOUBLE NOT NULL,\n `nullableDoubleField` DOUBLE,\n `booleanField` BOOLEAN NOT NULL,\n `nullableBooleanField` BOOLEAN,\n `enumField` VARCHAR(2147483647) CHARACTER SET `UTF-16LE` NOT NULL,\n `nullableEnumField` VARCHAR(2147483647) CHARACTER SET `UTF-16LE`,\n `nestedRecord` ROW(`nestedStringField` VARCHAR(2147483647) CHARACTER SET `UTF-16LE` NOT NULL, `nestedIntField` INTEGER NOT NULL) NOT NULL,\n `nullableNestedRecord` ROW(`nullableNestedStringField` VARCHAR(2147483647) CHARACTER SET `UTF-16LE`, `nullableNestedLongField` BIGINT),\n `decimalField` DECIMAL(10, 2) NOT NULL,\n PRIMARY KEY (`uuidField`, `timestampMillisField`) NOT ENFORCED,\n WATERMARK FOR `timestampMillisField` AS `timestampMillisField` - INTERVAL '0.0' SECOND\n) WITH (\n 'format' = 'flexible-json',\n 'path' = '${DATA_PATH}/schema.jsonl',\n 'connector' = 'filesystem'\n);", - "CREATE TEMPORARY TABLE `schema_2` (\n `uuidField` VARCHAR(2147483647) CHARACTER SET `UTF-16LE` NOT NULL,\n `timestampMillisField` TIMESTAMP(3) WITH LOCAL TIME ZONE NOT NULL,\n `nullableTimestampMillisField` TIMESTAMP(3) WITH LOCAL TIME ZONE,\n `timestampMicrosField` TIMESTAMP(6) WITH LOCAL TIME ZONE NOT NULL,\n `nullableTimestampMicrosField` TIMESTAMP(6) WITH LOCAL TIME ZONE,\n `dateField` DATE NOT NULL,\n `nullableDateField` DATE,\n `timeMillisField` TIME(0) NOT NULL,\n `nullableTimeMillisField` TIME(0),\n `timeMicrosField` TIME(0) NOT NULL,\n `nullableTimeMicrosField` TIME(0),\n `complexArrayField` RAW('com.datasqrl.json.FlinkJsonType', 'ADFjb20uZGF0YXNxcmwuanNvbi5GbGlua0pzb25UeXBlU2VyaWFsaXplclNuYXBzaG90AAAAAQApY29tLmRhdGFzcXJsLmpzb24uRmxpbmtKc29uVHlwZVNlcmlhbGl6ZXI='),\n `nullableComplexArrayField` RAW('com.datasqrl.json.FlinkJsonType', 'ADFjb20uZGF0YXNxcmwuanNvbi5GbGlua0pzb25UeXBlU2VyaWFsaXplclNuYXBzaG90AAAAAQApY29tLmRhdGFzcXJsLmpzb24uRmxpbmtKc29uVHlwZVNlcmlhbGl6ZXI='),\n `multiNestedRecord` RAW('com.datasqrl.json.FlinkJsonType', 'ADFjb20uZGF0YXNxcmwuanNvbi5GbGlua0pzb25UeXBlU2VyaWFsaXplclNuYXBzaG90AAAAAQApY29tLmRhdGFzcXJsLmpzb24uRmxpbmtKc29uVHlwZVNlcmlhbGl6ZXI='),\n `stringField` VARCHAR(2147483647) CHARACTER SET `UTF-16LE` NOT NULL,\n `nullableStringField` VARCHAR(2147483647) CHARACTER SET `UTF-16LE`,\n `intField` INTEGER NOT NULL,\n `nullableIntField` INTEGER,\n `longField` BIGINT NOT NULL,\n `nullableLongField` BIGINT,\n `floatField` FLOAT NOT NULL,\n `nullableFloatField` FLOAT,\n `doubleField` DOUBLE NOT NULL,\n `nullableDoubleField` DOUBLE,\n `booleanField` BOOLEAN NOT NULL,\n `nullableBooleanField` BOOLEAN,\n `enumField` VARCHAR(2147483647) CHARACTER SET `UTF-16LE` NOT NULL,\n `nullableEnumField` VARCHAR(2147483647) CHARACTER SET `UTF-16LE`,\n `nestedRecord` RAW('com.datasqrl.json.FlinkJsonType', 'ADFjb20uZGF0YXNxcmwuanNvbi5GbGlua0pzb25UeXBlU2VyaWFsaXplclNuYXBzaG90AAAAAQApY29tLmRhdGFzcXJsLmpzb24uRmxpbmtKc29uVHlwZVNlcmlhbGl6ZXI='),\n `nullableNestedRecord` RAW('com.datasqrl.json.FlinkJsonType', 'ADFjb20uZGF0YXNxcmwuanNvbi5GbGlua0pzb25UeXBlU2VyaWFsaXplclNuYXBzaG90AAAAAQApY29tLmRhdGFzcXJsLmpzb24uRmxpbmtKc29uVHlwZVNlcmlhbGl6ZXI='),\n `decimalField` DECIMAL(10, 2) NOT NULL,\n PRIMARY KEY (`uuidField`, `timestampMillisField`) NOT ENFORCED\n) WITH (\n 'password' = '${JDBC_PASSWORD}',\n 'connector' = 'jdbc-sqrl',\n 'driver' = 'org.postgresql.Driver',\n 'table-name' = 'schema_2',\n 'url' = '${JDBC_URL}',\n 'username' = '${JDBC_USERNAME}'\n);", - "CREATE VIEW `table$1`\nAS\nSELECT `uuidField`, `timestampMillisField`, `nullableTimestampMillisField`, `timestampMicrosField`, `nullableTimestampMicrosField`, `dateField`, `nullableDateField`, `timeMillisField`, `nullableTimeMillisField`, `timeMicrosField`, `nullableTimeMicrosField`, TOJSON(`complexArrayField`) AS `complexArrayField`, TOJSON(`nullableComplexArrayField`) AS `nullableComplexArrayField`, TOJSON(`multiNestedRecord`) AS `multiNestedRecord`, `stringField`, `nullableStringField`, `intField`, `nullableIntField`, `longField`, `nullableLongField`, `floatField`, `nullableFloatField`, `doubleField`, `nullableDoubleField`, `booleanField`, `nullableBooleanField`, `enumField`, `nullableEnumField`, TOJSON(`nestedRecord`) AS `nestedRecord`, TOJSON(`nullableNestedRecord`) AS `nullableNestedRecord`, `decimalField`\nFROM `schema_1`;", + "CREATE TEMPORARY TABLE `schema_1` (\n `uuidField` VARCHAR(2147483647) CHARACTER SET `UTF-16LE` NOT NULL,\n `timestampMillisField` TIMESTAMP(3) WITH LOCAL TIME ZONE NOT NULL,\n `nullableTimestampMillisField` TIMESTAMP(3) WITH LOCAL TIME ZONE,\n `timestampMicrosField` TIMESTAMP(6) WITH LOCAL TIME ZONE NOT NULL,\n `nullableTimestampMicrosField` TIMESTAMP(6) WITH LOCAL TIME ZONE,\n `dateField` DATE NOT NULL,\n `nullableDateField` DATE,\n `timeMillisField` TIME(0) NOT NULL,\n `nullableTimeMillisField` TIME(0),\n `timeMicrosField` TIME(0) NOT NULL,\n `nullableTimeMicrosField` TIME(0),\n `complexArrayField` ROW(`itemFieldOne` INTEGER NOT NULL, `itemFieldTwo` VARCHAR(2147483647) CHARACTER SET `UTF-16LE` NOT NULL) NOT NULL ARRAY NOT NULL,\n `nullableComplexArrayField` ROW(`nullableItemFieldOne` DOUBLE, `nullableItemFieldTwo` BOOLEAN) ARRAY,\n `multiNestedRecord` ROW(`nestedLevelOne` ROW(`levelOneField` VARCHAR(2147483647) CHARACTER SET `UTF-16LE` NOT NULL, `nestedLevelTwo` ROW(`levelTwoField` INTEGER NOT NULL) NOT NULL) NOT NULL) NOT NULL,\n `stringField` VARCHAR(2147483647) CHARACTER SET `UTF-16LE` NOT NULL,\n `nullableStringField` VARCHAR(2147483647) CHARACTER SET `UTF-16LE`,\n `intField` INTEGER NOT NULL,\n `nullableIntField` INTEGER,\n `longField` BIGINT NOT NULL,\n `nullableLongField` BIGINT,\n `floatField` FLOAT NOT NULL,\n `nullableFloatField` FLOAT,\n `doubleField` DOUBLE NOT NULL,\n `nullableDoubleField` DOUBLE,\n `booleanField` BOOLEAN NOT NULL,\n `nullableBooleanField` BOOLEAN,\n `enumField` VARCHAR(2147483647) CHARACTER SET `UTF-16LE` NOT NULL,\n `nullableEnumField` VARCHAR(2147483647) CHARACTER SET `UTF-16LE`,\n `arrayField` VARCHAR(2147483647) CHARACTER SET `UTF-16LE` NOT NULL ARRAY NOT NULL,\n `nullableArrayField` INTEGER ARRAY,\n `nestedRecord` ROW(`nestedStringField` VARCHAR(2147483647) CHARACTER SET `UTF-16LE` NOT NULL, `nestedIntField` INTEGER NOT NULL, `nestedArrayField` FLOAT NOT NULL ARRAY NOT NULL) NOT NULL,\n `nullableNestedRecord` ROW(`nullableNestedStringField` VARCHAR(2147483647) CHARACTER SET `UTF-16LE`, `nullableNestedLongField` BIGINT),\n `decimalField` DECIMAL(10, 2) NOT NULL,\n PRIMARY KEY (`uuidField`, `timestampMillisField`) NOT ENFORCED,\n WATERMARK FOR `timestampMillisField` AS `timestampMillisField` - INTERVAL '0.0' SECOND\n) WITH (\n 'format' = 'flexible-json',\n 'path' = '${DATA_PATH}/schema.jsonl',\n 'connector' = 'filesystem'\n);", + "CREATE TEMPORARY TABLE `schema_2` (\n `uuidField` VARCHAR(2147483647) CHARACTER SET `UTF-16LE` NOT NULL,\n `timestampMillisField` TIMESTAMP(3) WITH LOCAL TIME ZONE NOT NULL,\n `nullableTimestampMillisField` TIMESTAMP(3) WITH LOCAL TIME ZONE,\n `timestampMicrosField` TIMESTAMP(6) WITH LOCAL TIME ZONE NOT NULL,\n `nullableTimestampMicrosField` TIMESTAMP(6) WITH LOCAL TIME ZONE,\n `dateField` DATE NOT NULL,\n `nullableDateField` DATE,\n `timeMillisField` TIME(0) NOT NULL,\n `nullableTimeMillisField` TIME(0),\n `timeMicrosField` TIME(0) NOT NULL,\n `nullableTimeMicrosField` TIME(0),\n `complexArrayField` RAW('com.datasqrl.json.FlinkJsonType', 'ADFjb20uZGF0YXNxcmwuanNvbi5GbGlua0pzb25UeXBlU2VyaWFsaXplclNuYXBzaG90AAAAAQApY29tLmRhdGFzcXJsLmpzb24uRmxpbmtKc29uVHlwZVNlcmlhbGl6ZXI='),\n `nullableComplexArrayField` RAW('com.datasqrl.json.FlinkJsonType', 'ADFjb20uZGF0YXNxcmwuanNvbi5GbGlua0pzb25UeXBlU2VyaWFsaXplclNuYXBzaG90AAAAAQApY29tLmRhdGFzcXJsLmpzb24uRmxpbmtKc29uVHlwZVNlcmlhbGl6ZXI='),\n `multiNestedRecord` RAW('com.datasqrl.json.FlinkJsonType', 'ADFjb20uZGF0YXNxcmwuanNvbi5GbGlua0pzb25UeXBlU2VyaWFsaXplclNuYXBzaG90AAAAAQApY29tLmRhdGFzcXJsLmpzb24uRmxpbmtKc29uVHlwZVNlcmlhbGl6ZXI='),\n `stringField` VARCHAR(2147483647) CHARACTER SET `UTF-16LE` NOT NULL,\n `nullableStringField` VARCHAR(2147483647) CHARACTER SET `UTF-16LE`,\n `intField` INTEGER NOT NULL,\n `nullableIntField` INTEGER,\n `longField` BIGINT NOT NULL,\n `nullableLongField` BIGINT,\n `floatField` FLOAT NOT NULL,\n `nullableFloatField` FLOAT,\n `doubleField` DOUBLE NOT NULL,\n `nullableDoubleField` DOUBLE,\n `booleanField` BOOLEAN NOT NULL,\n `nullableBooleanField` BOOLEAN,\n `enumField` VARCHAR(2147483647) CHARACTER SET `UTF-16LE` NOT NULL,\n `nullableEnumField` VARCHAR(2147483647) CHARACTER SET `UTF-16LE`,\n `arrayField` RAW('com.datasqrl.json.FlinkJsonType', 'ADFjb20uZGF0YXNxcmwuanNvbi5GbGlua0pzb25UeXBlU2VyaWFsaXplclNuYXBzaG90AAAAAQApY29tLmRhdGFzcXJsLmpzb24uRmxpbmtKc29uVHlwZVNlcmlhbGl6ZXI='),\n `nullableArrayField` RAW('com.datasqrl.json.FlinkJsonType', 'ADFjb20uZGF0YXNxcmwuanNvbi5GbGlua0pzb25UeXBlU2VyaWFsaXplclNuYXBzaG90AAAAAQApY29tLmRhdGFzcXJsLmpzb24uRmxpbmtKc29uVHlwZVNlcmlhbGl6ZXI='),\n `nestedRecord` RAW('com.datasqrl.json.FlinkJsonType', 'ADFjb20uZGF0YXNxcmwuanNvbi5GbGlua0pzb25UeXBlU2VyaWFsaXplclNuYXBzaG90AAAAAQApY29tLmRhdGFzcXJsLmpzb24uRmxpbmtKc29uVHlwZVNlcmlhbGl6ZXI='),\n `nullableNestedRecord` RAW('com.datasqrl.json.FlinkJsonType', 'ADFjb20uZGF0YXNxcmwuanNvbi5GbGlua0pzb25UeXBlU2VyaWFsaXplclNuYXBzaG90AAAAAQApY29tLmRhdGFzcXJsLmpzb24uRmxpbmtKc29uVHlwZVNlcmlhbGl6ZXI='),\n `decimalField` DECIMAL(10, 2) NOT NULL,\n PRIMARY KEY (`uuidField`, `timestampMillisField`) NOT ENFORCED\n) WITH (\n 'password' = '${JDBC_PASSWORD}',\n 'connector' = 'jdbc-sqrl',\n 'driver' = 'org.postgresql.Driver',\n 'table-name' = 'schema_2',\n 'url' = '${JDBC_URL}',\n 'username' = '${JDBC_USERNAME}'\n);", + "CREATE VIEW `table$1`\nAS\nSELECT `uuidField`, `timestampMillisField`, `nullableTimestampMillisField`, `timestampMicrosField`, `nullableTimestampMicrosField`, `dateField`, `nullableDateField`, `timeMillisField`, `nullableTimeMillisField`, `timeMicrosField`, `nullableTimeMicrosField`, TOJSON(`complexArrayField`) AS `complexArrayField`, TOJSON(`nullableComplexArrayField`) AS `nullableComplexArrayField`, TOJSON(`multiNestedRecord`) AS `multiNestedRecord`, `stringField`, `nullableStringField`, `intField`, `nullableIntField`, `longField`, `nullableLongField`, `floatField`, `nullableFloatField`, `doubleField`, `nullableDoubleField`, `booleanField`, `nullableBooleanField`, `enumField`, `nullableEnumField`, TOJSON(`arrayField`) AS `arrayField`, TOJSON(`nullableArrayField`) AS `nullableArrayField`, TOJSON(`nestedRecord`) AS `nestedRecord`, TOJSON(`nullableNestedRecord`) AS `nullableNestedRecord`, `decimalField`\nFROM `schema_1`;", "EXECUTE STATEMENT SET BEGIN\nINSERT INTO `schema_2`\n(SELECT *\n FROM `table$1`)\n;\nEND;" ], "connectors" : [ @@ -95,6 +97,8 @@ LogicalTableScan(table=[[schema_1]]) "\"nullableBooleanField\" BOOLEAN ", "\"enumField\" TEXT NOT NULL", "\"nullableEnumField\" TEXT ", + "\"arrayField\" JSONB NOT NULL", + "\"nullableArrayField\" JSONB ", "\"nestedRecord\" JSONB NOT NULL", "\"nullableNestedRecord\" JSONB ", "\"decimalField\" NUMERIC NOT NULL" @@ -103,7 +107,7 @@ LogicalTableScan(table=[[schema_1]]) "\"uuidField\"", "\"timestampMillisField\"" ], - "sql" : "CREATE TABLE IF NOT EXISTS schema_2 (\"uuidField\" TEXT NOT NULL,\"timestampMillisField\" TIMESTAMP WITH TIME ZONE NOT NULL,\"nullableTimestampMillisField\" TIMESTAMP WITH TIME ZONE ,\"timestampMicrosField\" TIMESTAMP WITH TIME ZONE NOT NULL,\"nullableTimestampMicrosField\" TIMESTAMP WITH TIME ZONE ,\"dateField\" DATE NOT NULL,\"nullableDateField\" DATE ,\"timeMillisField\" TIME WITHOUT TIME ZONE NOT NULL,\"nullableTimeMillisField\" TIME WITHOUT TIME ZONE ,\"timeMicrosField\" TIME WITHOUT TIME ZONE NOT NULL,\"nullableTimeMicrosField\" TIME WITHOUT TIME ZONE ,\"complexArrayField\" JSONB NOT NULL,\"nullableComplexArrayField\" JSONB ,\"multiNestedRecord\" JSONB NOT NULL,\"stringField\" TEXT NOT NULL,\"nullableStringField\" TEXT ,\"intField\" INTEGER NOT NULL,\"nullableIntField\" INTEGER ,\"longField\" BIGINT NOT NULL,\"nullableLongField\" BIGINT ,\"floatField\" FLOAT NOT NULL,\"nullableFloatField\" FLOAT ,\"doubleField\" DOUBLE PRECISION NOT NULL,\"nullableDoubleField\" DOUBLE PRECISION ,\"booleanField\" BOOLEAN NOT NULL,\"nullableBooleanField\" BOOLEAN ,\"enumField\" TEXT NOT NULL,\"nullableEnumField\" TEXT ,\"nestedRecord\" JSONB NOT NULL,\"nullableNestedRecord\" JSONB ,\"decimalField\" NUMERIC NOT NULL , PRIMARY KEY (\"uuidField\",\"timestampMillisField\"));" + "sql" : "CREATE TABLE IF NOT EXISTS schema_2 (\"uuidField\" TEXT NOT NULL,\"timestampMillisField\" TIMESTAMP WITH TIME ZONE NOT NULL,\"nullableTimestampMillisField\" TIMESTAMP WITH TIME ZONE ,\"timestampMicrosField\" TIMESTAMP WITH TIME ZONE NOT NULL,\"nullableTimestampMicrosField\" TIMESTAMP WITH TIME ZONE ,\"dateField\" DATE NOT NULL,\"nullableDateField\" DATE ,\"timeMillisField\" TIME WITHOUT TIME ZONE NOT NULL,\"nullableTimeMillisField\" TIME WITHOUT TIME ZONE ,\"timeMicrosField\" TIME WITHOUT TIME ZONE NOT NULL,\"nullableTimeMicrosField\" TIME WITHOUT TIME ZONE ,\"complexArrayField\" JSONB NOT NULL,\"nullableComplexArrayField\" JSONB ,\"multiNestedRecord\" JSONB NOT NULL,\"stringField\" TEXT NOT NULL,\"nullableStringField\" TEXT ,\"intField\" INTEGER NOT NULL,\"nullableIntField\" INTEGER ,\"longField\" BIGINT NOT NULL,\"nullableLongField\" BIGINT ,\"floatField\" FLOAT NOT NULL,\"nullableFloatField\" FLOAT ,\"doubleField\" DOUBLE PRECISION NOT NULL,\"nullableDoubleField\" DOUBLE PRECISION ,\"booleanField\" BOOLEAN NOT NULL,\"nullableBooleanField\" BOOLEAN ,\"enumField\" TEXT NOT NULL,\"nullableEnumField\" TEXT ,\"arrayField\" JSONB NOT NULL,\"nullableArrayField\" JSONB ,\"nestedRecord\" JSONB NOT NULL,\"nullableNestedRecord\" JSONB ,\"decimalField\" NUMERIC NOT NULL , PRIMARY KEY (\"uuidField\",\"timestampMillisField\"));" }, { "indexName" : "schema_2_hash_c1", @@ -118,7 +122,7 @@ LogicalTableScan(table=[[schema_1]]) "views" : [ { "name" : "Schema", - "sql" : "CREATE OR REPLACE VIEW \"Schema\"(\"uuidField\", \"timestampMillisField\", \"nullableTimestampMillisField\", \"timestampMicrosField\", \"nullableTimestampMicrosField\", \"dateField\", \"nullableDateField\", \"timeMillisField\", \"nullableTimeMillisField\", \"timeMicrosField\", \"nullableTimeMicrosField\", \"complexArrayField\", \"nullableComplexArrayField\", \"multiNestedRecord\", \"stringField\", \"nullableStringField\", \"intField\", \"nullableIntField\", \"longField\", \"nullableLongField\", \"floatField\", \"nullableFloatField\", \"doubleField\", \"nullableDoubleField\", \"booleanField\", \"nullableBooleanField\", \"enumField\", \"nullableEnumField\", \"nestedRecord\", \"nullableNestedRecord\", \"decimalField\") AS SELECT *\nFROM \"schema_2\"\nORDER BY \"timestampMillisField\" DESC NULLS LAST, \"uuidField\";" + "sql" : "CREATE OR REPLACE VIEW \"Schema\"(\"uuidField\", \"timestampMillisField\", \"nullableTimestampMillisField\", \"timestampMicrosField\", \"nullableTimestampMicrosField\", \"dateField\", \"nullableDateField\", \"timeMillisField\", \"nullableTimeMillisField\", \"timeMicrosField\", \"nullableTimeMicrosField\", \"complexArrayField\", \"nullableComplexArrayField\", \"multiNestedRecord\", \"stringField\", \"nullableStringField\", \"intField\", \"nullableIntField\", \"longField\", \"nullableLongField\", \"floatField\", \"nullableFloatField\", \"doubleField\", \"nullableDoubleField\", \"booleanField\", \"nullableBooleanField\", \"enumField\", \"nullableEnumField\", \"arrayField\", \"nullableArrayField\", \"nestedRecord\", \"nullableNestedRecord\", \"decimalField\") AS SELECT *\nFROM \"schema_2\"\nORDER BY \"timestampMillisField\" DESC NULLS LAST, \"uuidField\";" } ] } @@ -262,7 +266,7 @@ LogicalTableScan(table=[[schema_1]]) "schema" : { "type" : "string", "type" : "string", - "schema" : "\"An RFC-3339 compliant Full Date Scalar\"\nscalar Date\n\n\"An RFC-3339 compliant DateTime Scalar\"\nscalar DateTime\n\n\"24-hour clock time value string in the format `hh:mm:ss` or `hh:mm:ss.sss`.\"\nscalar LocalTime\n\ntype Query {\n Schema(uuidField: String, timestampMillisField: DateTime, limit: Int = 10, offset: Int = 0): [Schema!]\n}\n\ntype Schema {\n uuidField: String!\n timestampMillisField: DateTime!\n nullableTimestampMillisField: DateTime\n timestampMicrosField: DateTime!\n nullableTimestampMicrosField: DateTime\n dateField: Date!\n nullableDateField: Date\n timeMillisField: LocalTime!\n nullableTimeMillisField: LocalTime\n timeMicrosField: LocalTime!\n nullableTimeMicrosField: LocalTime\n stringField: String!\n nullableStringField: String\n intField: Int!\n nullableIntField: Int\n longField: Float!\n nullableLongField: Float\n floatField: Float!\n nullableFloatField: Float\n doubleField: Float!\n nullableDoubleField: Float\n booleanField: Boolean!\n nullableBooleanField: Boolean\n enumField: String!\n nullableEnumField: String\n decimalField: Float!\n complexArrayField(limit: Int = 10, offset: Int = 0): [complexArrayField!]\n multiNestedRecord: multiNestedRecord!\n nestedRecord: nestedRecord!\n nullableComplexArrayField(limit: Int = 10, offset: Int = 0): [nullableComplexArrayField!]\n nullableNestedRecord: nullableNestedRecord\n}\n\ntype complexArrayField {\n itemFieldOne: Int!\n itemFieldTwo: String!\n}\n\ntype multiNestedRecord {\n nestedLevelOne: nestedLevelOne!\n}\n\ntype nestedLevelOne {\n levelOneField: String!\n nestedLevelTwo: nestedLevelTwo!\n}\n\ntype nestedLevelTwo {\n levelTwoField: Int!\n}\n\ntype nestedRecord {\n nestedStringField: String!\n nestedIntField: Int!\n}\n\ntype nullableComplexArrayField {\n nullableItemFieldOne: Float\n nullableItemFieldTwo: Boolean\n}\n\ntype nullableNestedRecord {\n nullableNestedStringField: String\n nullableNestedLongField: Float\n}\n" + "schema" : "\"An RFC-3339 compliant Full Date Scalar\"\nscalar Date\n\n\"An RFC-3339 compliant DateTime Scalar\"\nscalar DateTime\n\n\"24-hour clock time value string in the format `hh:mm:ss` or `hh:mm:ss.sss`.\"\nscalar LocalTime\n\ntype Query {\n Schema(uuidField: String, timestampMillisField: DateTime, limit: Int = 10, offset: Int = 0): [Schema!]\n}\n\ntype Schema {\n uuidField: String!\n timestampMillisField: DateTime!\n nullableTimestampMillisField: DateTime\n timestampMicrosField: DateTime!\n nullableTimestampMicrosField: DateTime\n dateField: Date!\n nullableDateField: Date\n timeMillisField: LocalTime!\n nullableTimeMillisField: LocalTime\n timeMicrosField: LocalTime!\n nullableTimeMicrosField: LocalTime\n stringField: String!\n nullableStringField: String\n intField: Int!\n nullableIntField: Int\n longField: Float!\n nullableLongField: Float\n floatField: Float!\n nullableFloatField: Float\n doubleField: Float!\n nullableDoubleField: Float\n booleanField: Boolean!\n nullableBooleanField: Boolean\n enumField: String!\n nullableEnumField: String\n arrayField: [String]!\n nullableArrayField: [Int]\n decimalField: Float!\n complexArrayField(limit: Int = 10, offset: Int = 0): [complexArrayField!]\n multiNestedRecord: multiNestedRecord!\n nestedRecord: nestedRecord!\n nullableComplexArrayField(limit: Int = 10, offset: Int = 0): [nullableComplexArrayField!]\n nullableNestedRecord: nullableNestedRecord\n}\n\ntype complexArrayField {\n itemFieldOne: Int!\n itemFieldTwo: String!\n}\n\ntype multiNestedRecord {\n nestedLevelOne: nestedLevelOne!\n}\n\ntype nestedLevelOne {\n levelOneField: String!\n nestedLevelTwo: nestedLevelTwo!\n}\n\ntype nestedLevelTwo {\n levelTwoField: Int!\n}\n\ntype nestedRecord {\n nestedStringField: String!\n nestedIntField: Int!\n nestedArrayField: [Float]!\n}\n\ntype nullableComplexArrayField {\n nullableItemFieldOne: Float\n nullableItemFieldTwo: Boolean\n}\n\ntype nullableNestedRecord {\n nullableNestedStringField: String\n nullableNestedLongField: Float\n}\n" } } } diff --git a/sqrl-testing/sqrl-integration-tests/src/test/resources/usecases/avro-schema/avro-schema/schema.avsc b/sqrl-testing/sqrl-integration-tests/src/test/resources/usecases/avro-schema/avro-schema/schema.avsc index 3e4c96b95..5e79376c3 100644 --- a/sqrl-testing/sqrl-integration-tests/src/test/resources/usecases/avro-schema/avro-schema/schema.avsc +++ b/sqrl-testing/sqrl-integration-tests/src/test/resources/usecases/avro-schema/avro-schema/schema.avsc @@ -292,23 +292,23 @@ "default": null, "doc": "A nullable enum field" }, -// { -// "name": "arrayField", -// "type": { -// "type": "array", -// "items": "string" -// }, -// "doc": "An array of strings" -// }, -// { -// "name": "nullableArrayField", -// "type": ["null", { -// "type": "array", -// "items": "int" -// }], -// "default": null, -// "doc": "A nullable array of integers" -// }, + { + "name": "arrayField", + "type": { + "type": "array", + "items": "string" + }, + "doc": "An array of strings" + }, + { + "name": "nullableArrayField", + "type": ["null", { + "type": "array", + "items": "int" + }], + "default": null, + "doc": "A nullable array of integers" + }, { "name": "nestedRecord", "type": { @@ -322,15 +322,14 @@ { "name": "nestedIntField", "type": "int" + }, + { + "name": "nestedArrayField", + "type": { + "type": "array", + "items": "float" + } } -// , -// { -// "name": "nestedArrayField", -// "type": { -// "type": "array", -// "items": "float" -// } -// } ] }, "doc": "A nested record" diff --git a/sqrl-testing/sqrl-integration-tests/src/test/resources/usecases/avro-schema/snapshots-avro-schema/MySchema.snapshot b/sqrl-testing/sqrl-integration-tests/src/test/resources/usecases/avro-schema/snapshots-avro-schema/MySchema.snapshot index d0c7a7b07..5556667d5 100644 --- a/sqrl-testing/sqrl-integration-tests/src/test/resources/usecases/avro-schema/snapshots-avro-schema/MySchema.snapshot +++ b/sqrl-testing/sqrl-integration-tests/src/test/resources/usecases/avro-schema/snapshots-avro-schema/MySchema.snapshot @@ -1 +1 @@ -{"data":{"MySchema":[{"uuidField":"223e4567-e89b-12d3-a456-426614174001","timestampMillisField":"2023-08-09T21:16:19.000Z","nullableTimestampMillisField":"2023-08-09T21:16:19.000Z","timestampMicrosField":"2023-08-09T21:16:19.000Z","nullableTimestampMicrosField":"2023-08-09T21:16:19.000Z","dateField":"2020-01-01","nullableDateField":null,"timeMillisField":"23:59:59","nullableTimeMillisField":"23:59:59","timeMicrosField":"23:59:59","nullableTimeMicrosField":"23:59:59","stringField":"example2","nullableStringField":"optional","intField":84,"nullableIntField":21,"longField":9.8765432109876E13,"nullableLongField":9.87654321E9,"floatField":6.28000021,"nullableFloatField":1.57000005,"doubleField":1.414,"nullableDoubleField":0.707,"booleanField":false,"nullableBooleanField":true,"enumField":"TWO","nullableEnumField":"FOUR","decimalField":7890.12,"complexArrayField":[{"itemFieldOne":2,"itemFieldTwo":"another"}],"multiNestedRecord":{"nestedLevelOne":{"levelOneField":"nestedLevel1","nestedLevelTwo":{"levelTwoField":20}}},"nestedRecord":{"nestedStringField":"nestedExample","nestedIntField":15},"nullableComplexArrayField":[{"nullableItemFieldOne":3.5,"nullableItemFieldTwo":true}],"nullableNestedRecord":{"nullableNestedStringField":"nullable","nullableNestedLongField":5.67890123456E11}},{"uuidField":"123e4567-e89b-12d3-a456-426614174000","timestampMillisField":"2023-08-08T17:29:39.000Z","nullableTimestampMillisField":null,"timestampMicrosField":"2023-08-08T17:29:39.000Z","nullableTimestampMicrosField":null,"dateField":"2020-01-01","nullableDateField":null,"timeMillisField":"23:59:59","nullableTimeMillisField":null,"timeMicrosField":"23:59:59","nullableTimeMicrosField":null,"stringField":"example","nullableStringField":null,"intField":42,"nullableIntField":null,"longField":1.23456789012345E14,"nullableLongField":null,"floatField":3.1400001,"nullableFloatField":null,"doubleField":2.718,"nullableDoubleField":null,"booleanField":true,"nullableBooleanField":null,"enumField":"ONE","nullableEnumField":null,"decimalField":1234.56,"complexArrayField":[{"itemFieldOne":1,"itemFieldTwo":"example"}],"multiNestedRecord":{"nestedLevelOne":{"levelOneField":"level1","nestedLevelTwo":{"levelTwoField":10}}},"nestedRecord":{"nestedStringField":"nested","nestedIntField":5},"nullableComplexArrayField":null,"nullableNestedRecord":null}]}} \ No newline at end of file +{"data":{"MySchema":[{"uuidField":"223e4567-e89b-12d3-a456-426614174001","timestampMillisField":"2023-08-09T21:16:19.000Z","nullableTimestampMillisField":"2023-08-09T21:16:19.000Z","timestampMicrosField":"2023-08-09T21:16:19.000Z","nullableTimestampMicrosField":"2023-08-09T21:16:19.000Z","dateField":"2020-01-01","nullableDateField":null,"timeMillisField":"23:59:59","nullableTimeMillisField":"23:59:59","timeMicrosField":"23:59:59","nullableTimeMicrosField":"23:59:59","stringField":"example2","nullableStringField":"optional","intField":84,"nullableIntField":21,"longField":9.8765432109876E13,"nullableLongField":9.87654321E9,"floatField":6.28000021,"nullableFloatField":1.57000005,"doubleField":1.414,"nullableDoubleField":0.707,"booleanField":false,"nullableBooleanField":true,"enumField":"TWO","nullableEnumField":"FOUR","arrayField":["x","y","z"],"nullableArrayField":[10,20,30],"decimalField":7890.12,"complexArrayField":[{"itemFieldOne":2,"itemFieldTwo":"another"}],"multiNestedRecord":{"nestedLevelOne":{"levelOneField":"nestedLevel1","nestedLevelTwo":{"levelTwoField":20}}},"nestedRecord":{"nestedStringField":"nestedExample","nestedIntField":15,"nestedArrayField":[4.4,5.5]},"nullableComplexArrayField":[{"nullableItemFieldOne":3.5,"nullableItemFieldTwo":true}],"nullableNestedRecord":{"nullableNestedStringField":"nullable","nullableNestedLongField":5.67890123456E11}},{"uuidField":"123e4567-e89b-12d3-a456-426614174000","timestampMillisField":"2023-08-08T17:29:39.000Z","nullableTimestampMillisField":null,"timestampMicrosField":"2023-08-08T17:29:39.000Z","nullableTimestampMicrosField":null,"dateField":"2020-01-01","nullableDateField":null,"timeMillisField":"23:59:59","nullableTimeMillisField":null,"timeMicrosField":"23:59:59","nullableTimeMicrosField":null,"stringField":"example","nullableStringField":null,"intField":42,"nullableIntField":null,"longField":1.23456789012345E14,"nullableLongField":null,"floatField":3.1400001,"nullableFloatField":null,"doubleField":2.718,"nullableDoubleField":null,"booleanField":true,"nullableBooleanField":null,"enumField":"ONE","nullableEnumField":null,"arrayField":["a","b","c"],"nullableArrayField":null,"decimalField":1234.56,"complexArrayField":[{"itemFieldOne":1,"itemFieldTwo":"example"}],"multiNestedRecord":{"nestedLevelOne":{"levelOneField":"level1","nestedLevelTwo":{"levelTwoField":10}}},"nestedRecord":{"nestedStringField":"nested","nestedIntField":5,"nestedArrayField":[1.1,2.2,3.3]},"nullableComplexArrayField":null,"nullableNestedRecord":null}]}} \ No newline at end of file diff --git a/sqrl-testing/sqrl-integration-tests/src/test/resources/usecases/avro-schema/snapshots-avro-schema/MySchemaQuery.snapshot b/sqrl-testing/sqrl-integration-tests/src/test/resources/usecases/avro-schema/snapshots-avro-schema/MySchemaQuery.snapshot index 9486dafa1..31b1fbb21 100644 --- a/sqrl-testing/sqrl-integration-tests/src/test/resources/usecases/avro-schema/snapshots-avro-schema/MySchemaQuery.snapshot +++ b/sqrl-testing/sqrl-integration-tests/src/test/resources/usecases/avro-schema/snapshots-avro-schema/MySchemaQuery.snapshot @@ -1 +1 @@ -{"data":{"Schema":[{"uuidField":"223e4567-e89b-12d3-a456-426614174001","timestampMillisField":"2023-08-09T21:16:19.000Z","nullableTimestampMillisField":"2023-08-09T21:16:19.000Z","timestampMicrosField":"2023-08-09T21:16:19.000Z","nullableTimestampMicrosField":"2023-08-09T21:16:19.000Z","dateField":"2020-01-01","nullableDateField":null,"timeMillisField":"23:59:59","nullableTimeMillisField":"23:59:59","timeMicrosField":"23:59:59","nullableTimeMicrosField":"23:59:59","stringField":"example2","nullableStringField":"optional","intField":84,"nullableIntField":21,"longField":9.8765432109876E13,"nullableLongField":9.87654321E9,"floatField":6.28000021,"nullableFloatField":1.57000005,"doubleField":1.414,"nullableDoubleField":0.707,"booleanField":false,"nullableBooleanField":true,"enumField":"TWO","nullableEnumField":"FOUR","decimalField":7890.12,"complexArrayField":[{"itemFieldOne":2,"itemFieldTwo":"another"}],"multiNestedRecord":{"nestedLevelOne":{"levelOneField":"nestedLevel1","nestedLevelTwo":{"levelTwoField":20}}},"nullableComplexArrayField":[{"nullableItemFieldOne":3.5,"nullableItemFieldTwo":true}],"nestedRecord":{"nestedStringField":"nestedExample","nestedIntField":15},"nullableNestedRecord":{"nullableNestedStringField":"nullable","nullableNestedLongField":5.67890123456E11}},{"uuidField":"123e4567-e89b-12d3-a456-426614174000","timestampMillisField":"2023-08-08T17:29:39.000Z","nullableTimestampMillisField":null,"timestampMicrosField":"2023-08-08T17:29:39.000Z","nullableTimestampMicrosField":null,"dateField":"2020-01-01","nullableDateField":null,"timeMillisField":"23:59:59","nullableTimeMillisField":null,"timeMicrosField":"23:59:59","nullableTimeMicrosField":null,"stringField":"example","nullableStringField":null,"intField":42,"nullableIntField":null,"longField":1.23456789012345E14,"nullableLongField":null,"floatField":3.1400001,"nullableFloatField":null,"doubleField":2.718,"nullableDoubleField":null,"booleanField":true,"nullableBooleanField":null,"enumField":"ONE","nullableEnumField":null,"decimalField":1234.56,"complexArrayField":[{"itemFieldOne":1,"itemFieldTwo":"example"}],"multiNestedRecord":{"nestedLevelOne":{"levelOneField":"level1","nestedLevelTwo":{"levelTwoField":10}}},"nullableComplexArrayField":null,"nestedRecord":{"nestedStringField":"nested","nestedIntField":5},"nullableNestedRecord":null}]}} \ No newline at end of file +{"data":{"Schema":[{"uuidField":"223e4567-e89b-12d3-a456-426614174001","timestampMillisField":"2023-08-09T21:16:19.000Z","nullableTimestampMillisField":"2023-08-09T21:16:19.000Z","timestampMicrosField":"2023-08-09T21:16:19.000Z","nullableTimestampMicrosField":"2023-08-09T21:16:19.000Z","dateField":"2020-01-01","nullableDateField":null,"timeMillisField":"23:59:59","nullableTimeMillisField":"23:59:59","timeMicrosField":"23:59:59","nullableTimeMicrosField":"23:59:59","stringField":"example2","nullableStringField":"optional","intField":84,"nullableIntField":21,"longField":9.8765432109876E13,"nullableLongField":9.87654321E9,"floatField":6.28000021,"nullableFloatField":1.57000005,"doubleField":1.414,"nullableDoubleField":0.707,"booleanField":false,"nullableBooleanField":true,"enumField":"TWO","arrayField":["x","y","z"],"nullableArrayField":[10,20,30],"nullableEnumField":"FOUR","decimalField":7890.12,"complexArrayField":[{"itemFieldOne":2,"itemFieldTwo":"another"}],"multiNestedRecord":{"nestedLevelOne":{"levelOneField":"nestedLevel1","nestedLevelTwo":{"levelTwoField":20}}},"nullableComplexArrayField":[{"nullableItemFieldOne":3.5,"nullableItemFieldTwo":true}],"nestedRecord":{"nestedStringField":"nestedExample","nestedIntField":15,"nestedArrayField":[4.4,5.5]},"nullableNestedRecord":{"nullableNestedStringField":"nullable","nullableNestedLongField":5.67890123456E11}},{"uuidField":"123e4567-e89b-12d3-a456-426614174000","timestampMillisField":"2023-08-08T17:29:39.000Z","nullableTimestampMillisField":null,"timestampMicrosField":"2023-08-08T17:29:39.000Z","nullableTimestampMicrosField":null,"dateField":"2020-01-01","nullableDateField":null,"timeMillisField":"23:59:59","nullableTimeMillisField":null,"timeMicrosField":"23:59:59","nullableTimeMicrosField":null,"stringField":"example","nullableStringField":null,"intField":42,"nullableIntField":null,"longField":1.23456789012345E14,"nullableLongField":null,"floatField":3.1400001,"nullableFloatField":null,"doubleField":2.718,"nullableDoubleField":null,"booleanField":true,"nullableBooleanField":null,"enumField":"ONE","arrayField":["a","b","c"],"nullableArrayField":null,"nullableEnumField":null,"decimalField":1234.56,"complexArrayField":[{"itemFieldOne":1,"itemFieldTwo":"example"}],"multiNestedRecord":{"nestedLevelOne":{"levelOneField":"level1","nestedLevelTwo":{"levelTwoField":10}}},"nullableComplexArrayField":null,"nestedRecord":{"nestedStringField":"nested","nestedIntField":5,"nestedArrayField":[1.1,2.2,3.3]},"nullableNestedRecord":null}]}} \ No newline at end of file diff --git a/sqrl-testing/sqrl-integration-tests/src/test/resources/usecases/avro-schema/tests-avro-schema/MySchemaQuery.graphql b/sqrl-testing/sqrl-integration-tests/src/test/resources/usecases/avro-schema/tests-avro-schema/MySchemaQuery.graphql index d10a84604..365bd5866 100644 --- a/sqrl-testing/sqrl-integration-tests/src/test/resources/usecases/avro-schema/tests-avro-schema/MySchemaQuery.graphql +++ b/sqrl-testing/sqrl-integration-tests/src/test/resources/usecases/avro-schema/tests-avro-schema/MySchemaQuery.graphql @@ -24,6 +24,8 @@ query { booleanField nullableBooleanField enumField + arrayField + nullableArrayField nullableEnumField decimalField complexArrayField { @@ -45,7 +47,7 @@ query { nestedRecord { nestedStringField nestedIntField -# nestedArrayField + nestedArrayField } nullableNestedRecord { nullableNestedStringField @@ -53,8 +55,4 @@ query { } } - - # arrayField - # nullableArrayField - } \ No newline at end of file