Skip to content

[Bug] timechart command with zero span throws execution exception #4527

Closed

Description

@dai-chen

I quick tested timechart command and found negative span value is not allowed in our grammar. But zero-span validation is missing. Let me create an issue and raise separate PR to fix.

opensearchsql> source=test_data_2023 | timechart span=0m per_second(packets);
TransportError(500, 'SearchPhaseExecutionException', {'error': 
{'reason':'Error occurred in OpenSearch engine: all shards failed', 'details': 'Shard[0]:
  java.lang.IllegalArgumentException: Zero or negative time interval not supported\n\n
    For more details, please send request for Json format to see the raw response from OpenSearch engine.',
      'type': 'SearchPhaseExecutionException'}, 'status': 400})

opensearchsql> source=test_data_2023 | timechart span=-1m per_second(packets);
{'reason': 'Invalid Query', 'details': "[-] is not a valid term at this part of the query: '...23
  | timechart span=-' <-- HERE. extraneous input '-' expecting {SPANLENGTH, INTEGER_LITERAL}",
    'type': 'SyntaxCheckException'}

Originally posted by @dai-chen in #4464 (comment)

Activity

  1. dai-chen commented on Oct 13, 2025

    @dai-chen
    CollaboratorAuthor

    Exception:

    Caused by: java.lang.IllegalArgumentException: Zero or negative time interval not supported
            at org.opensearch.common.Rounding$Builder.<init>(Rounding.java:380)
            at org.opensearch.common.Rounding.builder(Rounding.java:356)
            at org.opensearch.search.aggregations.bucket.histogram.DateIntervalWrapper.createRounding(DateIntervalWrapper.java:300)
            at org.opensearch.search.aggregations.bucket.composite.DateHistogramValuesSourceBuilder.innerBuild(DateHistogramValuesSourceBuilder.java:346)
            at org.opensearch.search.aggregations.bucket.composite.CompositeValuesSourceBuilder.build(CompositeValuesSourceBuilder.java:337)
            at org.opensearch.search.aggregations.bucket.composite.CompositeAggregationBuilder.doBuild(CompositeAggregationBuilder.java:296)
    ...
    
  2. added
    bug
    PPL
    on Oct 13, 2025
  3. self-assigned this
    on Oct 17, 2025
  4. moved this from Not Started to Done in PPL Trackeron Oct 20, 2025
  5. moved this from Done to In review in PPL Trackeron Oct 20, 2025
  6. moved this from In review 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

Labels

PPLbug

Type

No type

Projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions