Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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 @@ -666,7 +666,7 @@ public void testErrorMessageForInvalidIntervalParams() throws IOException {
error,
containsString(
"Invalid interval value in [?n2::time_duration], expected integer followed by one of "
+ "[MILLISECOND, MILLISECONDS, MS, SECOND, SECONDS, SEC, S, MINUTE, MINUTES, MIN, HOUR, HOURS, H] but got [3 days]"
+ "[MILLISECOND, MILLISECONDS, MS, SECOND, SECONDS, SEC, S, MINUTE, MINUTES, MIN, M, HOUR, HOURS, H] but got [3 days]"
)
);

Expand Down
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 @@ -208,6 +209,7 @@ public enum INTERVALS {
INTERVALS.MINUTE,
INTERVALS.MINUTES,
INTERVALS.MIN,
INTERVALS.M,
INTERVALS.HOUR,
INTERVALS.HOURS,
INTERVALS.H
Expand Down Expand Up @@ -488,7 +490,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 @@ -7973,39 +7973,39 @@ public void testToDatePeriodTimeDurationInvalidIntervals() {
from types | EVAL interval = "3 ours", x = date + interval::time_duration"""));
assertEquals(
"Invalid interval value in [interval::time_duration], expected integer followed by one of "
+ "[MILLISECOND, MILLISECONDS, MS, SECOND, SECONDS, SEC, S, MINUTE, MINUTES, MIN, HOUR, HOURS, H] but got [3 ours]",
+ "[MILLISECOND, MILLISECONDS, MS, SECOND, SECONDS, SEC, S, MINUTE, MINUTES, MIN, M, HOUR, HOURS, H] but got [3 ours]",
e.getMessage()
);

e = expectThrows(IllegalArgumentException.class, () -> planTypes("""
from types | EVAL interval = "- 3 hours", x = date + interval::time_duration"""));
assertEquals(
"Invalid interval value in [interval::time_duration], expected integer followed by one of "
+ "[MILLISECOND, MILLISECONDS, MS, SECOND, SECONDS, SEC, S, MINUTE, MINUTES, MIN, HOUR, HOURS, H] but got [- 3 hours]",
+ "[MILLISECOND, MILLISECONDS, MS, SECOND, SECONDS, SEC, S, MINUTE, MINUTES, MIN, M, HOUR, HOURS, H] but got [- 3 hours]",
e.getMessage()
);

e = expectThrows(IllegalArgumentException.class, () -> planTypes("""
from types | EVAL interval = "3 ours", x = date - to_timeduration(interval)"""));
assertEquals(
"Invalid interval value in [to_timeduration(interval)], expected integer followed by one of "
+ "[MILLISECOND, MILLISECONDS, MS, SECOND, SECONDS, SEC, S, MINUTE, MINUTES, MIN, HOUR, HOURS, H] but got [3 ours]",
+ "[MILLISECOND, MILLISECONDS, MS, SECOND, SECONDS, SEC, S, MINUTE, MINUTES, MIN, M, HOUR, HOURS, H] but got [3 ours]",
e.getMessage()
);

e = expectThrows(IllegalArgumentException.class, () -> planTypes("""
from types | EVAL interval = "- 3 hours", x = date - to_timeduration(interval)"""));
assertEquals(
"Invalid interval value in [to_timeduration(interval)], expected integer followed by one of "
+ "[MILLISECOND, MILLISECONDS, MS, SECOND, SECONDS, SEC, S, MINUTE, MINUTES, MIN, HOUR, HOURS, H] but got [- 3 hours]",
+ "[MILLISECOND, MILLISECONDS, MS, SECOND, SECONDS, SEC, S, MINUTE, MINUTES, MIN, M, HOUR, HOURS, H] but got [- 3 hours]",
e.getMessage()
);

e = expectThrows(IllegalArgumentException.class, () -> planTypes("""
from types | EVAL interval = "3.5 hours", x = date - to_timeduration(interval)"""));
assertEquals(
"Invalid interval value in [to_timeduration(interval)], expected integer followed by one of "
+ "[MILLISECOND, MILLISECONDS, MS, SECOND, SECONDS, SEC, S, MINUTE, MINUTES, MIN, HOUR, HOURS, H] but got [3.5 hours]",
+ "[MILLISECOND, MILLISECONDS, MS, SECOND, SECONDS, SEC, S, MINUTE, MINUTES, MIN, M, HOUR, HOURS, H] but got [3.5 hours]",
e.getMessage()
);

Expand All @@ -8029,23 +8029,23 @@ public void testToDatePeriodTimeDurationInvalidIntervals() {
row x = "2024-01-01"::datetime | eval y = x + "3 ours"::time_duration"""));
assertEquals(
"Invalid interval value in [\"3 ours\"::time_duration], expected integer followed by one of "
+ "[MILLISECOND, MILLISECONDS, MS, SECOND, SECONDS, SEC, S, MINUTE, MINUTES, MIN, HOUR, HOURS, H] but got [3 ours]",
+ "[MILLISECOND, MILLISECONDS, MS, SECOND, SECONDS, SEC, S, MINUTE, MINUTES, MIN, M, HOUR, HOURS, H] but got [3 ours]",
e.getMessage()
);

e = expectThrows(IllegalArgumentException.class, () -> planTypes("""
row x = "2024-01-01"::datetime | eval y = x - to_timeduration("3 ours")"""));
assertEquals(
"Invalid interval value in [to_timeduration(\"3 ours\")], expected integer followed by one of "
+ "[MILLISECOND, MILLISECONDS, MS, SECOND, SECONDS, SEC, S, MINUTE, MINUTES, MIN, HOUR, HOURS, H] but got [3 ours]",
+ "[MILLISECOND, MILLISECONDS, MS, SECOND, SECONDS, SEC, S, MINUTE, MINUTES, MIN, M, HOUR, HOURS, H] but got [3 ours]",
e.getMessage()
);

e = expectThrows(IllegalArgumentException.class, () -> planTypes("""
row x = "2024-01-01"::datetime | eval y = x - to_timeduration("3.5 hours")"""));
assertEquals(
"Invalid interval value in [to_timeduration(\"3.5 hours\")], expected integer followed by one of "
+ "[MILLISECOND, MILLISECONDS, MS, SECOND, SECONDS, SEC, S, MINUTE, MINUTES, MIN, HOUR, HOURS, H] but got [3.5 hours]",
+ "[MILLISECOND, MILLISECONDS, MS, SECOND, SECONDS, SEC, S, MINUTE, MINUTES, MIN, M, HOUR, HOURS, H] but got [3.5 hours]",
e.getMessage()
);
}
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