Commit f16570f
[SPARK-54807][SQL] Allow qualified names for built-in and session functions
[design_sketch.md](https://github.com/user-attachments/files/25671695/design_sketch.md)
### What changes were proposed in this pull request?
- Allow reference of built in functions with qualifiers builtin or system.builtin and temporary functions as session or system.session. Functions registered as extensionz can be qualified with system.extension or extension.
- Cleaned up APIs to resolve functions to prep for configurable path
- Register builtin extension, and session functions with qualified names, so they can co-exist
- Fix a bug that allowed session functions with the same name to co-exist as table and scalar functions
[design_sketch.md](https://github.com/user-attachments/files/25671695/design_sketch.md)
### Why are the changes needed?
This portion of work allows users to excplicitly pick a builtin or temporary function, the same way they would pick a persisted function by fully qualifying it.
This increases security.
WIth this we now have a fixed order:
extension -> builtin -> session -> current schema for function resolution.
In follow on work we plan to allow the priority of function resolution to be configurable, for example to push temporary functions after built-ins or even after persisted functions.
Ultimately we aim for proper SQL Standard PATH support where a user can add "libraries" of functions to the path.
### Does this PR introduce _any_ user-facing change?
You can now reference builtin functions such as concat with builtin.concat or system.builtin.concat. Teh same for temporary functions which can be qualified as session, or system.session.
### How was this patch tested?
A new suite: functionQualificationSuite.scala has been added
### Was this patch authored or co-authored using generative AI tooling?
Yes: Claude Sonnet
Closes #53570 from srielau/search-path.
Lead-authored-by: Serge Rielau <serge@rielau.com>
Co-authored-by: Wenchen Fan <wenchen@databricks.com>
Co-authored-by: Serge Rielau <srielau@users.noreply.github.com>
Signed-off-by: Gengliang Wang <gengliang@apache.org>1 parent 4ebdc4a commit f16570f
39 files changed
Lines changed: 2583 additions & 442 deletions
File tree
- common/utils/src/main/resources/error
- mllib/src/main/scala/org/apache/spark/sql/ml
- sql
- api/src/main/scala/org/apache/spark/sql/errors
- catalyst/src
- main/scala/org/apache/spark/sql
- catalyst
- analysis
- resolver
- catalog
- parser
- connector/catalog
- errors
- internal
- test/scala/org/apache/spark/sql/catalyst/parser
- core/src
- main/scala/org/apache/spark/sql
- catalyst/analysis
- classic
- execution
- command
- test
- resources/sql-tests
- analyzer-results
- postgreSQL
- results
- postgreSQL
- scala/org/apache/spark/sql
- analysis/resolver
- connector
- errors
- execution/command
- jdbc
Lines changed: 12 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
4116 | 4116 | | |
4117 | 4117 | | |
4118 | 4118 | | |
| 4119 | + | |
| 4120 | + | |
| 4121 | + | |
| 4122 | + | |
| 4123 | + | |
| 4124 | + | |
4119 | 4125 | | |
4120 | 4126 | | |
4121 | 4127 | | |
| |||
4186 | 4192 | | |
4187 | 4193 | | |
4188 | 4194 | | |
| 4195 | + | |
| 4196 | + | |
| 4197 | + | |
| 4198 | + | |
| 4199 | + | |
| 4200 | + | |
4189 | 4201 | | |
4190 | 4202 | | |
4191 | 4203 | | |
| |||
Lines changed: 3 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
20 | 20 | | |
21 | 21 | | |
22 | 22 | | |
| 23 | + | |
23 | 24 | | |
24 | 25 | | |
25 | 26 | | |
| |||
41 | 42 | | |
42 | 43 | | |
43 | 44 | | |
44 | | - | |
| 45 | + | |
| 46 | + | |
45 | 47 | | |
46 | 48 | | |
47 | 49 | | |
| |||
Lines changed: 14 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
674 | 674 | | |
675 | 675 | | |
676 | 676 | | |
| 677 | + | |
| 678 | + | |
| 679 | + | |
| 680 | + | |
| 681 | + | |
| 682 | + | |
| 683 | + | |
| 684 | + | |
| 685 | + | |
| 686 | + | |
| 687 | + | |
| 688 | + | |
| 689 | + | |
| 690 | + | |
677 | 691 | | |
678 | 692 | | |
679 | 693 | | |
| |||
Lines changed: 95 additions & 52 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1823 | 1823 | | |
1824 | 1824 | | |
1825 | 1825 | | |
| 1826 | + | |
| 1827 | + | |
| 1828 | + | |
| 1829 | + | |
| 1830 | + | |
| 1831 | + | |
| 1832 | + | |
| 1833 | + | |
| 1834 | + | |
| 1835 | + | |
| 1836 | + | |
| 1837 | + | |
| 1838 | + | |
| 1839 | + | |
| 1840 | + | |
| 1841 | + | |
| 1842 | + | |
| 1843 | + | |
| 1844 | + | |
| 1845 | + | |
1826 | 1846 | | |
1827 | 1847 | | |
1828 | 1848 | | |
1829 | 1849 | | |
1830 | 1850 | | |
1831 | 1851 | | |
1832 | | - | |
| 1852 | + | |
1833 | 1853 | | |
1834 | 1854 | | |
1835 | | - | |
| 1855 | + | |
| 1856 | + | |
| 1857 | + | |
| 1858 | + | |
1836 | 1859 | | |
1837 | 1860 | | |
1838 | 1861 | | |
1839 | 1862 | | |
1840 | 1863 | | |
1841 | 1864 | | |
1842 | | - | |
| 1865 | + | |
1843 | 1866 | | |
1844 | 1867 | | |
1845 | 1868 | | |
| |||
1987 | 2010 | | |
1988 | 2011 | | |
1989 | 2012 | | |
1990 | | - | |
1991 | | - | |
| 2013 | + | |
| 2014 | + | |
| 2015 | + | |
| 2016 | + | |
| 2017 | + | |
| 2018 | + | |
| 2019 | + | |
1992 | 2020 | | |
1993 | 2021 | | |
1994 | 2022 | | |
| |||
1998 | 2026 | | |
1999 | 2027 | | |
2000 | 2028 | | |
2001 | | - | |
| 2029 | + | |
| 2030 | + | |
| 2031 | + | |
| 2032 | + | |
| 2033 | + | |
| 2034 | + | |
| 2035 | + | |
| 2036 | + | |
| 2037 | + | |
| 2038 | + | |
2002 | 2039 | | |
2003 | 2040 | | |
| 2041 | + | |
2004 | 2042 | | |
2005 | 2043 | | |
2006 | | - | |
2007 | | - | |
| 2044 | + | |
| 2045 | + | |
| 2046 | + | |
| 2047 | + | |
2008 | 2048 | | |
2009 | | - | |
2010 | | - | |
2011 | | - | |
| 2049 | + | |
2012 | 2050 | | |
2013 | 2051 | | |
2014 | | - | |
2015 | | - | |
2016 | | - | |
2017 | | - | |
2018 | | - | |
| 2052 | + | |
| 2053 | + | |
| 2054 | + | |
| 2055 | + | |
| 2056 | + | |
| 2057 | + | |
| 2058 | + | |
| 2059 | + | |
| 2060 | + | |
| 2061 | + | |
| 2062 | + | |
| 2063 | + | |
| 2064 | + | |
| 2065 | + | |
| 2066 | + | |
| 2067 | + | |
| 2068 | + | |
| 2069 | + | |
| 2070 | + | |
| 2071 | + | |
| 2072 | + | |
| 2073 | + | |
| 2074 | + | |
| 2075 | + | |
| 2076 | + | |
| 2077 | + | |
| 2078 | + | |
| 2079 | + | |
2019 | 2080 | | |
2020 | 2081 | | |
2021 | 2082 | | |
| |||
2057 | 2118 | | |
2058 | 2119 | | |
2059 | 2120 | | |
2060 | | - | |
2061 | | - | |
2062 | | - | |
2063 | | - | |
2064 | | - | |
2065 | | - | |
2066 | | - | |
2067 | | - | |
2068 | | - | |
2069 | | - | |
2070 | | - | |
2071 | | - | |
2072 | | - | |
2073 | | - | |
2074 | | - | |
2075 | | - | |
2076 | | - | |
2077 | | - | |
2078 | | - | |
2079 | | - | |
2080 | | - | |
2081 | | - | |
2082 | | - | |
2083 | | - | |
2084 | | - | |
2085 | | - | |
2086 | | - | |
2087 | | - | |
2088 | | - | |
| 2121 | + | |
| 2122 | + | |
2089 | 2123 | | |
2090 | 2124 | | |
2091 | 2125 | | |
| 2126 | + | |
| 2127 | + | |
| 2128 | + | |
| 2129 | + | |
| 2130 | + | |
| 2131 | + | |
| 2132 | + | |
| 2133 | + | |
| 2134 | + | |
| 2135 | + | |
| 2136 | + | |
| 2137 | + | |
| 2138 | + | |
| 2139 | + | |
| 2140 | + | |
2092 | 2141 | | |
2093 | 2142 | | |
2094 | 2143 | | |
| |||
2167 | 2216 | | |
2168 | 2217 | | |
2169 | 2218 | | |
2170 | | - | |
| 2219 | + | |
2171 | 2220 | | |
2172 | 2221 | | |
2173 | 2222 | | |
2174 | 2223 | | |
2175 | 2224 | | |
2176 | | - | |
2177 | | - | |
2178 | | - | |
2179 | | - | |
2180 | | - | |
2181 | | - | |
2182 | 2225 | | |
2183 | 2226 | | |
2184 | 2227 | | |
| |||
Lines changed: 4 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
303 | 303 | | |
304 | 304 | | |
305 | 305 | | |
306 | | - | |
| 306 | + | |
| 307 | + | |
| 308 | + | |
307 | 309 | | |
308 | 310 | | |
309 | | - | |
| 311 | + | |
310 | 312 | | |
311 | 313 | | |
312 | 314 | | |
| |||
Lines changed: 8 additions & 4 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
35 | 35 | | |
36 | 36 | | |
37 | 37 | | |
| 38 | + | |
38 | 39 | | |
39 | 40 | | |
40 | 41 | | |
| |||
78 | 79 | | |
79 | 80 | | |
80 | 81 | | |
81 | | - | |
82 | | - | |
83 | | - | |
84 | | - | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
85 | 89 | | |
86 | 90 | | |
87 | 91 | | |
| |||
0 commit comments