clintropolis commented on code in PR #13732:
URL: https://github.com/apache/druid/pull/13732#discussion_r1095435579
##########
processing/src/main/java/org/apache/druid/segment/virtual/NestedFieldVirtualColumn.java:
##########
@@ -233,20 +245,49 @@ public DimensionSelector makeDimensionSelector(
ReadableOffset offset
)
{
- final NestedDataComplexColumn column =
NestedDataComplexColumn.fromColumnSelector(columnSelector, columnName);
- if (column == null) {
- // complex column itself didn't exist
- return DimensionSelector.constant(null);
+ ColumnHolder holder = columnSelector.getColumnHolder(columnName);
+ if (holder == null) {
+ // column doesn't exist
+ return dimensionSpec.decorate(DimensionSelector.constant(null,
dimensionSpec.getExtractionFn()));
}
if (hasNegativeArrayIndex) {
- return new FieldDimensionSelector(
- new RawFieldLiteralColumnValueSelector(
- column.makeColumnValueSelector(offset),
- parts
- )
- );
+ // if the path has negative array elements, then we have to use the
'raw' processing of the FieldDimensionSelector
+ // created with the column selector factory instead of using the
optimized nested field column, return null
+ // to fall through
+ return null;
}
- return column.makeDimensionSelector(parts, offset,
dimensionSpec.getExtractionFn());
+
+ return dimensionSpec.decorate(makeDimensionSelectorUndecorated(holder,
offset, dimensionSpec.getExtractionFn()));
+ }
+
+ private DimensionSelector makeDimensionSelectorUndecorated(
+ ColumnHolder holder,
+ ReadableOffset offset,
+ @Nullable ExtractionFn extractionFn
+ )
+ {
+ BaseColumn theColumn = holder.getColumn();
+ if (theColumn instanceof NestedDataComplexColumn) {
+ final NestedDataComplexColumn column = (NestedDataComplexColumn)
theColumn;
+ return column.makeDimensionSelector(parts, offset, extractionFn);
+ }
+
+ // ok, so not a nested column, but we can still do stuff
+ if (!parts.isEmpty()) {
+ // we are being asked for a path that will never exist, so we are null
selector
+ return DimensionSelector.constant(null, extractionFn);
+ }
+
+ // the path was the 'root', we're in luck, spit out a selector that
behaves the same way as a nested column
Review Comment:
ah this comment is maybe confusing after i re-arranged some stuff. the
comment is in relation to making it past the last 'if' statement that would
have bailed with a nil selector if we weren't looking for the root path
im checking for a dictionary encoded column here because if so, i want to
wrap it in the auto casting gizmo because the string dimension selectors do not
have that behavior by default. If it is not dictionary encoded, i can just use
the column value selector because it is going to be a numeric column which do
all implement all of the 'get number' methods
i'll admit that this is possibly a bit dependent on the way things currently
are and that the checks might not be adequate in the future. I guess if i flip
this logic around like your other comment suggested i could make these check
explicitly for either numeric columns and use value selector or string
dictionary column and use the wrapped dim selector, else return nil 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]