You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@druid.apache.org by "github-code-scanning[bot] (via GitHub)" <gi...@apache.org> on 2023/02/14 01:24:59 UTC
[GitHub] [druid] github-code-scanning[bot] commented on a diff in pull request #13799: Now unnest allows bound, in and selector filters on the unnested column
github-code-scanning[bot] commented on code in PR #13799:
URL: https://github.com/apache/druid/pull/13799#discussion_r1105192799
##########
processing/src/test/java/org/apache/druid/segment/UnnestStorageAdapterTest.java:
##########
@@ -249,151 +248,44 @@
unnest 2 rows -> 16 entries also the value cardinality
unnest of unnest -> 16*8 = 128 rows
*/
- Assert.assertEquals(count, 128);
- Assert.assertEquals(dimSelector.getValueCardinality(), 16);
+ Assert.assertEquals(128, count);
+ Assert.assertEquals(16, dimSelector.getValueCardinality());
return null;
});
}
@Test
- public void test_unnest_adapters_with_allowList()
+ public void test_unnest_adapters_basic_with_filter()
{
- final String columnName = "multi-string1";
-
- Sequence<Cursor> cursorSequence = UNNEST_STORAGE_ADAPTER1.makeCursors(
- null,
- UNNEST_STORAGE_ADAPTER1.getInterval(),
+ Filter f = new InDimFilter(OUTPUT_COLUMN_NAME, ImmutableSet.of("1", "3", "5"));
+ Sequence<Cursor> cursorSequence = UNNEST_STORAGE_ADAPTER.makeCursors(
+ f,
+ UNNEST_STORAGE_ADAPTER.getInterval(),
VirtualColumns.EMPTY,
Granularities.ALL,
false,
null
);
+ List<String> expectedResults = Arrays.asList("1", "3", "5");
cursorSequence.accumulate(null, (accumulated, cursor) -> {
ColumnSelectorFactory factory = cursor.getColumnSelectorFactory();
DimensionSelector dimSelector = factory.makeDimensionSelector(DefaultDimensionSpec.of(OUTPUT_COLUMN_NAME));
- ColumnValueSelector valueSelector = factory.makeColumnValueSelector(OUTPUT_COLUMN_NAME);
-
int count = 0;
while (!cursor.isDone()) {
Object dimSelectorVal = dimSelector.getObject();
- Object valueSelectorVal = valueSelector.getObject();
if (dimSelectorVal == null) {
Assert.assertNull(dimSelectorVal);
- } else if (valueSelectorVal == null) {
- Assert.assertNull(valueSelectorVal);
}
+ Assert.assertEquals(expectedResults.get(count), dimSelectorVal.toString());
Review Comment:
## Dereferenced variable may be null
Variable [dimSelectorVal](1) may be null at this access as suggested by [this](2) null guard.
[Show more details](https://github.com/apache/druid/security/code-scanning/4265)
--
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: commits-unsubscribe@druid.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@druid.apache.org
For additional commands, e-mail: commits-help@druid.apache.org