Commit f024d30
[SPARK-34317][SQL] Introduce relationTypeMismatchHint to UnresolvedTable for a better error message
### What changes were proposed in this pull request?
This PR proposes to add `relationTypeMismatchHint` to `UnresolvedTable` so that if a relation is resolved to a view when a table is expected, a hint message can be included as a part of the analysis exception message. Note that the same feature is already introduced to `UnresolvedView` in #30636.
This mostly affects `ALTER TABLE` commands where the analysis exception message will now contain `Please use ALTER VIEW as instead`.
### Why are the changes needed?
To give a better error message. (The hint used to exist but got removed for commands that migrated to the new resolution framework)
### Does this PR introduce _any_ user-facing change?
Yes, now `ALTER TABLE` commands include a hint to use `ALTER VIEW` instead.
```
sql("ALTER TABLE v SET SERDE 'whatever'")
```
Before:
```
"v is a view. 'ALTER TABLE ... SET [SERDE|SERDEPROPERTIES]' expects a table.
```
After this PR:
```
"v is a view. 'ALTER TABLE ... SET [SERDE|SERDEPROPERTIES]' expects a table. Please use ALTER VIEW instead.
```
### How was this patch tested?
Updated existing test cases to include the hint.
Closes #31424 from imback82/better_error.
Authored-by: Terry Kim <yuminkim@gmail.com>
Signed-off-by: Wenchen Fan <wenchen@databricks.com>1 parent bb9bf66 commit f024d30
File tree
12 files changed
+177
-79
lines changed- sql
- catalyst/src
- main/scala/org/apache/spark/sql
- catalyst
- analysis
- parser
- errors
- test/scala/org/apache/spark/sql/catalyst/parser
- core/src
- main/scala/org/apache/spark/sql/internal
- test/scala/org/apache/spark/sql/execution/command
- hive/src/test/scala/org/apache/spark/sql/hive/execution
12 files changed
+177
-79
lines changedLines changed: 10 additions & 8 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
893 | 893 | | |
894 | 894 | | |
895 | 895 | | |
896 | | - | |
| 896 | + | |
897 | 897 | | |
898 | 898 | | |
899 | 899 | | |
| |||
990 | 990 | | |
991 | 991 | | |
992 | 992 | | |
993 | | - | |
| 993 | + | |
994 | 994 | | |
995 | 995 | | |
996 | 996 | | |
| |||
1144 | 1144 | | |
1145 | 1145 | | |
1146 | 1146 | | |
1147 | | - | |
| 1147 | + | |
1148 | 1148 | | |
1149 | | - | |
| 1149 | + | |
| 1150 | + | |
| 1151 | + | |
1150 | 1152 | | |
1151 | 1153 | | |
1152 | 1154 | | |
1153 | 1155 | | |
1154 | 1156 | | |
1155 | | - | |
1156 | | - | |
1157 | | - | |
1158 | | - | |
| 1157 | + | |
| 1158 | + | |
| 1159 | + | |
| 1160 | + | |
1159 | 1161 | | |
1160 | 1162 | | |
1161 | 1163 | | |
| |||
Lines changed: 2 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
40 | 40 | | |
41 | 41 | | |
42 | 42 | | |
43 | | - | |
| 43 | + | |
| 44 | + | |
44 | 45 | | |
45 | 46 | | |
46 | 47 | | |
| |||
Lines changed: 21 additions & 10 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2170 | 2170 | | |
2171 | 2171 | | |
2172 | 2172 | | |
2173 | | - | |
2174 | | - | |
| 2173 | + | |
| 2174 | + | |
| 2175 | + | |
2175 | 2176 | | |
2176 | 2177 | | |
2177 | 2178 | | |
| |||
3494 | 3495 | | |
3495 | 3496 | | |
3496 | 3497 | | |
3497 | | - | |
| 3498 | + | |
3498 | 3499 | | |
3499 | 3500 | | |
3500 | 3501 | | |
| |||
3524 | 3525 | | |
3525 | 3526 | | |
3526 | 3527 | | |
3527 | | - | |
| 3528 | + | |
3528 | 3529 | | |
3529 | 3530 | | |
3530 | 3531 | | |
| |||
3547 | 3548 | | |
3548 | 3549 | | |
3549 | 3550 | | |
3550 | | - | |
| 3551 | + | |
| 3552 | + | |
3551 | 3553 | | |
3552 | 3554 | | |
3553 | 3555 | | |
| |||
3814 | 3816 | | |
3815 | 3817 | | |
3816 | 3818 | | |
3817 | | - | |
| 3819 | + | |
| 3820 | + | |
3818 | 3821 | | |
3819 | 3822 | | |
3820 | 3823 | | |
| |||
3843 | 3846 | | |
3844 | 3847 | | |
3845 | 3848 | | |
3846 | | - | |
| 3849 | + | |
| 3850 | + | |
3847 | 3851 | | |
3848 | 3852 | | |
3849 | 3853 | | |
| |||
3861 | 3865 | | |
3862 | 3866 | | |
3863 | 3867 | | |
3864 | | - | |
| 3868 | + | |
| 3869 | + | |
3865 | 3870 | | |
3866 | 3871 | | |
3867 | 3872 | | |
| |||
3889 | 3894 | | |
3890 | 3895 | | |
3891 | 3896 | | |
3892 | | - | |
| 3897 | + | |
| 3898 | + | |
3893 | 3899 | | |
3894 | 3900 | | |
3895 | 3901 | | |
| |||
3909 | 3915 | | |
3910 | 3916 | | |
3911 | 3917 | | |
3912 | | - | |
| 3918 | + | |
| 3919 | + | |
3913 | 3920 | | |
3914 | 3921 | | |
3915 | 3922 | | |
| |||
4122 | 4129 | | |
4123 | 4130 | | |
4124 | 4131 | | |
| 4132 | + | |
| 4133 | + | |
| 4134 | + | |
| 4135 | + | |
4125 | 4136 | | |
Lines changed: 12 additions & 3 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
21 | 21 | | |
22 | 22 | | |
23 | 23 | | |
24 | | - | |
| 24 | + | |
25 | 25 | | |
26 | 26 | | |
27 | 27 | | |
| |||
231 | 231 | | |
232 | 232 | | |
233 | 233 | | |
234 | | - | |
| 234 | + | |
| 235 | + | |
235 | 236 | | |
236 | | - | |
| 237 | + | |
| 238 | + | |
| 239 | + | |
| 240 | + | |
| 241 | + | |
| 242 | + | |
| 243 | + | |
| 244 | + | |
| 245 | + | |
237 | 246 | | |
238 | 247 | | |
239 | 248 | | |
| |||
Lines changed: 34 additions & 17 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
867 | 867 | | |
868 | 868 | | |
869 | 869 | | |
| 870 | + | |
870 | 871 | | |
871 | 872 | | |
872 | 873 | | |
873 | | - | |
| 874 | + | |
874 | 875 | | |
875 | 876 | | |
876 | 877 | | |
877 | 878 | | |
878 | 879 | | |
879 | 880 | | |
880 | | - | |
| 881 | + | |
881 | 882 | | |
882 | 883 | | |
883 | 884 | | |
| |||
1915 | 1916 | | |
1916 | 1917 | | |
1917 | 1918 | | |
1918 | | - | |
| 1919 | + | |
1919 | 1920 | | |
1920 | 1921 | | |
1921 | 1922 | | |
1922 | 1923 | | |
1923 | 1924 | | |
1924 | | - | |
| 1925 | + | |
| 1926 | + | |
| 1927 | + | |
| 1928 | + | |
| 1929 | + | |
| 1930 | + | |
1925 | 1931 | | |
1926 | 1932 | | |
1927 | 1933 | | |
1928 | | - | |
| 1934 | + | |
| 1935 | + | |
| 1936 | + | |
| 1937 | + | |
| 1938 | + | |
| 1939 | + | |
1929 | 1940 | | |
1930 | 1941 | | |
1931 | 1942 | | |
1932 | | - | |
| 1943 | + | |
| 1944 | + | |
| 1945 | + | |
| 1946 | + | |
| 1947 | + | |
| 1948 | + | |
1933 | 1949 | | |
1934 | 1950 | | |
1935 | 1951 | | |
| |||
1938 | 1954 | | |
1939 | 1955 | | |
1940 | 1956 | | |
1941 | | - | |
| 1957 | + | |
1942 | 1958 | | |
1943 | 1959 | | |
1944 | 1960 | | |
| |||
2003 | 2019 | | |
2004 | 2020 | | |
2005 | 2021 | | |
2006 | | - | |
| 2022 | + | |
2007 | 2023 | | |
2008 | 2024 | | |
2009 | 2025 | | |
2010 | 2026 | | |
2011 | | - | |
| 2027 | + | |
2012 | 2028 | | |
2013 | 2029 | | |
2014 | 2030 | | |
| |||
2058 | 2074 | | |
2059 | 2075 | | |
2060 | 2076 | | |
| 2077 | + | |
2061 | 2078 | | |
2062 | 2079 | | |
2063 | | - | |
| 2080 | + | |
2064 | 2081 | | |
2065 | 2082 | | |
2066 | 2083 | | |
| |||
2073 | 2090 | | |
2074 | 2091 | | |
2075 | 2092 | | |
2076 | | - | |
| 2093 | + | |
2077 | 2094 | | |
2078 | 2095 | | |
2079 | 2096 | | |
| |||
2086 | 2103 | | |
2087 | 2104 | | |
2088 | 2105 | | |
2089 | | - | |
| 2106 | + | |
2090 | 2107 | | |
2091 | 2108 | | |
2092 | 2109 | | |
| |||
2100 | 2117 | | |
2101 | 2118 | | |
2102 | 2119 | | |
2103 | | - | |
| 2120 | + | |
2104 | 2121 | | |
2105 | 2122 | | |
2106 | 2123 | | |
| |||
2113 | 2130 | | |
2114 | 2131 | | |
2115 | 2132 | | |
2116 | | - | |
| 2133 | + | |
2117 | 2134 | | |
2118 | 2135 | | |
2119 | 2136 | | |
| |||
2126 | 2143 | | |
2127 | 2144 | | |
2128 | 2145 | | |
2129 | | - | |
| 2146 | + | |
2130 | 2147 | | |
2131 | 2148 | | |
2132 | 2149 | | |
| |||
2139 | 2156 | | |
2140 | 2157 | | |
2141 | 2158 | | |
2142 | | - | |
| 2159 | + | |
2143 | 2160 | | |
2144 | 2161 | | |
2145 | 2162 | | |
| |||
2470 | 2487 | | |
2471 | 2488 | | |
2472 | 2489 | | |
2473 | | - | |
| 2490 | + | |
2474 | 2491 | | |
2475 | 2492 | | |
2476 | 2493 | | |
| |||
Lines changed: 2 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
448 | 448 | | |
449 | 449 | | |
450 | 450 | | |
451 | | - | |
| 451 | + | |
| 452 | + | |
452 | 453 | | |
453 | 454 | | |
454 | 455 | | |
| |||
Lines changed: 8 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
30 | 30 | | |
31 | 31 | | |
32 | 32 | | |
33 | | - | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
34 | 37 | | |
35 | 38 | | |
36 | 39 | | |
| |||
42 | 45 | | |
43 | 46 | | |
44 | 47 | | |
45 | | - | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
46 | 52 | | |
47 | 53 | | |
48 | 54 | | |
| |||
0 commit comments