Skip to content

[BUG] Span millisecond incorrectly converted to microsecond interval #4550

@dai-chen

Description

@dai-chen

What is the bug?

When using span=X milliseconds in timechart commands, the span unit is incorrectly converted to IntervalUnit.MICROSECOND by PlanUtils.spanUnitToIntervalUnit(). The root cause is that the IntervalUnit enum does not include a MILLISECOND value, only MICROSECOND.

How can one reproduce the bug?
Steps to reproduce the behavior:

  1. Execute a PPL query with timechart using millisecond span:
    source=logs | timechart span=500ms count()
  2. The span calculation will use microsecond interval unit instead of millisecond, causing incorrect time bucketing.

What is the expected behavior?

  • IntervalUnit enum should include a MILLISECOND value
  • PlanUtils should correctly convert between SpanUnit.MILLISECOND and IntervalUnit.MILLISECOND

Do you have any additional context?

Impact: This bug also blocks the implementation of millisecond support in the timechart per_* functions (per_second, per_minute, per_hour, per_day). The per_* function transformation logic calculates span width in seconds instead of millisecond, leading to incorrect results when a millisecond span is used.

source=test_data_2023 | timechart span=1ms per_second(packets);
fetched rows / total rows = 5/5
+---------------------+-----------------------+
| @timestamp          | per_second(packets)   |
|---------------------+-----------------------|
| 2023-10-08 10:00:00 | null                  |
| 2023-10-08 10:00:05 | null                  |
| 2023-10-08 10:00:30 | null                  |
| 2023-10-08 10:00:40 | null                  |
| 2023-10-08 10:00:50 | null                  |
+---------------------+-----------------------+

Metadata

Metadata

Assignees

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