Commit 43e0dd4
fix(spark): catch HoodieSchemaNotFoundException in 3-arg DefaultSource.createRelation
The 2-arg `createRelation(sqlContext, parameters)` overload wraps its body
in a try/catch that converts `HoodieSchemaNotFoundException` to
`EmptyRelation` (added in HUDI-7147 / #10689). The 3-arg
`createRelation(sqlContext, optParams, schema)` overload — which Spark's
`DataSource.resolveRelation()` invokes directly via the
`SchemaRelationProvider` path whenever a user-supplied schema is present
(e.g. `spark.read.schema(s).format("hudi").load(path)`, or HMS-catalog
resolution that already knows the schema) — has no such catch, so the
exception propagates and breaks query analysis.
Mirror the 2-arg catch on the 3-arg overload so behavior is symmetric:
schema-less Hudi tables resolve to an empty relation regardless of which
overload Spark invokes.
Also adds `TestCOWDataSource.testReadOfAnEmptyTableWithUserSuppliedSchema`,
a sibling of the existing `testReadOfAnEmptyTable` that exercises the
3-arg path.
Closes #18668
Co-Authored-By: Claude Opus 4.7 <[email protected]>1 parent 38db5ed commit 43e0dd4
2 files changed
Lines changed: 47 additions & 1 deletion
File tree
- hudi-spark-datasource
- hudi-spark-common/src/main/scala/org/apache/hudi
- hudi-spark/src/test/scala/org/apache/hudi/functional
Lines changed: 13 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
134 | 134 | | |
135 | 135 | | |
136 | 136 | | |
137 | | - | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
138 | 150 | | |
139 | 151 | | |
140 | 152 | | |
| |||
hudi-spark-datasource/hudi-spark/src/test/scala/org/apache/hudi/functional/TestCOWDataSource.scala
Lines changed: 34 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2214 | 2214 | | |
2215 | 2215 | | |
2216 | 2216 | | |
| 2217 | + | |
| 2218 | + | |
| 2219 | + | |
| 2220 | + | |
| 2221 | + | |
| 2222 | + | |
| 2223 | + | |
| 2224 | + | |
| 2225 | + | |
| 2226 | + | |
| 2227 | + | |
| 2228 | + | |
| 2229 | + | |
| 2230 | + | |
| 2231 | + | |
| 2232 | + | |
| 2233 | + | |
| 2234 | + | |
| 2235 | + | |
| 2236 | + | |
| 2237 | + | |
| 2238 | + | |
| 2239 | + | |
| 2240 | + | |
| 2241 | + | |
| 2242 | + | |
| 2243 | + | |
| 2244 | + | |
| 2245 | + | |
| 2246 | + | |
| 2247 | + | |
| 2248 | + | |
| 2249 | + | |
| 2250 | + | |
2217 | 2251 | | |
2218 | 2252 | | |
2219 | 2253 | | |
| |||
0 commit comments