diff --git a/src/integrationTest/java/integration/tests/PreparedStatementTest.java b/src/integrationTest/java/integration/tests/PreparedStatementTest.java index cf3fe02f..93e41441 100644 --- a/src/integrationTest/java/integration/tests/PreparedStatementTest.java +++ b/src/integrationTest/java/integration/tests/PreparedStatementTest.java @@ -466,7 +466,7 @@ void shouldInsertAndSelectComplexStruct() throws SQLException { try (Connection connection = createConnection()) { try (PreparedStatement statement = connection - .prepareStatement("INSERT INTO test_struct_helper(a, b) VALUES (?,?)")) { + .prepareStatement("INSERT INTO test_struct_helper(a, \"b column\") VALUES (?,?)")) { statement.setArray(1, connection.createArrayOf("VARCHAR", car1.getTags())); statement.setTimestamp(2, car1.getTs()); statement.executeUpdate(); @@ -483,11 +483,11 @@ void shouldInsertAndSelectComplexStruct() throws SQLException { .executeQuery("SELECT test_struct FROM test_struct")) { rs.next(); assertEquals(FireboltDataType.STRUCT.name().toLowerCase() - + "(id int, s struct(a array(text null), b timestamp null))", + + "(id int, s struct(a array(text null), `b column` timestamp null))", rs.getMetaData().getColumnTypeName(1).toLowerCase()); String expectedJson = String.format( - "{\"id\":%d,\"s\":{\"a\":[\"%s\",\"%s\"],\"b\":\"%s\"}}", 1, car1.getTags()[0], - car1.getTags()[1], car1.getTs().toString()); + "{\"id\":%d,\"s\":{\"a\":[\"%s\",\"%s\"],\"b column\":\"%s\"}}", 1, car1.getTags()[0], + car1.getTags()[1], car1.getTs().toString()); assertEquals(expectedJson, rs.getString(1)); } } finally { diff --git a/src/integrationTest/resources/statements/prepared-statement-struct/ddl.sql b/src/integrationTest/resources/statements/prepared-statement-struct/ddl.sql index 333f372a..7e2e94d6 100644 --- a/src/integrationTest/resources/statements/prepared-statement-struct/ddl.sql +++ b/src/integrationTest/resources/statements/prepared-statement-struct/ddl.sql @@ -6,5 +6,5 @@ SET prevent_create_on_information_schema=true; SET enable_create_table_with_struct_type=true; DROP TABLE IF EXISTS test_struct; DROP TABLE IF EXISTS test_struct_helper; -CREATE TABLE IF NOT EXISTS test_struct(id int not null, s struct(a array(text) not null, b datetime null) not null); -CREATE TABLE IF NOT EXISTS test_struct_helper(a array(text) not null, b datetime null); +CREATE TABLE IF NOT EXISTS test_struct(id int not null, s struct(a array(text) not null, "b column" datetime null) not null); +CREATE TABLE IF NOT EXISTS test_struct_helper(a array(text) not null, "b column" datetime null); diff --git a/src/test/java/com/firebolt/jdbc/resultset/FireboltResultSetTest.java b/src/test/java/com/firebolt/jdbc/resultset/FireboltResultSetTest.java index 63ae686e..e8db5806 100644 --- a/src/test/java/com/firebolt/jdbc/resultset/FireboltResultSetTest.java +++ b/src/test/java/com/firebolt/jdbc/resultset/FireboltResultSetTest.java @@ -1490,8 +1490,8 @@ void shouldReturnStruct() throws SQLException { assertEquals("{\"a\":\"1\"}", resultSet.getObject("a_struct")); assertEquals("{\"a\":[1,2,3]}", resultSet.getObject(5)); assertEquals("{\"a\":[1,2,3]}", resultSet.getObject("array_struct")); - assertEquals("{\"x\":\"2\",\"a\":{\"b\":\"1\",\"c\":\"3\"}}", resultSet.getObject(6)); - assertEquals("{\"x\":\"2\",\"a\":{\"b\":\"1\",\"c\":\"3\"}}", resultSet.getObject("nested_struct")); + assertEquals("{\"x\":\"2\",\"a\":{\"b col\":\"1\",\"c\":\"3\"}}", resultSet.getObject(6)); + assertEquals("{\"x\":\"2\",\"a\":{\"b col\":\"1\",\"c\":\"3\"}}", resultSet.getObject("nested_struct")); // Returns native JDBC type for (int i = 2; i <= 6; i++) { assertEquals(Types.VARCHAR, resultSet.getMetaData().getColumnType(i)); @@ -1501,7 +1501,7 @@ void shouldReturnStruct() throws SQLException { assertEquals("STRUCT(A INT)", resultSet.getMetaData().getColumnTypeName(3)); assertEquals("STRUCT(A INT)", resultSet.getMetaData().getColumnTypeName(4)); assertEquals("STRUCT(A ARRAY(INT))", resultSet.getMetaData().getColumnTypeName(5)); - assertEquals("STRUCT(X INT, A STRUCT(B INT, C INT))", resultSet.getMetaData().getColumnTypeName(6)); + assertEquals("STRUCT(X INT, A STRUCT(`B COL` INT, C INT))", resultSet.getMetaData().getColumnTypeName(6)); } @Test diff --git a/src/test/resources/responses/firebolt-response-with-struct-nofalse b/src/test/resources/responses/firebolt-response-with-struct-nofalse index b706be02..7b55faf3 100644 --- a/src/test/resources/responses/firebolt-response-with-struct-nofalse +++ b/src/test/resources/responses/firebolt-response-with-struct-nofalse @@ -1,4 +1,4 @@ id null_struct an_empty_struct a_struct array_struct nested_struct -Int64 struct(a int null) struct(a int) struct(a int) struct(a array(int)) struct(x int, a struct(b int, c int)) -1 {"a":null} {"a":"1"} {"a":[1,2,3]} {"x":"2","a":{"b":"1","c":"3"}} -2 {"a":null} {"a":"2"} {"a":[1,2,3]} {"x":"2","a":{"b":"1","c":"3"}} +Int64 struct(a int null) struct(a int) struct(a int) struct(a array(int)) struct(x int, a struct(`b col` int, c int)) +1 {"a":null} {"a":"1"} {"a":[1,2,3]} {"x":"2","a":{"b col":"1","c":"3"}} +2 {"a":null} {"a":"2"} {"a":[1,2,3]} {"x":"2","a":{"b col":"1","c":"3"}}