Skip to content

Commit 3552ae3

Browse files
more implicit casting for union typed field in logical plan
1 parent 93615fb commit 3552ae3

File tree

5 files changed

+257
-68
lines changed

5 files changed

+257
-68
lines changed

x-pack/plugin/esql/qa/testFixtures/src/main/resources/union_types.csv-spec

Lines changed: 118 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1640,7 +1640,22 @@ id:integer | name:keyword | count:long
16401640
14 | mmmmm | 2
16411641
;
16421642

1643-
MultiTypedFieldsKeepDropSort
1643+
MultiTypedFieldsEvalKeepSort
1644+
required_capability: implicit_casting_union_typed_numeric_and_date
1645+
1646+
FROM employees, employees_incompatible
1647+
| Eval x = emp_no
1648+
| KEEP x, languages, hire_date, avg_worked_seconds
1649+
| SORT x, hire_date
1650+
| limit 2
1651+
;
1652+
1653+
x:long |languages:integer |hire_date:date_nanos |avg_worked_seconds:unsigned_long
1654+
10001 |2 |1986-06-26T00:00:00.000Z |268728049
1655+
10001 |2 |1986-06-26T00:00:00.000Z |268728049
1656+
;
1657+
1658+
MultiTypedFieldsDropKeepSort
16441659
required_capability: implicit_casting_union_typed_numeric_and_date
16451660

16461661
FROM employees, employees_incompatible
@@ -1655,13 +1670,13 @@ emp_no:long |languages:integer |hire_date:date_nanos |avg_worked_seconds:uns
16551670
10001 |2 |1986-06-26T00:00:00.000Z |268728049
16561671
;
16571672

1658-
MultiTypedFieldsRenameKeep
1673+
MultiTypedFieldsRenameKeepSort
16591674
required_capability: implicit_casting_union_typed_numeric_and_date
16601675

16611676
from employees, employees_incompatible
16621677
| RENAME emp_no as new_emp_no, languages as new_languages, hire_date as new_hire_date, avg_worked_seconds as new_avg_worked_seconds
16631678
| KEEP new_emp_no, new_languages, new_hire_date, new_avg_worked_seconds
1664-
| sort new_emp_no, new_hire_date
1679+
| SORT new_emp_no, new_hire_date
16651680
| limit 2
16661681
;
16671682

@@ -1670,7 +1685,7 @@ new_emp_no:long |new_languages:integer |new_hire_date:date_nanos |new_avg_worked
16701685
10001 |2 |1986-06-26T00:00:00.000Z |268728049
16711686
;
16721687

1673-
MultiTypedFieldsEvalKeepSort
1688+
MultiTypedFieldsDropEvalKeepSort
16741689
required_capability: implicit_casting_union_typed_numeric_and_date
16751690

16761691
FROM employees, employees_incompatible
@@ -1703,3 +1718,102 @@ emp_no:long |hire_date:date_nanos
17031718
10017 | 1993-08-03T00:00:00.000Z
17041719
10017 | 1993-08-03T00:00:00.000Z
17051720
;
1721+
1722+
MultiTypedFieldsStatsByNumeric
1723+
required_capability: implicit_casting_union_typed_numeric_and_date
1724+
1725+
FROM employees, employees_incompatible
1726+
| STATS x=count(emp_no), y=max(hire_date), z=max(height) BY languages
1727+
| SORT languages
1728+
;
1729+
1730+
x:long | y:date_nanos | z:double | languages:integer
1731+
30 | 1999-04-30T00:00:00.000Z | 2.06 | 1
1732+
38 | 1995-01-27T00:00:00.000Z | 2.1 | 2
1733+
34 | 1996-11-05T00:00:00.000Z | 2.1 | 3
1734+
36 | 1995-03-13T00:00:00.000Z | 2.0 | 4
1735+
42 | 1994-04-09T00:00:00.000Z | 2.1 | 5
1736+
20 | 1997-05-19T00:00:00.000Z | 2.1 | null
1737+
;
1738+
1739+
MultiTypedFieldsStatsByDateNanos
1740+
required_capability: implicit_casting_union_typed_numeric_and_date
1741+
1742+
FROM employees, employees_incompatible
1743+
| STATS x=count(emp_no), y=avg(salary_change), z=max(height) BY hire_date
1744+
| Eval y = round(y, 1), z = round(z, 1)
1745+
| KEEP x, y, z, hire_date
1746+
| SORT hire_date
1747+
| LIMIT 5
1748+
;
1749+
1750+
x:long | y:double | z:double | hire_date:date_nanos
1751+
2 | null | 1.9 | 1985-02-18T00:00:00.000Z
1752+
2 | null | 2.0 | 1985-02-24T00:00:00.000Z
1753+
2 | 3.3 | 2.0 | 1985-05-13T00:00:00.000Z
1754+
2 | 0.2 | 1.8 | 1985-07-09T00:00:00.000Z
1755+
2 | 3.6 | 1.5 | 1985-09-17T00:00:00.000Z
1756+
;
1757+
1758+
MultiTypedFieldsWhereMvExpandKeepSortNumeric
1759+
required_capability: implicit_casting_union_typed_numeric_and_date
1760+
1761+
FROM employees, employees_incompatible
1762+
| WHERE emp_no == 10003
1763+
| MV_EXPAND salary_change
1764+
| KEEP emp_no, salary_change
1765+
| EVAL salary_change = round(salary_change, 2)
1766+
| SORT salary_change
1767+
;
1768+
1769+
emp_no:long | salary_change:double
1770+
10003 | 12.82
1771+
10003 | 12.82
1772+
10003 | 14.68
1773+
10003 | 14.68
1774+
;
1775+
1776+
MultiTypedFieldsMvExpandKeepSortNumeric
1777+
required_capability: implicit_casting_union_typed_numeric_and_date
1778+
1779+
FROM employees, employees_incompatible
1780+
| MV_EXPAND salary_change
1781+
| KEEP emp_no, salary_change
1782+
| EVAL salary_change = round(salary_change, 2)
1783+
| SORT emp_no, salary_change
1784+
| LIMIT 10
1785+
;
1786+
1787+
emp_no:long | salary_change:double
1788+
10001 | 1.19
1789+
10001 | 1.19
1790+
10002 | -7.23
1791+
10002 | -7.23
1792+
10002 | 11.17
1793+
10002 | 11.17
1794+
10003 | 12.82
1795+
10003 | 12.82
1796+
10003 | 14.68
1797+
10003 | 14.68
1798+
;
1799+
1800+
MultiTypedFieldsEvalLookupJoinNumeric
1801+
required_capability: join_lookup_v12
1802+
required_capability: implicit_casting_union_typed_numeric_and_date
1803+
1804+
FROM employees, employees_incompatible
1805+
| EVAL language_code = languages
1806+
| LOOKUP JOIN languages_lookup ON language_code
1807+
| WHERE emp_no >= 10091 AND emp_no < 10094
1808+
| KEEP emp_no, language_code, language_name
1809+
| SORT emp_no
1810+
;
1811+
1812+
emp_no:long | language_code:integer | language_name:keyword
1813+
10091 | 3 | Spanish
1814+
10091 | 3 | Spanish
1815+
10092 | 1 | English
1816+
10092 | 1 | English
1817+
10093 | 3 | Spanish
1818+
10093 | 3 | Spanish
1819+
;

0 commit comments

Comments
 (0)