Commit fb0097c
[RTAS]: Fix bug - remove fs scheme from tableLocation in commit (cont) (#594)
## Summary
This is the follow up PR of
#542. After the fix, we were
able to replace the table once but not multiple times. RC anslysis:
1. `OpenHouseInternalTableOperations` uses `metadata.location()` for the
new HTS tableLocation, and that value comes from
`.withLocation(tableLocation)` that we pass, so we need to make sure
it's schemeless.
2. We used `tableDto.getTableVersion()` to populate
`.withLocation(tableLocation)`, but tableDto always contains scheme.
(Why is tableLocation = tableVersion in tableDto? Because tableVersion
comes from client request, and client request uses the tableLocation
from the server response, so they will always be same and contain
scheme)
3. The last PR fixes the tableLocation in table properties, so the new
tableVersion for the first replace will be schemeless. But since the new
tableLocation has scheme, the next replace will fail.
Therefore, in this PR, we use the tableLocation from the table
properties that we had just stripped in the last PR for
`.withLocation(tableLocation)`.
## Changes
- [ ] Client-facing API Changes
- [ ] Internal API Changes
- [x] Bug Fixes
- [ ] New Features
- [ ] Performance Improvements
- [ ] Code Style
- [ ] Refactoring
- [ ] Documentation
- [ ] Tests
For all the boxes checked, please include additional details of the
changes made in this pull request.
## Testing Done
<!--- Check any relevant boxes with "x" -->
- [x] Manually Tested on local docker setup. Please include commands
ran, and their output.
- [ ] Added new tests for the changes made.
- [x] Updated existing tests to reflect the changes made.
- [ ] No tests added or updated. Please explain why. If unsure, please
feel free to ask for help.
- [ ] Some other form of testing like staging or soak time in
production. Please explain.
**Unit tests**
I removed `stripPathScheme` in the spark E2E tests to gurantee that
scheme issues can be captured by unit tests.
**Test 1: RTAS**
```
scala> spark.sql(s"CREATE TABLE $tableName TBLPROPERTIES ('prop1'='val1', 'prop2'='val2') AS SELECT * FROM $sourceName");
res3: org.apache.spark.sql.DataFrame = []
scala> spark.sql(s"INSERT INTO $tableName values (4, 'd')");
res4: org.apache.spark.sql.DataFrame = []
scala> spark.sql(s"REPLACE TABLE $tableName PARTITIONED BY (part) TBLPROPERTIES ('prop1'='newval1', 'prop3'='val3') AS SELECT id, data, CASE WHEN (id % 2) = 0 THEN 'even' ELSE 'odd' END AS part FROM $sourceName ORDER BY 3, 1");
res5: org.apache.spark.sql.DataFrame = []
scala> spark.sql(s"REPLACE TABLE $tableName PARTITIONED BY (part) AS SELECT 2 * id as id, data, CASE WHEN ((2 * id) % 2) = 0 THEN 'even' ELSE 'odd' END AS part FROM $sourceName ORDER BY 3, 1");
res12: org.apache.spark.sql.DataFrame = []
scala> spark.sql(s"SELECT * FROM $tableName").show(false)
+---+----+----+
|id |data|part|
+---+----+----+
|2 |a |even|
|4 |b |even|
|6 |c |even|
+---+----+----+
```
**Test 2: CRTAS**
```
scala> spark.sql(s"CREATE OR REPLACE TABLE $tableName TBLPROPERTIES ('prop1'='val1', 'prop2'='val2') AS SELECT * FROM $sourceName");
res19: org.apache.spark.sql.DataFrame = []
scala> spark.sql(s"INSERT INTO $tableName values (4, 'd')");
res20: org.apache.spark.sql.DataFrame = []
scala> spark.sql(s"CREATE OR REPLACE TABLE $tableName PARTITIONED BY (part) AS SELECT id, data, CASE WHEN id % 2 = 0 THEN 'even' ELSE 'odd' END AS part FROM $sourceName ORDER BY 3, 1");
res21: org.apache.spark.sql.DataFrame = []
scala> spark.sql(s"CREATE OR REPLACE TABLE $tableName PARTITIONED BY (part) AS SELECT 2 * id as id, data, CASE WHEN ((2 * id) % 2) = 0 THEN 'even' ELSE 'odd' END AS part FROM $sourceName ORDER BY 3, 1");
res22: org.apache.spark.sql.DataFrame = []
scala> spark.sql(s"SELECT * FROM $tableName").show(false)
+---+----+----+
|id |data|part|
+---+----+----+
|2 |a |even|
|4 |b |even|
|6 |c |even|
+---+----+----+
```
# Additional Information
- [ ] Breaking Changes
- [ ] Deprecations
- [ ] Large PR broken into smaller PRs, and PR plan linked in the
description.
For all the boxes checked, include additional details of the changes
made in this pull request.
---------
Co-authored-by: Levi Jiang <lejiang@lejiang-mn2962.linkedin.biz>1 parent 7a1eb61 commit fb0097c
4 files changed
Lines changed: 9 additions & 27 deletions
File tree
- apps/spark/src/test/java/com/linkedin/openhouse/catalog/e2e
- integrations/spark/spark-3.1/openhouse-spark-itest/src/test/java/com/linkedin/openhouse/spark/catalogtest
- services/tables/src/main/java/com/linkedin/openhouse/tables/repository/impl
- tables-test-fixtures/tables-test-fixtures-iceberg-1.2/src/main/java/com/linkedin/openhouse/tablestest
Lines changed: 2 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
141 | 141 | | |
142 | 142 | | |
143 | 143 | | |
144 | | - | |
145 | | - | |
| 144 | + | |
| 145 | + | |
146 | 146 | | |
147 | 147 | | |
148 | 148 | | |
| |||
Lines changed: 4 additions & 16 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
83 | 83 | | |
84 | 84 | | |
85 | 85 | | |
86 | | - | |
87 | | - | |
88 | | - | |
89 | | - | |
| 86 | + | |
90 | 87 | | |
91 | 88 | | |
92 | 89 | | |
| |||
151 | 148 | | |
152 | 149 | | |
153 | 150 | | |
154 | | - | |
155 | | - | |
156 | | - | |
157 | | - | |
| 151 | + | |
158 | 152 | | |
159 | 153 | | |
160 | 154 | | |
| |||
201 | 195 | | |
202 | 196 | | |
203 | 197 | | |
204 | | - | |
205 | | - | |
206 | | - | |
207 | | - | |
| 198 | + | |
208 | 199 | | |
209 | 200 | | |
210 | 201 | | |
| |||
265 | 256 | | |
266 | 257 | | |
267 | 258 | | |
268 | | - | |
269 | | - | |
270 | | - | |
271 | | - | |
| 259 | + | |
272 | 260 | | |
273 | 261 | | |
274 | 262 | | |
| |||
Lines changed: 3 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2 | 2 | | |
3 | 3 | | |
4 | 4 | | |
| 5 | + | |
5 | 6 | | |
6 | 7 | | |
7 | 8 | | |
| |||
158 | 159 | | |
159 | 160 | | |
160 | 161 | | |
161 | | - | |
162 | | - | |
| 162 | + | |
| 163 | + | |
163 | 164 | | |
164 | 165 | | |
165 | 166 | | |
| |||
Lines changed: 0 additions & 7 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
131 | 131 | | |
132 | 132 | | |
133 | 133 | | |
134 | | - | |
135 | | - | |
136 | | - | |
137 | | - | |
138 | | - | |
139 | | - | |
140 | | - | |
141 | 134 | | |
0 commit comments