somu-imply commented on code in PR #13934:
URL: https://github.com/apache/druid/pull/13934#discussion_r1138181823


##########
processing/src/test/java/org/apache/druid/segment/UnnestStorageAdapterTest.java:
##########
@@ -245,4 +260,107 @@ private static void assertColumnReadsIdentifier(final 
VirtualColumn column, fina
     MatcherAssert.assertThat(column, 
CoreMatchers.instanceOf(ExpressionVirtualColumn.class));
     Assert.assertEquals("\"" + identifier + "\"", ((ExpressionVirtualColumn) 
column).getExpression());
   }
+
+  @Test
+  public void test_unnest_adapters_with_no_base_filter_active_unnest_filter()
+  {
+
+    Sequence<Cursor> cursorSequence = UNNEST_STORAGE_ADAPTER2.makeCursors(
+        null,
+        UNNEST_STORAGE_ADAPTER2.getInterval(),
+        VirtualColumns.EMPTY,
+        Granularities.ALL,
+        false,
+        null
+    );
+
+    cursorSequence.accumulate(null, (accumulated, cursor) -> {
+      ColumnSelectorFactory factory = cursor.getColumnSelectorFactory();
+
+      DimensionSelector dimSelector = 
factory.makeDimensionSelector(DefaultDimensionSpec.of(OUTPUT_COLUMN_NAME));
+      int count = 0;
+      while (!cursor.isDone()) {
+        Object dimSelectorVal = dimSelector.getObject();
+        if (dimSelectorVal == null) {
+          Assert.assertNull(dimSelectorVal);
+        }
+        cursor.advance();
+        count++;
+      }
+      Assert.assertEquals(1, count);
+      Filter unnestFilter = new SelectorDimFilter(OUTPUT_COLUMN_NAME, "1", 
null).toFilter();
+      VirtualColumn vc = new ExpressionVirtualColumn(
+          OUTPUT_COLUMN_NAME,
+          "\"" + COLUMNNAME + "\"",
+          null,
+          ExprMacroTable.nil()
+      );
+      final String inputColumn = 
UNNEST_STORAGE_ADAPTER2.getUnnestInputIfDirectAccess(vc);
+      Pair<Filter, Filter> filterPair = 
UNNEST_STORAGE_ADAPTER2.computeBaseAndPostUnnestFilters(
+          null,
+          unnestFilter,
+          VirtualColumns.EMPTY,
+          inputColumn,
+          INCREMENTAL_INDEX_STORAGE_ADAPTER.getColumnCapabilities(inputColumn)
+      );
+      SelectorFilter left = ((SelectorFilter) filterPair.lhs);
+      SelectorFilter right = ((SelectorFilter) filterPair.rhs);
+      Assert.assertEquals(inputColumn, left.getDimension());
+      Assert.assertEquals(OUTPUT_COLUMN_NAME, right.getDimension());
+      Assert.assertEquals(right.getValue(), left.getValue());
+      return null;
+    });
+  }
+

Review Comment:
   My goal is to see if the lhs and rhs of filter splitter are correct because 
those are the parts that gets pushed down or to the PostJoinCursor and this 
kind of does that.  I can also validate that the cursor I get after 
`makeCursor` is actually a PostJoinCursor. Atm we do not have a method on the 
cursor to get the filter passed to it so I was calling the method which 
modifies the filters to validate. Thanks for the feedback, I'll try to refactor 
the tests based on the suggestions 



-- 
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]

Reply via email to