Commit 4c2c191
authored
branch-4.1: [feature](paimon) Support Variant V2 writes (#66321)
### What problem does this PR solve?
Issue Number: Part of #65086
Problem Summary:
The Paimon JNI writer already supports primitive and complex Doris
columns, but a Doris Variant V2 value could not be written losslessly
because the generic Arrow path exposed Variant as JSON text. That loses
the native Variant `value` and `metadata` representation and does not
support Variant nested in ARRAY, MAP, or STRUCT.
This PR adds a Paimon-specific Variant V2 write protocol:
- maps Paimon VARIANT targets, including nested VARIANT nodes, to Doris
compute Variant V2 during analysis;
- requires `enable_variant_v2=true` and rejects legacy Variant V1 inputs
during analysis with an actionable error;
- transports Variant V2 through Arrow as `struct<value: binary,
metadata: binary>` while preserving SQL NULL separately from a Variant
null value;
- recursively applies the binary representation inside ARRAY, MAP, and
STRUCT;
- converts the Arrow pair to Paimon `GenericVariant` in the Java JNI
backend and uses Paimon SDK accessors to validate compatibility with the
bundled Paimon version;
- keeps the existing JSON Arrow representation as the default for
non-Paimon consumers.
#### Supported write scenarios
- `INSERT INTO ... VALUES` and `INSERT INTO ... SELECT`, including UNION
inputs and reordered/omitted columns.
- `INSERT OVERWRITE` and static partition writes.
- Append-only and primary-key tables, fixed and dynamic bucket modes,
and schema evolution involving VARIANT columns.
- Top-level VARIANT and VARIANT nested in ARRAY, MAP, STRUCT, and deeper
combinations.
- Scalar/object/array values, SQL NULL, Variant null, typed primitives,
long strings, and residual object fields.
- Paimon Parquet Variant shredding. Regression coverage verifies the
physical `typed_value` layout and values, Paimon unshredding,
type-mismatch fallback to residual bytes, and reading a table containing
both unshredded and shredded files.
#### Current limitations
- Variant writes are V2-only. When `enable_variant_v2=false`, or when a
legacy Variant V1 expression is supplied to a Paimon VARIANT target,
analysis fails intentionally.
- The write path uses the Java Paimon JNI backend.
- Doris-side querying of Paimon Variant V2 is outside this PR.
End-to-end logical readback is therefore verified with the Spark/Paimon
reader; raw Parquet shredding is independently verified through Doris's
S3 TVF.
- The added Paimon integration coverage uses Parquet, which is also the
format used to validate Variant shredding.
### Release note
Support writing Variant V2 values, including nested Variant values, from
Doris into Apache Paimon tables through the Java JNI writer. Set
`enable_variant_v2=true` before writing a Paimon table containing
VARIANT.
### Check List (For Author)
- Test
- [x] Regression test
- [ ] Unit Test
- [x] Manual test
- Debug FE and BE incremental builds.
- `./run-regression-test.sh --run -s
test_paimon_write_variant_shredding`
- `./run-regression-test.sh --run -s
test_paimon_write_variant_table_modes`
- Behavior changed:
- [ ] No.
- [x] Yes. Paimon VARIANT targets now accept Variant V2 writes when
enabled and reject disabled/V1 writes during analysis.
- Does this need documentation?
- [ ] No.
- [x] Yes. User-facing documentation can follow separately.
### Check List (For Reviewer who merge this PR)
- [ ] Confirm the release note
- [ ] Confirm test cases
- [ ] Confirm document
- [ ] Add branch pick label1 parent 1d147d8 commit 4c2c191
51 files changed
Lines changed: 2527 additions & 96 deletions
File tree
- be
- src
- core/data_type_serde
- exec/sink/writer/paimon
- exprs/function/cast/variant_v2
- test
- core/data_type_serde
- exprs/function/cast
- fe
- be-java-extensions
- java-udf/src/main/resources
- paimon-connector/src
- main/java/org/apache/doris/paimon
- test/java/org/apache/doris/paimon
- fe-core
- src
- main/java/org/apache/doris
- datasource/paimon
- source
- nereids
- rules
- analysis
- expression/check
- trees
- expressions/functions/scalar
- plans/commands/insert
- types
- util
- test/java/org/apache/doris
- datasource/paimon
- source
- nereids
- rules
- analysis
- expression/check
- util
- regression-test
- data/paimon_write
- suites
- paimon_write
- variant_p0
Some content is hidden
Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
Lines changed: 133 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
18 | 18 | | |
19 | 19 | | |
20 | 20 | | |
| 21 | + | |
21 | 22 | | |
22 | 23 | | |
23 | 24 | | |
| |||
175 | 176 | | |
176 | 177 | | |
177 | 178 | | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
| 195 | + | |
| 196 | + | |
| 197 | + | |
| 198 | + | |
| 199 | + | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
| 203 | + | |
| 204 | + | |
| 205 | + | |
| 206 | + | |
| 207 | + | |
| 208 | + | |
| 209 | + | |
| 210 | + | |
| 211 | + | |
| 212 | + | |
| 213 | + | |
| 214 | + | |
| 215 | + | |
| 216 | + | |
| 217 | + | |
| 218 | + | |
| 219 | + | |
| 220 | + | |
| 221 | + | |
| 222 | + | |
| 223 | + | |
| 224 | + | |
| 225 | + | |
| 226 | + | |
| 227 | + | |
| 228 | + | |
| 229 | + | |
| 230 | + | |
| 231 | + | |
| 232 | + | |
| 233 | + | |
| 234 | + | |
| 235 | + | |
| 236 | + | |
| 237 | + | |
| 238 | + | |
| 239 | + | |
| 240 | + | |
| 241 | + | |
| 242 | + | |
| 243 | + | |
| 244 | + | |
| 245 | + | |
| 246 | + | |
| 247 | + | |
| 248 | + | |
| 249 | + | |
| 250 | + | |
| 251 | + | |
| 252 | + | |
| 253 | + | |
| 254 | + | |
| 255 | + | |
| 256 | + | |
| 257 | + | |
| 258 | + | |
| 259 | + | |
| 260 | + | |
| 261 | + | |
| 262 | + | |
| 263 | + | |
| 264 | + | |
| 265 | + | |
| 266 | + | |
| 267 | + | |
| 268 | + | |
| 269 | + | |
| 270 | + | |
| 271 | + | |
| 272 | + | |
| 273 | + | |
| 274 | + | |
| 275 | + | |
| 276 | + | |
| 277 | + | |
| 278 | + | |
| 279 | + | |
| 280 | + | |
| 281 | + | |
| 282 | + | |
| 283 | + | |
| 284 | + | |
| 285 | + | |
| 286 | + | |
| 287 | + | |
| 288 | + | |
| 289 | + | |
| 290 | + | |
| 291 | + | |
| 292 | + | |
| 293 | + | |
| 294 | + | |
| 295 | + | |
| 296 | + | |
| 297 | + | |
| 298 | + | |
| 299 | + | |
| 300 | + | |
| 301 | + | |
| 302 | + | |
| 303 | + | |
| 304 | + | |
| 305 | + | |
178 | 306 | | |
179 | 307 | | |
180 | 308 | | |
| |||
537 | 665 | | |
538 | 666 | | |
539 | 667 | | |
| 668 | + | |
| 669 | + | |
| 670 | + | |
| 671 | + | |
| 672 | + | |
540 | 673 | | |
541 | 674 | | |
542 | 675 | | |
| |||
Lines changed: 69 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
32 | 32 | | |
33 | 33 | | |
34 | 34 | | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
35 | 39 | | |
36 | 40 | | |
37 | 41 | | |
| |||
69 | 73 | | |
70 | 74 | | |
71 | 75 | | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
72 | 139 | | |
73 | 140 | | |
74 | 141 | | |
| |||
359 | 426 | | |
360 | 427 | | |
361 | 428 | | |
| 429 | + | |
362 | 430 | | |
363 | | - | |
| 431 | + | |
364 | 432 | | |
365 | 433 | | |
366 | 434 | | |
| |||
Lines changed: 4 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
137 | 137 | | |
138 | 138 | | |
139 | 139 | | |
140 | | - | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
141 | 143 | | |
142 | 144 | | |
143 | 145 | | |
| |||
196 | 198 | | |
197 | 199 | | |
198 | 200 | | |
199 | | - | |
| 201 | + | |
200 | 202 | | |
201 | 203 | | |
202 | 204 | | |
| |||
Lines changed: 1 addition & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
70 | 70 | | |
71 | 71 | | |
72 | 72 | | |
| 73 | + | |
73 | 74 | | |
74 | 75 | | |
75 | 76 | | |
| |||
Lines changed: 76 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
15 | 15 | | |
16 | 16 | | |
17 | 17 | | |
| 18 | + | |
18 | 19 | | |
| 20 | + | |
19 | 21 | | |
20 | 22 | | |
21 | 23 | | |
| |||
198 | 200 | | |
199 | 201 | | |
200 | 202 | | |
| 203 | + | |
| 204 | + | |
| 205 | + | |
| 206 | + | |
| 207 | + | |
| 208 | + | |
| 209 | + | |
| 210 | + | |
| 211 | + | |
| 212 | + | |
| 213 | + | |
| 214 | + | |
| 215 | + | |
| 216 | + | |
| 217 | + | |
| 218 | + | |
| 219 | + | |
| 220 | + | |
| 221 | + | |
| 222 | + | |
| 223 | + | |
| 224 | + | |
| 225 | + | |
| 226 | + | |
| 227 | + | |
| 228 | + | |
| 229 | + | |
| 230 | + | |
| 231 | + | |
| 232 | + | |
| 233 | + | |
| 234 | + | |
| 235 | + | |
| 236 | + | |
| 237 | + | |
| 238 | + | |
| 239 | + | |
| 240 | + | |
| 241 | + | |
| 242 | + | |
| 243 | + | |
| 244 | + | |
| 245 | + | |
| 246 | + | |
201 | 247 | | |
202 | 248 | | |
203 | 249 | | |
| |||
379 | 425 | | |
380 | 426 | | |
381 | 427 | | |
| 428 | + | |
| 429 | + | |
| 430 | + | |
| 431 | + | |
| 432 | + | |
| 433 | + | |
| 434 | + | |
| 435 | + | |
| 436 | + | |
| 437 | + | |
| 438 | + | |
| 439 | + | |
| 440 | + | |
| 441 | + | |
| 442 | + | |
| 443 | + | |
| 444 | + | |
| 445 | + | |
| 446 | + | |
| 447 | + | |
| 448 | + | |
| 449 | + | |
| 450 | + | |
| 451 | + | |
| 452 | + | |
| 453 | + | |
| 454 | + | |
| 455 | + | |
| 456 | + | |
| 457 | + | |
382 | 458 | | |
0 commit comments