Commit 56dafc3
committed
[SC-5492] Fix drop table command in ACL enabled Spark
## What changes were proposed in this pull request?
Drop table commands (and probably other create/drop commands) currently fail with a table does not exists exception when using Thrift with ACLs enabled.
This bug is caused by the following factors:
1. Thrift always executes an action on a dataset by calling `collect()`.
2. A `Dataset` for a command is executed eagerly. As soon as we create a `Dataset` that contains a `DropTableCommand`, the given table is dropped.
3. When you execute an action on a dataset. The `Dataset` creates a new `Dataframe` to track the query execution. The created `Dataset` will re-check analysis, the ACL `CheckPermissions` rule is triggered in this case, which fails because it cannot find the table to be dropped (it has already been dropped when the `Dataset` was eagerly executed).
This PR fixes this issue by modifying the `Dataset` actions; they will not spin off a new `Dataframe` anymore, the `queryExecution` is used directly when evaluating an action. This also gets rid of some code duplication for `Dataset` action evaluation by merging the typed and untyped code paths. The changes to `Dataset` will put in Apache Spark, I have created https://issues.apache.org/jira/browse/SPARK-19070 to track this.
## How was this patch tested?
I have added a regression test to `HiveThriftServer2Suites` and I have expanded the `base` scenario in the thrift ACL end to end tests.
Author: Herman van Hovell <[email protected]>
Closes apache#160 from hvanhovell/SC-5492.1 parent c836d98 commit 56dafc3
File tree
5 files changed
+214
-142
lines changed- sql
- core/src/main/scala/org/apache/spark/sql
- hive-thriftserver/src/test
- resources/acl-tests
- inputs
- results
- scala/org/apache/spark/sql/hive/thriftserver
- hive/src/test/scala/com/databricks/sql/acl
5 files changed
+214
-142
lines changedLines changed: 26 additions & 50 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
43 | 43 | | |
44 | 44 | | |
45 | 45 | | |
46 | | - | |
| 46 | + | |
47 | 47 | | |
48 | 48 | | |
49 | 49 | | |
| |||
2109 | 2109 | | |
2110 | 2110 | | |
2111 | 2111 | | |
2112 | | - | |
2113 | | - | |
2114 | | - | |
| 2112 | + | |
2115 | 2113 | | |
2116 | 2114 | | |
2117 | 2115 | | |
| |||
2338 | 2336 | | |
2339 | 2337 | | |
2340 | 2338 | | |
2341 | | - | |
| 2339 | + | |
2342 | 2340 | | |
2343 | 2341 | | |
2344 | 2342 | | |
| |||
2348 | 2346 | | |
2349 | 2347 | | |
2350 | 2348 | | |
2351 | | - | |
| 2349 | + | |
2352 | 2350 | | |
2353 | 2351 | | |
2354 | | - | |
| 2352 | + | |
2355 | 2353 | | |
2356 | 2354 | | |
2357 | 2355 | | |
2358 | 2356 | | |
2359 | 2357 | | |
2360 | 2358 | | |
2361 | 2359 | | |
2362 | | - | |
2363 | | - | |
2364 | | - | |
2365 | | - | |
2366 | | - | |
2367 | | - | |
2368 | | - | |
2369 | | - | |
2370 | | - | |
2371 | | - | |
2372 | | - | |
2373 | | - | |
2374 | | - | |
2375 | | - | |
2376 | | - | |
2377 | | - | |
2378 | | - | |
| 2360 | + | |
| 2361 | + | |
| 2362 | + | |
2379 | 2363 | | |
2380 | 2364 | | |
2381 | 2365 | | |
2382 | | - | |
| 2366 | + | |
2383 | 2367 | | |
2384 | 2368 | | |
2385 | 2369 | | |
| |||
2390 | 2374 | | |
2391 | 2375 | | |
2392 | 2376 | | |
2393 | | - | |
2394 | | - | |
2395 | | - | |
| 2377 | + | |
| 2378 | + | |
| 2379 | + | |
2396 | 2380 | | |
2397 | 2381 | | |
2398 | 2382 | | |
| |||
2401 | 2385 | | |
2402 | 2386 | | |
2403 | 2387 | | |
2404 | | - | |
2405 | | - | |
| 2388 | + | |
| 2389 | + | |
2406 | 2390 | | |
2407 | 2391 | | |
2408 | 2392 | | |
| |||
2769 | 2753 | | |
2770 | 2754 | | |
2771 | 2755 | | |
2772 | | - | |
| 2756 | + | |
2773 | 2757 | | |
2774 | | - | |
| 2758 | + | |
2775 | 2759 | | |
2776 | 2760 | | |
2777 | 2761 | | |
2778 | | - | |
| 2762 | + | |
| 2763 | + | |
| 2764 | + | |
2779 | 2765 | | |
2780 | | - | |
| 2766 | + | |
2781 | 2767 | | |
2782 | 2768 | | |
2783 | 2769 | | |
2784 | | - | |
| 2770 | + | |
2785 | 2771 | | |
2786 | 2772 | | |
2787 | 2773 | | |
2788 | 2774 | | |
2789 | | - | |
2790 | | - | |
2791 | | - | |
2792 | | - | |
2793 | | - | |
2794 | | - | |
2795 | | - | |
2796 | | - | |
2797 | | - | |
2798 | | - | |
2799 | | - | |
2800 | | - | |
2801 | | - | |
2802 | | - | |
2803 | | - | |
| 2775 | + | |
| 2776 | + | |
| 2777 | + | |
| 2778 | + | |
| 2779 | + | |
2804 | 2780 | | |
2805 | 2781 | | |
2806 | 2782 | | |
| |||
Lines changed: 13 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
20 | 20 | | |
21 | 21 | | |
22 | 22 | | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
23 | 34 | | |
24 | 35 | | |
25 | | - | |
| 36 | + | |
| 37 | + | |
26 | 38 | | |
27 | 39 | | |
Lines changed: 68 additions & 8 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | | - | |
| 2 | + | |
3 | 3 | | |
4 | 4 | | |
5 | 5 | | |
| |||
111 | 111 | | |
112 | 112 | | |
113 | 113 | | |
114 | | - | |
| 114 | + | |
115 | 115 | | |
116 | 116 | | |
117 | 117 | | |
| |||
121 | 121 | | |
122 | 122 | | |
123 | 123 | | |
124 | | - | |
| 124 | + | |
125 | 125 | | |
126 | 126 | | |
127 | 127 | | |
128 | | - | |
| 128 | + | |
129 | 129 | | |
130 | | - | |
| 130 | + | |
131 | 131 | | |
132 | 132 | | |
133 | 133 | | |
134 | | - | |
| 134 | + | |
135 | 135 | | |
136 | | - | |
| 136 | + | |
137 | 137 | | |
138 | | - | |
| 138 | + | |
139 | 139 | | |
140 | 140 | | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
| 195 | + | |
| 196 | + | |
| 197 | + | |
| 198 | + | |
| 199 | + | |
| 200 | + | |
Lines changed: 1 addition & 7 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
770 | 770 | | |
771 | 771 | | |
772 | 772 | | |
773 | | - | |
| 773 | + | |
774 | 774 | | |
775 | 775 | | |
776 | 776 | | |
777 | 777 | | |
778 | | - | |
779 | | - | |
780 | | - | |
781 | | - | |
782 | | - | |
783 | | - | |
784 | 778 | | |
785 | 779 | | |
786 | 780 | | |
| |||
0 commit comments