Skip to content

[BUG] Script Size Exceeded for Wide-Schema Indices #4597

Closed

Description

@ahkcs

Summary

Queries against wide-schema indices (100+ fields) fail with script size exceeded even when the query references only a few fields. The Calcite engine appears to serialize all index fields into the execution script, causing the generated script to exceed OpenSearch’s 64 KB inline script limit (script.max_size_in_bytes).

Error (example):

java.lang.IllegalArgumentException: exceeded max allowed inline script size in bytes [65535] with size [130362] for script

Steps to Reproduce

  1. Create a wide-schema index (example with 600+ fields):
PUT /wide_schema_index
{
  "mappings": {
    "properties": {
      "@timestamp": { "type": "date" },
      "message":    { "type": "text" }
      // ... 600+ additional fields (attributes.*, metrics.*, tags.*, resource.*)
    }
  }
}
  1. Run a simple PPL query referencing 1–2 fields:
POST /_plugins/_ppl
{
  "query": "source=wide_schema_index | bin @timestamp span=1minute | stats count() by `@timestamp`"
}
  1. Observe the failure:
{
  "error": {
    "reason": "Error occurred in OpenSearch engine: all shards failed",
    "details": "java.lang.IllegalArgumentException: exceeded max allowed inline script size in bytes [65535] with size [130362]"
  }
}

Expected Result

  • Query succeeds, since it references only a small subset of fields.

Actual Result

  • Query fails with script size exceeded because the generated script includes all fields from the index mapping.

Suspected Root Cause

In CalciteLogicalIndexScan.java:

// Current behavior (collects ALL fields)
private Map<String, Map<String, ExprType>> getAllFieldTypes() {
  return table.getRowType().getFieldList().stream()  // returns ALL fields
    .collect(Collectors.toMap(
      field -> field.getName(),
      field -> extractNestedTypes(field.getType())
    ));
}
  • getFieldList() returns the entire schema; all fields are serialized into the execution script, making script size scale with total schema width rather than referenced fields.

Activity

  1. added
    bug
    on Oct 17, 2025
  2. alexey-temnikov commented on Oct 17, 2025

    @alexey-temnikov
    Contributor

    Might be the same as - #4547

  3. added
    PPL
    on Oct 20, 2025
  4. moved this from Not Started to Done in PPL Trackeron Oct 21, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    PPLbug

    Type

    No type

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions