Commit 0c19497
[SPARK-33815][SQL] Migrate ALTER TABLE ... SET [SERDE|SERDEPROPERTIES] to use UnresolvedTable to resolve the identifier
### What changes were proposed in this pull request?
This PR proposes to migrate `ALTER TABLE ... SET [SERDE|SERDEPROPERTIES` to use `UnresolvedTable` to resolve the table identifier. This allows consistent resolution rules (temp view first, etc.) to be applied for both v1/v2 commands. More info about the consistent resolution rule proposal can be found in [JIRA](https://issues.apache.org/jira/browse/SPARK-29900) or [proposal doc](https://docs.google.com/document/d/1hvLjGA8y_W_hhilpngXVub1Ebv8RsMap986nENCFnrg/edit?usp=sharing).
Note that `ALTER TABLE ... SET [SERDE|SERDEPROPERTIES]` is not supported for v2 tables.
### Why are the changes needed?
The PR makes the resolution consistent behavior consistent. For example,
```scala
sql("CREATE DATABASE test")
sql("CREATE TABLE spark_catalog.test.t (id bigint, val string) USING csv PARTITIONED BY (id)")
sql("CREATE TEMPORARY VIEW t AS SELECT 2")
sql("USE spark_catalog.test")
sql("ALTER TABLE t SET SERDE 'serdename'") // works fine
```
, but after this PR:
```
sql("ALTER TABLE t SET SERDE 'serdename'")
org.apache.spark.sql.AnalysisException: t is a temp view. 'ALTER TABLE ... SET [SERDE|SERDEPROPERTIES\' expects a table; line 1 pos 0
```
, which is the consistent behavior with other commands.
### Does this PR introduce _any_ user-facing change?
After this PR, `t` in the above example is resolved to a temp view first instead of `spark_catalog.test.t`.
### How was this patch tested?
Updated existing tests.
Closes #30813 from imback82/alter_table_serde_v2.
Authored-by: Terry Kim <[email protected]>
Signed-off-by: Wenchen Fan <[email protected]>1 parent 0c12900 commit 0c19497
File tree
9 files changed
+66
-37
lines changed- sql
- catalyst/src
- main/scala/org/apache/spark/sql/catalyst
- parser
- plans/logical
- test/scala/org/apache/spark/sql/catalyst/parser
- core/src
- main/scala/org/apache/spark/sql
- catalyst/analysis
- execution/datasources/v2
- test/scala/org/apache/spark/sql
- connector
- execution
- hive/src/test/scala/org/apache/spark/sql/hive/execution
9 files changed
+66
-37
lines changedLines changed: 5 additions & 3 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
3806 | 3806 | | |
3807 | 3807 | | |
3808 | 3808 | | |
3809 | | - | |
| 3809 | + | |
3810 | 3810 | | |
3811 | 3811 | | |
3812 | 3812 | | |
| |||
3816 | 3816 | | |
3817 | 3817 | | |
3818 | 3818 | | |
3819 | | - | |
3820 | | - | |
| 3819 | + | |
| 3820 | + | |
| 3821 | + | |
| 3822 | + | |
3821 | 3823 | | |
3822 | 3824 | | |
3823 | 3825 | | |
| |||
Lines changed: 0 additions & 9 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
300 | 300 | | |
301 | 301 | | |
302 | 302 | | |
303 | | - | |
304 | | - | |
305 | | - | |
306 | | - | |
307 | | - | |
308 | | - | |
309 | | - | |
310 | | - | |
311 | | - | |
312 | 303 | | |
313 | 304 | | |
314 | 305 | | |
| |||
Lines changed: 11 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
777 | 777 | | |
778 | 778 | | |
779 | 779 | | |
| 780 | + | |
| 781 | + | |
| 782 | + | |
| 783 | + | |
| 784 | + | |
| 785 | + | |
| 786 | + | |
| 787 | + | |
| 788 | + | |
| 789 | + | |
| 790 | + | |
780 | 791 | | |
781 | 792 | | |
782 | 793 | | |
| |||
Lines changed: 20 additions & 14 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2134 | 2134 | | |
2135 | 2135 | | |
2136 | 2136 | | |
2137 | | - | |
2138 | | - | |
| 2137 | + | |
| 2138 | + | |
| 2139 | + | |
| 2140 | + | |
| 2141 | + | |
2139 | 2142 | | |
2140 | 2143 | | |
2141 | 2144 | | |
| |||
2144 | 2147 | | |
2145 | 2148 | | |
2146 | 2149 | | |
2147 | | - | |
2148 | | - | |
| 2150 | + | |
| 2151 | + | |
2149 | 2152 | | |
2150 | 2153 | | |
2151 | 2154 | | |
| |||
2157 | 2160 | | |
2158 | 2161 | | |
2159 | 2162 | | |
2160 | | - | |
2161 | | - | |
| 2163 | + | |
| 2164 | + | |
| 2165 | + | |
| 2166 | + | |
| 2167 | + | |
2162 | 2168 | | |
2163 | 2169 | | |
2164 | 2170 | | |
| |||
2168 | 2174 | | |
2169 | 2175 | | |
2170 | 2176 | | |
2171 | | - | |
2172 | | - | |
| 2177 | + | |
| 2178 | + | |
2173 | 2179 | | |
2174 | 2180 | | |
2175 | 2181 | | |
| |||
2181 | 2187 | | |
2182 | 2188 | | |
2183 | 2189 | | |
2184 | | - | |
2185 | | - | |
| 2190 | + | |
| 2191 | + | |
2186 | 2192 | | |
2187 | 2193 | | |
2188 | 2194 | | |
| |||
2194 | 2200 | | |
2195 | 2201 | | |
2196 | 2202 | | |
2197 | | - | |
2198 | | - | |
| 2203 | + | |
| 2204 | + | |
2199 | 2205 | | |
2200 | 2206 | | |
2201 | 2207 | | |
| |||
2207 | 2213 | | |
2208 | 2214 | | |
2209 | 2215 | | |
2210 | | - | |
2211 | | - | |
| 2216 | + | |
| 2217 | + | |
2212 | 2218 | | |
2213 | 2219 | | |
2214 | 2220 | | |
| |||
Lines changed: 6 additions & 3 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
476 | 476 | | |
477 | 477 | | |
478 | 478 | | |
479 | | - | |
480 | | - | |
| 479 | + | |
| 480 | + | |
| 481 | + | |
| 482 | + | |
| 483 | + | |
481 | 484 | | |
482 | | - | |
| 485 | + | |
483 | 486 | | |
484 | 487 | | |
485 | 488 | | |
| |||
Lines changed: 4 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
334 | 334 | | |
335 | 335 | | |
336 | 336 | | |
| 337 | + | |
| 338 | + | |
| 339 | + | |
| 340 | + | |
337 | 341 | | |
338 | 342 | | |
339 | 343 | | |
| |||
Lines changed: 2 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2120 | 2120 | | |
2121 | 2121 | | |
2122 | 2122 | | |
2123 | | - | |
| 2123 | + | |
| 2124 | + | |
2124 | 2125 | | |
2125 | 2126 | | |
2126 | 2127 | | |
| |||
Lines changed: 9 additions & 3 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
140 | 140 | | |
141 | 141 | | |
142 | 142 | | |
143 | | - | |
144 | | - | |
145 | | - | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
146 | 152 | | |
147 | 153 | | |
148 | 154 | | |
| |||
Lines changed: 9 additions & 4 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
888 | 888 | | |
889 | 889 | | |
890 | 890 | | |
891 | | - | |
| 891 | + | |
| 892 | + | |
| 893 | + | |
892 | 894 | | |
893 | | - | |
| 895 | + | |
| 896 | + | |
| 897 | + | |
894 | 898 | | |
895 | | - | |
896 | | - | |
| 899 | + | |
| 900 | + | |
| 901 | + | |
897 | 902 | | |
898 | 903 | | |
899 | 904 | | |
| |||
0 commit comments