Skip to content
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions docs/changelog/136448.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
pr: 136448
summary: Add `m` alias for `minute` duration literal
area: ES|QL
type: enhancement
issues:
- 135552
2 changes: 1 addition & 1 deletion docs/reference/query-languages/esql/esql-time-spans.md
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ POST /_query
| week | w, weeks |
| day | d, days |
| hour | h, hours |
| minute | min, minutes |
| minute | m, min, minutes |
| second | s, sec, seconds |
| millisecond | ms, milliseconds |

Original file line number Diff line number Diff line change
Expand Up @@ -255,11 +255,12 @@ errors:long | day:datetime | message:keyword
keepWildcardBeforeStats
required_capability: implicit_casting_string_literal_to_temporal_amount
required_capability: tbucket
required_capability: temporal_amount_m

FROM sample_data
| WHERE client_ip IS NOT NULL
| KEEP *stamp*, client_ip, event_duration
| STATS p95 = PERCENTILE(event_duration, 95) BY ten_min = TBUCKET(10min), client_ip
| STATS p95 = PERCENTILE(event_duration, 95) BY ten_min = TBUCKET(10m), client_ip
;
ignoreOrder:true

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1499,7 +1499,12 @@ public enum Cap {
/**
* Support for dots in FUSE attributes
*/
DOTS_IN_FUSE;
DOTS_IN_FUSE,

/**
* Support for the literal {@code m} suffix as an alias for {@code minute} in temporal amounts.
*/
TEMPORAL_AMOUNT_M;

private final boolean enabled;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,7 @@ public enum INTERVALS {
MINUTE,
MINUTES,
MIN,
M,
HOUR,
HOURS,
H,
Expand Down Expand Up @@ -488,7 +489,7 @@ public static TemporalAmount parseTemporalAmount(Number value, String temporalUn
return switch (INTERVALS.valueOf(temporalUnit.toUpperCase(Locale.ROOT))) {
case MILLISECOND, MILLISECONDS, MS -> Duration.ofMillis(safeToLong(value));
case SECOND, SECONDS, SEC, S -> Duration.ofSeconds(safeToLong(value));
case MINUTE, MINUTES, MIN -> Duration.ofMinutes(safeToLong(value));
case MINUTE, MINUTES, MIN, M -> Duration.ofMinutes(safeToLong(value));
case HOUR, HOURS, H -> Duration.ofHours(safeToLong(value));

case DAY, DAYS, D -> Period.ofDays(safeToInt(safeToLong(value)));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -392,6 +392,7 @@ public void testDurationLiterals() {
assertEquals(l(Duration.ofMinutes(value), TIME_DURATION), whereExpression(value + "minute"));
assertEquals(l(Duration.ofMinutes(value), TIME_DURATION), whereExpression(value + " minutes"));
assertEquals(l(Duration.ofMinutes(value), TIME_DURATION), whereExpression(value + " min"));
assertEquals(l(Duration.ofMinutes(value), TIME_DURATION), whereExpression(value + " m"));

assertEquals(l(Duration.ZERO, TIME_DURATION), whereExpression("0 hour"));
assertEquals(l(Duration.ofHours(value), TIME_DURATION), whereExpression(value + "hour"));
Expand Down
Loading