Skip to content

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

@ahkcs

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    PPLPiped processing languagebugSomething isn't working

    Type

    No type

    Projects

    Status

    Done

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions