cryptoe commented on code in PR #14900:
URL: https://github.com/apache/druid/pull/14900#discussion_r1345648332
##########
extensions-core/multi-stage-query/src/test/java/org/apache/druid/msq/exec/MSQInsertTest.java:
##########
@@ -1463,6 +1464,193 @@ public void testInsertArraysAutoType() throws
IOException
.verifyResults();
}
+ @Test
+ public void testInsertArrays() throws IOException
+ {
+ List<Object[]> expectedRows = Arrays.asList(
+ new Object[]{
+ 1672531200000L,
+ null,
+ null,
+ new Object[]{1L, 2L, 3L},
+ new Object[]{},
+ new Object[]{1.1d, 2.2d, 3.3d},
+ null
+ },
+ new Object[]{
+ 1672531200000L,
+ null,
+ Arrays.asList("a", "b"),
+ null,
+ new Object[]{2L, 3L},
+ null,
+ new Object[]{null}
+ },
+ new Object[]{
+ 1672531200000L,
+ Arrays.asList("a", "b"),
+ null,
+ null,
+ new Object[]{null, 2L, 9L},
+ null,
+ new Object[]{999.0d, 5.5d, null}
+ },
+ new Object[]{
+ 1672531200000L,
+ Arrays.asList("a", "b"),
+ Arrays.asList("a", "b"),
+ new Object[]{1L, 2L, 3L},
+ new Object[]{1L, null, 3L},
+ new Object[]{1.1d, 2.2d, 3.3d},
+ new Object[]{1.1d, 2.2d, null}
+ },
+ new Object[]{
+ 1672531200000L,
+ Arrays.asList("a", "b", "c"),
+ Arrays.asList(null, "b"),
+ new Object[]{2L, 3L},
+ null,
+ new Object[]{3.3d, 4.4d, 5.5d},
+ new Object[]{999.0d, null, 5.5d}
+ },
+ new Object[]{
+ 1672531200000L,
+ Arrays.asList("b", "c"),
+ Arrays.asList("d", null, "b"),
+ new Object[]{1L, 2L, 3L, 4L},
+ new Object[]{1L, 2L, 3L},
+ new Object[]{1.1d, 3.3d},
+ new Object[]{null, 2.2d, null}
+ },
+ new Object[]{
+ 1672531200000L,
+ Arrays.asList("d", "e"),
+ Arrays.asList("b", "b"),
+ new Object[]{1L, 4L},
+ new Object[]{1L},
+ new Object[]{2.2d, 3.3d, 4.0d},
+ null
+ },
+ new Object[]{
+ 1672617600000L,
+ null,
+ null,
+ new Object[]{1L, 2L, 3L},
+ null,
+ new Object[]{1.1d, 2.2d, 3.3d},
+ new Object[]{}
+ },
+ new Object[]{
+ 1672617600000L,
+ null,
+ Arrays.asList("a", "b"),
+ null,
+ new Object[]{2L, 3L},
+ null,
+ new Object[]{null, 1.1d}
+ },
+ new Object[]{
+ 1672617600000L,
+ Arrays.asList("a", "b"),
+ null,
+ null,
+ new Object[]{null, 2L, 9L},
+ null,
+ new Object[]{999.0d, 5.5d, null}
+ },
+ new Object[]{
+ 1672617600000L,
+ Arrays.asList("a", "b"),
+ Collections.emptyList(),
+ new Object[]{1L, 2L, 3L},
+ new Object[]{1L, null, 3L},
+ new Object[]{1.1d, 2.2d, 3.3d},
+ new Object[]{1.1d, 2.2d, null}
+ },
+ new Object[]{
+ 1672617600000L,
+ Arrays.asList("a", "b", "c"),
+ Arrays.asList(null, "b"),
+ new Object[]{2L, 3L},
+ null,
+ new Object[]{3.3d, 4.4d, 5.5d},
+ new Object[]{999.0d, null, 5.5d}
+ },
+ new Object[]{
+ 1672617600000L,
+ Arrays.asList("b", "c"),
+ Arrays.asList("d", null, "b"),
+ new Object[]{1L, 2L, 3L, 4L},
+ new Object[]{1L, 2L, 3L},
+ new Object[]{1.1d, 3.3d},
+ new Object[]{null, 2.2d, null}
+ },
+ new Object[]{
+ 1672617600000L,
+ Arrays.asList("d", "e"),
+ Arrays.asList("b", "b"),
+ new Object[]{1L, 4L},
+ new Object[]{null},
+ new Object[]{2.2d, 3.3d, 4.0},
+ null
+ }
+ );
+
+ RowSignature rowSignatureWithoutTimeAndStringColumns =
+ RowSignature.builder()
+ .add("arrayLong", ColumnType.LONG_ARRAY)
+ .add("arrayLongNulls", ColumnType.LONG_ARRAY)
+ .add("arrayDouble", ColumnType.DOUBLE_ARRAY)
+ .add("arrayDoubleNulls", ColumnType.DOUBLE_ARRAY)
+ .build();
+
+
+ RowSignature fileSignature = RowSignature.builder()
+ .add("timestamp",
ColumnType.STRING)
+ .add("arrayString",
ColumnType.STRING_ARRAY)
+ .add("arrayStringNulls",
ColumnType.STRING_ARRAY)
+
.addAll(rowSignatureWithoutTimeAndStringColumns)
+ .build();
+
+ // MSQ writes strings instead of string arrays
+ RowSignature rowSignature = RowSignature.builder()
+ .add("__time", ColumnType.LONG)
+ .add("arrayString",
ColumnType.STRING)
+ .add("arrayStringNulls",
ColumnType.STRING)
+
.addAll(rowSignatureWithoutTimeAndStringColumns)
+ .build();
+
+ final Map<String, Object> adjustedContext = new HashMap<>(context);
+ final File tmpFile = temporaryFolder.newFile();
+ final InputStream resourceStream =
NestedDataTestUtils.class.getClassLoader().getResourceAsStream(NestedDataTestUtils.ARRAY_TYPES_DATA_FILE);
Review Comment:
Since this method will run multiple times due to parametrized tests, we can
consider writing this file only once. Maybe in a static method but that can be
done in a follow up PR.
Thank you for adding this test though.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]