I find that pinot cannot do ```WHERE json_extract_...
# troubleshooting
s
I find that pinot cannot do
Copy code
WHERE json_extract_scalar(some_column, "$.some_field", 'String', 'null') = some_other_string_col
But I am not sure why. Is that a pinot limitation? the error messages are not descriptive
Copy code
Caught exception while doing operator: class org.apache.pinot.core.operator.query.SelectionOnlyOperator on segment some_segment: For input string: "null"
m
@Raghvendra Yadav ^^
r
@Samuel Papin can you please paste the complete exception ?
s
This is all that showed on the pinot controller
m
Check broker, where the query is actually compiled?
Also, unrelated, you are probably aware (but this is a common pitfall), for production querying use Pinot broker, not controller.
s
I am not sure I have access to the broker logs. let me look
Found logs. same message
r
@Samuel Papin You should have complete exception in server logs.
s
Copy code
Caught exception while processing query: QueryContext{_tableName='[TABLE]_OFFLINE', _subquery=null, _selectExpressions=[$segmentName], _distinct=true, _aliasList=[null],      
  _filter=(eventMetaTypeId = '[ID]' AND eventTypeInnerId = '[ID]' AND (minus(indexedString0,jsonextractscalar(properties,'$.[PROPERTY]','String','null')) != '0'), _groupByExpressions=null, _havingFilter=null, _orderByExpressions=null,         
  _limit=1000000, _offset=0, _queryOptions={timeoutMs=59987}, _expressionOverrideHints={}, _explain=NONE} [SERVER_NAME] 0 [INTERNAL_HOST] [HASH] 2026-03-19 20:22:28.000
and then we have
Copy code
2026-03-23 16:06:19.700 ddb11638-1376-4e5d-b3bd-c45ca78b0f59 iad03 server Caused by: java.lang.NumberFormatException: For input string: "some_string" [server_url] 2026-03-19 20:19:14.000
where "some_string" is the value in the jsonextractscalar I think. I am not sure if the
minus
is forcing it to be interpreted as a number?
r
Thanks for sharing the exception. Pinot’s SQL layer rewrites json_extract_scalar(...) = <column> into minus(json_extract_scalar(...), <column>) = 0 when the right-hand side is not a literal, so the filter is evaluated as numeric subtraction, not string equality. Because of that rewrite, this shape of query does not behave like a plain string compare on json_extract_scalar. To avoid the minus form, put a literal on the RHS (e.g. compare to a fixed string), or use a boolean wrapper such as equals(json_extract_scalar(...), col) = true so the outer predicate still has a literal on the right.
s
But I want to compare the json field to a string column.
basically to make sure they are always same, otherwise It's a signal to reindex that data
r
Can you try following "WHERE equals( json_extract_scalar(tags, '$.sf_environment', 'STRING', 'null'), data_type ) = true"
s
let me try
Copy code
equals(
    json_extract_scalar(
      properties,
      '$.string_property',
      'String',
      'null'
    ), otherStringColumn
  ) = true
is failing with the same error.
r
Let me try locally and get back to you in some time.
@Samuel Papin Can you please also elaborate what are trying to achieve at high level? It would help me explore alternatives if required.
m
I can fill you in on that so that Samuel doesn't have to repeat
thanks 1
s
Back to you on this.
Copy code
equals(
    json_extract_scalar(
      properties,
      '$.string_property',
      'String',
      'null'
    ), otherStringColumn
  ) = true
Is now working as intended 🤷. What do you think about updating the minus rewrite to the equals(A,B) = true format? I don't think it would lose performance, would it?
r
@Samuel Papin there should not be a perf hit.
s
Ok. I made https://github.com/apache/pinot/pull/18587 with this change, for your consideration. lmk if that's the right way to contribute
r
@Samuel Papin Above changes are merged as well.
🍷 1