-
Notifications
You must be signed in to change notification settings - Fork 3.8k
fix json column isNumeric check to properly consider array element selector types #18948
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -49,6 +49,7 @@ | |
| import org.apache.druid.segment.column.ColumnType; | ||
| import org.apache.druid.segment.column.DictionaryEncodedColumn; | ||
| import org.apache.druid.segment.column.StringEncodingStrategies; | ||
| import org.apache.druid.segment.column.TypeSignature; | ||
| import org.apache.druid.segment.column.TypeStrategies; | ||
| import org.apache.druid.segment.column.TypeStrategy; | ||
| import org.apache.druid.segment.column.ValueType; | ||
|
|
@@ -1043,8 +1044,20 @@ public boolean isNumeric(List<NestedPathPart> path) | |
| if (field instanceof NestedField) { | ||
| final NestedField nestedField = (NestedField) field; | ||
| return getColumnHolder(nestedField.fieldName, nestedField.fieldIndex).getCapabilities().isNumeric(); | ||
| } else if (field instanceof NestedArrayElement) { | ||
| final NestedArrayElement element = (NestedArrayElement) field; | ||
| final TypeSignature<ValueType> elementType = getColumnHolder( | ||
| element.nestedField.fieldName, | ||
| element.nestedField.fieldIndex | ||
| ).getCapabilities().getElementType(); | ||
| if (elementType != null) { | ||
| return elementType.isNumeric(); | ||
| } | ||
| // if element type is null, the field was not an array, so don't consider it as numeric | ||
| return false; | ||
| } | ||
| return true; | ||
| // a non-existent field can be considered numeric via a nil selector | ||
| return field == null; | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. would be more readable if this just returns true (and return false as i commented above). also might be helpful adding explanation like this field doesnt exist, thus we can vectorized....
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I guess i was thinking that if we ever add any other types of path parts here then they will default to 'not numeric' instead of 'numeric' |
||
| } | ||
|
|
||
| @SuppressWarnings("unchecked") | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
would be helpful to add some explanation here say if elementType not derived, we dont know this field is numeric or not... also might be just more readable return false directly after the if statement.