You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[BUG] Script size limit exceeded in PPL queries with temporal functions and aggregations on large schemas #4547
PPL queries combining eval with temporal functions (TIMESTAMP, TIMESTAMPDIFF) and aggregations (stats, top) fail with script size limit error on indices with large schemas (e.g., OCSF 1.1.0 with 618+ fields).
Error:
exceeded max allowed inline script size [65535] with size [202478]
To Reproduce
Query:
source=ocsf-1.1.0-6003
| eval start_time_ts =TIMESTAMP(start_time_dt), time_ts =TIMESTAMP(time_dt), time_diff = TIMESTAMPDIFF(SECOND, start_time_ts, time_ts)
| where time_diff >0
| stats count() by activity_name
| sort - count
| head 5
This is a preliminary analysis and requires further investigation.
Location:RelJsonSerializer.serialize() in opensearch/src/main/java/org/opensearch/sql/opensearch/storage/serde/RelJsonSerializer.java
The serializer includes the entire table schema (rowType) in the script even though the RexNode expression only references 2 fields. For large schemas, this causes massive script bloat.
Most likely, it's caused by field type serialization problem. RelJsonSerializer requires input type's ExprTypes as well.
For now, we serialize scan's rowType field types, which could be a long array. But sometimes script input is a small set of long rowType. We haven't prune unnecessary field types.
The major root cause is exactly the serialization of all field types for current scan rowType during pushdown. Sometimes, if a query doesn't have a project operator to narrow down the schema size, it will still pass a wide schema to RelJsonSerializer to serialize agg or filter script.
We observed that most of RexNode doesn't care about irrelevant fields. i.e. FILTER($z > 1) for scan schema [$a, $b, $c, ... $x, $y, $z]. Considering above situation, we can rewrite the input reference index for the RexNode. For FILTER($z > 1), the original RexInputRef(index=25) can be rewritten to RexInputRef(index=0). Then the required field types to be serialized will be [$z]. The input values are fetched via name. So changing input index doesn't impact the calculation.
Activity
alexey-temnikov commentedon Oct 14, 2025
Reproduction Steps
Here are the steps to reproduce locally:
1. Create Test Index with 300 Fields
2. Insert Sample Data
3. Run PPL Query to Trigger the Bug
Expected Error
Key Observations
start_timeandend_timeRyanL1997 commentedon Oct 14, 2025
Hi @LantaoJin @songkant-aws , could you take a look of this? Thanks!
qianheng-aws commentedon Oct 15, 2025
#4522 should mitigate the size issue but still exceed the threshold by my local test:
May need further enhancement on the script size.
songkant-aws commentedon Oct 15, 2025
Most likely, it's caused by field type serialization problem. RelJsonSerializer requires input type's ExprTypes as well.
For now, we serialize scan's rowType field types, which could be a long array. But sometimes script input is a small set of long rowType. We haven't prune unnecessary field types.
songkant-aws commentedon Oct 21, 2025
The major root cause is exactly the serialization of all field types for current scan rowType during pushdown. Sometimes, if a query doesn't have a project operator to narrow down the schema size, it will still pass a wide schema to RelJsonSerializer to serialize agg or filter script.
We observed that most of RexNode doesn't care about irrelevant fields. i.e.
FILTER($z > 1)for scan schema[$a, $b, $c, ... $x, $y, $z]. Considering above situation, we can rewrite the input reference index for the RexNode. ForFILTER($z > 1), the originalRexInputRef(index=25)can be rewritten toRexInputRef(index=0). Then the required field types to be serialized will be[$z]. The input values are fetched via name. So changing input index doesn't impact the calculation.