@@ -1581,4 +1581,258 @@ x:date | y:date
15811581
15821582;
15831583
1584+ evalDateTruncMonthIntervalWithGTEInRange
1585+ FROM employees
1586+ | SORT hire_date
1587+ | WHERE hire_date >= "1990-01-01"
1588+ | EVAL x = date_trunc(1 month, hire_date)
1589+ | KEEP emp_no, hire_date, x
1590+ | LIMIT 5;
1591+
1592+ emp_no:integer | hire_date:date | x:date
1593+ 10082 | 1990-01-03T00:00:00.000Z | 1990-01-01T00:00:00.000Z
1594+ 10096 | 1990-01-14T00:00:00.000Z | 1990-01-01T00:00:00.000Z
1595+ 10011 | 1990-01-22T00:00:00.000Z | 1990-01-01T00:00:00.000Z
1596+ 10056 | 1990-02-01T00:00:00.000Z | 1990-02-01T00:00:00.000Z
1597+ 10086 | 1990-02-16T00:00:00.000Z | 1990-02-01T00:00:00.000Z
1598+ ;
1599+
1600+ evalDateTruncHoursIntervalWithLTEInRange
1601+ FROM employees
1602+ | SORT hire_date desc
1603+ | WHERE hire_date <= "1990-01-01"
1604+ | EVAL x = date_trunc(240 hours, hire_date)
1605+ | KEEP emp_no, hire_date, x
1606+ | LIMIT 5;
1607+
1608+ emp_no:integer | hire_date:date | x:date
1609+ 10023 | 1989-12-17T00:00:00.000Z | 1989-12-17T00:00:00.000Z
1610+ 10041 | 1989-11-12T00:00:00.000Z | 1989-11-07T00:00:00.000Z
1611+ 10069 | 1989-11-05T00:00:00.000Z | 1989-10-28T00:00:00.000Z
1612+ 10092 | 1989-09-22T00:00:00.000Z | 1989-09-18T00:00:00.000Z
1613+ 10038 | 1989-09-20T00:00:00.000Z | 1989-09-18T00:00:00.000Z
1614+ ;
1615+
1616+ evalDateTruncWeeklyIntervalWithLTGTInRange
1617+ from employees
1618+ | SORT hire_date
1619+ | WHERE hire_date > "1986-01-01" and hire_date < "1988-01-01"
1620+ | EVAL x = date_trunc(1 week, hire_date)
1621+ | KEEP emp_no, hire_date, x
1622+ | LIMIT 5;
1623+
1624+ emp_no:integer | hire_date:date | x:date
1625+ 10053 | 1986-02-04T00:00:00.000Z | 1986-02-03T00:00:00.000Z
1626+ 10066 | 1986-02-26T00:00:00.000Z | 1986-02-24T00:00:00.000Z
1627+ 10090 | 1986-03-14T00:00:00.000Z | 1986-03-10T00:00:00.000Z
1628+ 10079 | 1986-03-27T00:00:00.000Z | 1986-03-24T00:00:00.000Z
1629+ 10001 | 1986-06-26T00:00:00.000Z | 1986-06-23T00:00:00.000Z
1630+ ;
1631+
1632+ evalDateTruncQuarterlyIntervalWithGTInRange
1633+ from employees
1634+ | SORT hire_date
1635+ | WHERE hire_date > "1980-01-01"
1636+ | EVAL x = date_trunc(3 month, hire_date)
1637+ | KEEP emp_no, hire_date, x
1638+ | LIMIT 5;
1639+
1640+ emp_no:integer | hire_date:date | x:date
1641+ 10009 | 1985-02-18T00:00:00.000Z | 1985-01-01T00:00:00.000Z
1642+ 10048 | 1985-02-24T00:00:00.000Z | 1985-01-01T00:00:00.000Z
1643+ 10098 | 1985-05-13T00:00:00.000Z | 1985-04-01T00:00:00.000Z
1644+ 10076 | 1985-07-09T00:00:00.000Z | 1985-07-01T00:00:00.000Z
1645+ 10061 | 1985-09-17T00:00:00.000Z | 1985-07-01T00:00:00.000Z
1646+ ;
1647+
1648+ dateTruncGroupingYearIntervalWithLTInRange
1649+ from employees
1650+ | WHERE hire_date < "2025-01-01"
1651+ | EVAL y = date_trunc(1 year, hire_date)
1652+ | stats c = count(emp_no) by y
1653+ | SORT y
1654+ | KEEP y, c
1655+ | LIMIT 5;
1656+
1657+ y:date | c:long
1658+ 1985-01-01T00:00:00.000Z | 11
1659+ 1986-01-01T00:00:00.000Z | 11
1660+ 1987-01-01T00:00:00.000Z | 15
1661+ 1988-01-01T00:00:00.000Z | 9
1662+ 1989-01-01T00:00:00.000Z | 13
1663+ ;
1664+
1665+ dateTruncGroupingYearIntervalWithLTOutOfRange
1666+ from employees
1667+ | WHERE hire_date < "1980-01-01"
1668+ | EVAL y = date_trunc(1 year, hire_date)
1669+ | stats c = count(emp_no) by y
1670+ | SORT y
1671+ | KEEP y, c
1672+ | LIMIT 5;
1673+
1674+ y:date | c:long
1675+ ;
1676+
1677+ dateTruncGroupingYearIntervalWithGTOutOfRange
1678+ from employees
1679+ | WHERE hire_date > "2000-01-01"
1680+ | EVAL y = date_trunc(1 year, hire_date)
1681+ | stats c = count(emp_no) by y
1682+ | SORT y
1683+ | KEEP y, c
1684+ | LIMIT 5;
1685+
1686+ y:date | c:long
1687+ ;
15841688
1689+ dateTruncGroupingMonthIntervalWithLTGTInRange
1690+ from employees
1691+ | WHERE hire_date > "1987-01-01" and hire_date < "1988-01-01"
1692+ | EVAL y = date_trunc(1 month, hire_date)
1693+ | stats c = count(emp_no) by y
1694+ | SORT y
1695+ | KEEP y, c
1696+ | LIMIT 5;
1697+
1698+ y:date | c:long
1699+ 1987-03-01T00:00:00.000Z | 5
1700+ 1987-04-01T00:00:00.000Z | 3
1701+ 1987-05-01T00:00:00.000Z | 1
1702+ 1987-07-01T00:00:00.000Z | 1
1703+ 1987-08-01T00:00:00.000Z | 2
1704+ ;
1705+
1706+ dateTruncGroupingDayIntervalWithEQInRange
1707+ from employees
1708+ | WHERE hire_date == "1988-02-10"
1709+ | EVAL y = date_trunc(1 day, hire_date)
1710+ | stats c = count(emp_no) by y
1711+ | SORT y
1712+ | KEEP y, c
1713+ | LIMIT 5;
1714+
1715+ y:date | c:long
1716+ 1988-02-10T00:00:00.000Z | 1
1717+ ;
1718+
1719+ dateTruncGroupingDayIntervalWithEQOutOfRange
1720+ from employees
1721+ | WHERE hire_date == "2025-01-01"
1722+ | EVAL y = date_trunc(1 day, hire_date)
1723+ | stats c = count(emp_no) by y
1724+ | SORT y
1725+ | KEEP y, c
1726+ | LIMIT 5;
1727+
1728+ y:date | c:long
1729+ ;
1730+
1731+ dateTruncWithEval
1732+ from employees
1733+ | EVAL x = hire_date
1734+ | WHERE x > "1987-01-01" and hire_date < "1988-01-01"
1735+ | EVAL y = date_trunc(1 month, x)
1736+ | STATS c = count(emp_no) by y
1737+ | SORT y
1738+ | KEEP y, c
1739+ | LIMIT 5;
1740+
1741+ y:date | c:long
1742+ 1987-03-01T00:00:00.000Z | 5
1743+ 1987-04-01T00:00:00.000Z | 3
1744+ 1987-05-01T00:00:00.000Z | 1
1745+ 1987-07-01T00:00:00.000Z | 1
1746+ 1987-08-01T00:00:00.000Z | 2
1747+ ;
1748+
1749+ dateTruncWithEvalExpression
1750+ from employees
1751+ | EVAL x = hire_date + 1 year
1752+ | WHERE x > "1987-01-01" and x < "1988-01-01"
1753+ | EVAL y = date_trunc(1 month, x)
1754+ | STATS c = count(emp_no) by y
1755+ | SORT y
1756+ | KEEP y, c
1757+ | LIMIT 5;
1758+
1759+ y:date | c:long
1760+ 1987-02-01T00:00:00.000Z | 2
1761+ 1987-03-01T00:00:00.000Z | 2
1762+ 1987-06-01T00:00:00.000Z | 1
1763+ 1987-07-01T00:00:00.000Z | 1
1764+ 1987-08-01T00:00:00.000Z | 2
1765+ ;
1766+
1767+ dateTruncWithRename
1768+ FROM employees
1769+ | RENAME hire_date as x
1770+ | WHERE x > "1987-01-01" and x < "1988-01-01"
1771+ | EVAL y = date_trunc(1 month, x)
1772+ | STATS c = count(emp_no) by y
1773+ | SORT y
1774+ | KEEP y, c
1775+ | LIMIT 5;
1776+
1777+ y:date | c:long
1778+ 1987-03-01T00:00:00.000Z | 5
1779+ 1987-04-01T00:00:00.000Z | 3
1780+ 1987-05-01T00:00:00.000Z | 1
1781+ 1987-07-01T00:00:00.000Z | 1
1782+ 1987-08-01T00:00:00.000Z | 2
1783+ ;
1784+
1785+ dateTruncWithRenameChain
1786+ FROM employees
1787+ | RENAME hire_date as a, a as x
1788+ | WHERE x > "1987-01-01" and x < "1988-01-01"
1789+ | EVAL y = date_trunc(1 month, x)
1790+ | STATS c = count(emp_no) by y
1791+ | SORT y
1792+ | KEEP y, c
1793+ | LIMIT 5;
1794+
1795+ y:date | c:long
1796+ 1987-03-01T00:00:00.000Z | 5
1797+ 1987-04-01T00:00:00.000Z | 3
1798+ 1987-05-01T00:00:00.000Z | 1
1799+ 1987-07-01T00:00:00.000Z | 1
1800+ 1987-08-01T00:00:00.000Z | 2
1801+ ;
1802+
1803+ dateTruncWithRenameBack
1804+ FROM employees
1805+ | RENAME hire_date as x, x as hire_date
1806+ | WHERE hire_date > "1987-01-01" and hire_date < "1988-01-01"
1807+ | EVAL y = date_trunc(1 month, hire_date)
1808+ | STATS c = count(emp_no) by y
1809+ | SORT y
1810+ | KEEP y, c
1811+ | LIMIT 5;
1812+
1813+ y:date | c:long
1814+ 1987-03-01T00:00:00.000Z | 5
1815+ 1987-04-01T00:00:00.000Z | 3
1816+ 1987-05-01T00:00:00.000Z | 1
1817+ 1987-07-01T00:00:00.000Z | 1
1818+ 1987-08-01T00:00:00.000Z | 2
1819+ ;
1820+
1821+ dateTruncWithEvalRename
1822+ FROM employees
1823+ | EVAL a = hire_date
1824+ | RENAME hire_date as b
1825+ | WHERE a > "1987-01-01" and a < "1988-01-01"
1826+ | EVAL y = date_trunc(1 month, b)
1827+ | STATS c = count(emp_no) by y
1828+ | SORT y
1829+ | KEEP y, c
1830+ | LIMIT 5;
1831+
1832+ y:date | c:long
1833+ 1987-03-01T00:00:00.000Z | 5
1834+ 1987-04-01T00:00:00.000Z | 3
1835+ 1987-05-01T00:00:00.000Z | 1
1836+ 1987-07-01T00:00:00.000Z | 1
1837+ 1987-08-01T00:00:00.000Z | 2
1838+ ;
0 commit comments