clintropolis commented on a change in pull request #11884:
URL: https://github.com/apache/druid/pull/11884#discussion_r744025968
##########
File path:
processing/src/main/java/org/apache/druid/segment/RowBasedColumnSelectorFactory.java
##########
@@ -340,9 +330,67 @@ public Class classOfObject()
@Override
public void inspectRuntimeShape(RuntimeShapeInspector inspector)
{
- inspector.visit("row", supplier);
+ inspector.visit("row", rowSupplier);
inspector.visit("extractionFn", extractionFn);
}
+
+ private void updateCurrentValues()
+ {
+ if (rowIdSupplier == null || rowIdSupplier.getAsLong() != currentId)
{
+ try {
+ final Object rawValue = dimFunction.apply(rowSupplier.get());
+
+ if (rawValue == null || rawValue instanceof String) {
+ final String s = NullHandling.emptyToNullIfNeeded((String)
rawValue);
+
+ if (extractionFn == null) {
+ dimensionValues = Collections.singletonList(s);
+ } else {
+ dimensionValues =
Collections.singletonList(extractionFn.apply(s));
+ }
+ } else if (rawValue instanceof List) {
+ // Consistent behavior with Rows.objectToStrings, but applies
extractionFn too.
+ //noinspection rawtypes
+ final List<String> values = new ArrayList<>(((List)
rawValue).size());
+
+ //noinspection rawtypes
+ for (final Object item : ((List) rawValue)) {
+ // Behavior with null item is to convert it to string
"null". This is not what most other areas of Druid
+ // would do when treating a null as a string, but it's
consistent with Rows.objectToStrings, which is
+ // commonly used when retrieving strings from input-row-like
objects.
+ if (extractionFn == null) {
+
values.add(NullHandling.emptyToNullIfNeeded(String.valueOf(item)));
Review comment:
heh, i've never paid close attention to this, so that means `null`
becomes `"null"` but `""` becomes `null`? but only if it is a list of strings,
not a single string...
I don't think this needs done now, but I can't help but wonder if things
that want this transformation to happen should like provide a mechanism to make
it happen so that it isn't implicit functionality of the row selector stuff
--
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]