rohangarg commented on code in PR #12834:
URL: https://github.com/apache/druid/pull/12834#discussion_r932950545


##########
processing/src/test/java/org/apache/druid/segment/serde/NullColumnPartSerdeTest.java:
##########
@@ -61,4 +76,128 @@ public void testDeserializer()
     Assert.assertTrue(columnCapabilities.areDictionaryValuesSorted().isTrue());
     Assert.assertTrue(columnCapabilities.areDictionaryValuesUnique().isTrue());
   }
+
+  @Test
+  public void testDimensionSelector()
+  {
+    final NullColumnPartSerde partSerde = new NullColumnPartSerde(10, new 
RoaringBitmapSerdeFactory(null));
+    final ColumnBuilder builder = new 
ColumnBuilder().setType(ValueType.STRING);
+    partSerde.getDeserializer().read(Mockito.mock(ByteBuffer.class), builder, 
Mockito.mock(ColumnConfig.class));
+    ColumnHolder holder = builder.build();
+
+    BaseColumn theColumn = holder.getColumn();
+    Assert.assertTrue(theColumn instanceof DictionaryEncodedColumn);
+    DictionaryEncodedColumn dictionaryEncodedColumn = 
(DictionaryEncodedColumn) theColumn;
+
+    ReadableOffset offset = new SimpleAscendingOffset(10);
+    DimensionSelector dimensionSelector = 
dictionaryEncodedColumn.makeDimensionSelector(
+        offset,
+        null
+    );
+    Assert.assertNull(dimensionSelector.getObject());
+    Assert.assertEquals(1, dimensionSelector.getRow().size());
+    Assert.assertEquals(0, dimensionSelector.getRow().get(0));
+  }
+
+  @Test
+  public void testDimensionVectorSelector()
+  {
+    final NullColumnPartSerde partSerde = new NullColumnPartSerde(10, new 
RoaringBitmapSerdeFactory(null));
+    final ColumnBuilder builder = new 
ColumnBuilder().setType(ValueType.STRING);
+    partSerde.getDeserializer().read(Mockito.mock(ByteBuffer.class), builder, 
Mockito.mock(ColumnConfig.class));
+    ColumnHolder holder = builder.build();
+
+    BaseColumn theColumn = holder.getColumn();
+    Assert.assertTrue(theColumn instanceof DictionaryEncodedColumn);
+    DictionaryEncodedColumn dictionaryEncodedColumn = 
(DictionaryEncodedColumn) theColumn;
+
+    ReadableVectorOffset vectorOffset = new NoFilterVectorOffset(8, 0, 10);
+
+    SingleValueDimensionVectorSelector vectorSelector =
+        
dictionaryEncodedColumn.makeSingleValueDimensionVectorSelector(vectorOffset);
+
+    int[] rowVector = vectorSelector.getRowVector();
+    for (int i = 0; i < vectorOffset.getCurrentVectorSize(); i++) {
+      Assert.assertEquals(0, rowVector[i]);
+      Assert.assertNull(vectorSelector.lookupName(rowVector[i]));
+    }
+
+    Assert.assertThrows(UnsupportedOperationException.class, () -> {
+      
dictionaryEncodedColumn.makeMultiValueDimensionVectorSelector(vectorOffset);

Review Comment:
   Thanks for the clarification, makes sense
   Also, just checked the `NullColumnPartSerde#getDeserializer` sets 
`setHasMultipleValues` as `false` which should never invoke the creation of MVD 
selector. 



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