Commit a16a2fd
authored
[Spark] Add dataframe reader options to unblock non-additive schema changes (#4126)
## Description
Non-additive schema changes - DROP/RENAME and, since
https://github.com/databricks-eng/runtime/pull/124363 , type changes -
in streaming block the stream until the user sets a SQL conf to unblock
them:
```
spark.databricks.delta.streaming.allowSourceColumnRename
spark.databricks.delta.streaming.allowSourceColumnDrop
spark.databricks.delta.streaming.allowSourceColumnTypeChange
```
This change adds dataframe reader options as an alternative to SQL confs
to unblock non-additive schema changes:
```
spark.readStream
.option("allowSourceColumnRename", "true")
.option("allowSourceColumnDrop", "true")
.option("allowSourceColumnTypeChange", "true")
```
## How was this patch tested?
Extended existing tests in `DeltaSourceMetadataEvolutionSupportSuite` to
also cover dataframe reader options.
## This PR introduces the following *user-facing* changes
The error thrown on non-additive schema changes during streaming is
updated to suggest dataframe reader options in addition to SQL confs to
unblock the stream:
```
[DELTA_STREAMING_CANNOT_CONTINUE_PROCESSING_POST_SCHEMA_EVOLUTION]
We've detected one or more non-additive schema change(s) (DROP) between Delta version 1 and 2 in the Delta streaming source.
Please check if you want to manually propagate the schema change(s) to the sink table before we proceed with stream processing using the finalized schema at version 2.
Once you have fixed the schema of the sink table or have decided there is no need to fix, you can set the following configuration(s) to unblock the non-additive schema change(s) and continue stream processing.
<NEW>
Using dataframe reader option(s):
.option("allowSourceColumnDrop", "true")
<NEW>
Using SQL configuration(s):
To unblock for this particular stream just for this series of schema change(s):
SET spark.databricks.delta.streaming.allowSourceColumnDrop.ckpt_123456 = 2;
To unblock for this particular stream:
SET spark.databricks.delta.streaming.allowSourceColumnDrop.ckpt_123456 = "always";
To unblock for all streams:
SET spark.databricks.delta.streaming.allowSourceColumnDrop= "always";
```
The user can use the available reader option to unblock a given type of
non-additive schema change:
```
spark.readStream
.option("allowSourceColumnRename", "true")
.option("allowSourceColumnDrop", "true")
.option("allowSourceColumnTypeChange", "true")
```1 parent 50a99fd commit a16a2fd
10 files changed
Lines changed: 225 additions & 32 deletions
File tree
- spark/src
- main
- resources/error
- scala/org/apache/spark/sql/delta
- sources
- test/scala/org/apache/spark/sql/delta
- sources
- typewidening
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2319 | 2319 | | |
2320 | 2320 | | |
2321 | 2321 | | |
| 2322 | + | |
| 2323 | + | |
| 2324 | + | |
| 2325 | + | |
| 2326 | + | |
| 2327 | + | |
| 2328 | + | |
2322 | 2329 | | |
2323 | 2330 | | |
2324 | 2331 | | |
| |||
2338 | 2345 | | |
2339 | 2346 | | |
2340 | 2347 | | |
| 2348 | + | |
| 2349 | + | |
| 2350 | + | |
| 2351 | + | |
| 2352 | + | |
| 2353 | + | |
| 2354 | + | |
2341 | 2355 | | |
2342 | 2356 | | |
2343 | 2357 | | |
| |||
Lines changed: 18 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
3136 | 3136 | | |
3137 | 3137 | | |
3138 | 3138 | | |
| 3139 | + | |
3139 | 3140 | | |
| 3141 | + | |
| 3142 | + | |
| 3143 | + | |
| 3144 | + | |
| 3145 | + | |
| 3146 | + | |
3140 | 3147 | | |
3141 | 3148 | | |
3142 | 3149 | | |
| |||
3154 | 3161 | | |
3155 | 3162 | | |
3156 | 3163 | | |
| 3164 | + | |
| 3165 | + | |
3157 | 3166 | | |
3158 | 3167 | | |
3159 | 3168 | | |
| |||
3165 | 3174 | | |
3166 | 3175 | | |
3167 | 3176 | | |
| 3177 | + | |
3168 | 3178 | | |
3169 | 3179 | | |
3170 | 3180 | | |
| |||
3173 | 3183 | | |
3174 | 3184 | | |
3175 | 3185 | | |
| 3186 | + | |
| 3187 | + | |
| 3188 | + | |
| 3189 | + | |
| 3190 | + | |
| 3191 | + | |
3176 | 3192 | | |
3177 | 3193 | | |
3178 | 3194 | | |
| |||
3190 | 3206 | | |
3191 | 3207 | | |
3192 | 3208 | | |
| 3209 | + | |
| 3210 | + | |
3193 | 3211 | | |
3194 | 3212 | | |
3195 | 3213 | | |
| |||
Lines changed: 10 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
212 | 212 | | |
213 | 213 | | |
214 | 214 | | |
| 215 | + | |
| 216 | + | |
| 217 | + | |
| 218 | + | |
| 219 | + | |
| 220 | + | |
215 | 221 | | |
216 | 222 | | |
217 | 223 | | |
| |||
289 | 295 | | |
290 | 296 | | |
291 | 297 | | |
| 298 | + | |
| 299 | + | |
| 300 | + | |
| 301 | + | |
292 | 302 | | |
293 | 303 | | |
294 | 304 | | |
| |||
Lines changed: 1 addition & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
439 | 439 | | |
440 | 440 | | |
441 | 441 | | |
442 | | - | |
443 | 442 | | |
444 | 443 | | |
445 | 444 | | |
| |||
451 | 450 | | |
452 | 451 | | |
453 | 452 | | |
454 | | - | |
| 453 | + | |
455 | 454 | | |
456 | 455 | | |
457 | 456 | | |
| |||
Lines changed: 49 additions & 13 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
449 | 449 | | |
450 | 450 | | |
451 | 451 | | |
452 | | - | |
| 452 | + | |
453 | 453 | | |
454 | 454 | | |
455 | 455 | | |
| |||
460 | 460 | | |
461 | 461 | | |
462 | 462 | | |
| 463 | + | |
463 | 464 | | |
464 | 465 | | |
465 | 466 | | |
466 | 467 | | |
467 | 468 | | |
468 | | - | |
469 | 469 | | |
| 470 | + | |
| 471 | + | |
470 | 472 | | |
471 | 473 | | |
472 | 474 | | |
473 | 475 | | |
474 | 476 | | |
| 477 | + | |
475 | 478 | | |
476 | 479 | | |
477 | 480 | | |
478 | 481 | | |
479 | 482 | | |
| 483 | + | |
| 484 | + | |
480 | 485 | | |
481 | 486 | | |
482 | 487 | | |
483 | 488 | | |
484 | 489 | | |
485 | 490 | | |
486 | 491 | | |
| 492 | + | |
| 493 | + | |
487 | 494 | | |
488 | 495 | | |
489 | 496 | | |
490 | 497 | | |
491 | 498 | | |
492 | 499 | | |
| 500 | + | |
| 501 | + | |
493 | 502 | | |
494 | 503 | | |
495 | 504 | | |
496 | 505 | | |
497 | 506 | | |
498 | 507 | | |
| 508 | + | |
| 509 | + | |
499 | 510 | | |
500 | 511 | | |
501 | 512 | | |
502 | 513 | | |
503 | 514 | | |
504 | 515 | | |
| 516 | + | |
| 517 | + | |
505 | 518 | | |
506 | 519 | | |
507 | 520 | | |
| |||
541 | 554 | | |
542 | 555 | | |
543 | 556 | | |
544 | | - | |
| 557 | + | |
545 | 558 | | |
546 | 559 | | |
547 | 560 | | |
548 | 561 | | |
| 562 | + | |
549 | 563 | | |
550 | 564 | | |
551 | 565 | | |
| |||
561 | 575 | | |
562 | 576 | | |
563 | 577 | | |
564 | | - | |
| 578 | + | |
| 579 | + | |
| 580 | + | |
| 581 | + | |
| 582 | + | |
| 583 | + | |
| 584 | + | |
565 | 585 | | |
566 | | - | |
| 586 | + | |
| 587 | + | |
| 588 | + | |
567 | 589 | | |
568 | 590 | | |
| 591 | + | |
569 | 592 | | |
570 | 593 | | |
571 | 594 | | |
| |||
576 | 599 | | |
577 | 600 | | |
578 | 601 | | |
579 | | - | |
| 602 | + | |
580 | 603 | | |
581 | 604 | | |
582 | 605 | | |
| |||
595 | 618 | | |
596 | 619 | | |
597 | 620 | | |
598 | | - | |
| 621 | + | |
| 622 | + | |
599 | 623 | | |
600 | 624 | | |
601 | 625 | | |
602 | 626 | | |
603 | 627 | | |
604 | 628 | | |
605 | | - | |
| 629 | + | |
| 630 | + | |
| 631 | + | |
| 632 | + | |
| 633 | + | |
| 634 | + | |
| 635 | + | |
606 | 636 | | |
607 | 637 | | |
608 | 638 | | |
609 | 639 | | |
610 | | - | |
611 | | - | |
| 640 | + | |
| 641 | + | |
| 642 | + | |
612 | 643 | | |
613 | 644 | | |
614 | | - | |
| 645 | + | |
| 646 | + | |
615 | 647 | | |
616 | 648 | | |
617 | 649 | | |
618 | 650 | | |
619 | 651 | | |
620 | 652 | | |
621 | | - | |
| 653 | + | |
622 | 654 | | |
| 655 | + | |
623 | 656 | | |
624 | 657 | | |
625 | 658 | | |
| 659 | + | |
626 | 660 | | |
627 | 661 | | |
628 | 662 | | |
| |||
644 | 678 | | |
645 | 679 | | |
646 | 680 | | |
647 | | - | |
| 681 | + | |
648 | 682 | | |
649 | 683 | | |
650 | 684 | | |
| |||
656 | 690 | | |
657 | 691 | | |
658 | 692 | | |
| 693 | + | |
659 | 694 | | |
660 | 695 | | |
661 | 696 | | |
| |||
665 | 700 | | |
666 | 701 | | |
667 | 702 | | |
| 703 | + | |
668 | 704 | | |
669 | 705 | | |
670 | 706 | | |
| |||
Lines changed: 7 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
19 | 19 | | |
20 | 20 | | |
21 | 21 | | |
| 22 | + | |
22 | 23 | | |
23 | 24 | | |
24 | 25 | | |
| |||
33 | 34 | | |
34 | 35 | | |
35 | 36 | | |
| 37 | + | |
36 | 38 | | |
37 | 39 | | |
38 | 40 | | |
| |||
240 | 242 | | |
241 | 243 | | |
242 | 244 | | |
243 | | - | |
| 245 | + | |
244 | 246 | | |
245 | 247 | | |
246 | 248 | | |
| 249 | + | |
| 250 | + | |
247 | 251 | | |
248 | 252 | | |
249 | 253 | | |
| |||
296 | 300 | | |
297 | 301 | | |
298 | 302 | | |
299 | | - | |
| 303 | + | |
| 304 | + | |
300 | 305 | | |
301 | 306 | | |
302 | 307 | | |
| |||
Lines changed: 10 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2732 | 2732 | | |
2733 | 2733 | | |
2734 | 2734 | | |
| 2735 | + | |
2735 | 2736 | | |
2736 | 2737 | | |
2737 | 2738 | | |
| |||
2743 | 2744 | | |
2744 | 2745 | | |
2745 | 2746 | | |
| 2747 | + | |
| 2748 | + | |
| 2749 | + | |
| 2750 | + | |
| 2751 | + | |
| 2752 | + | |
2746 | 2753 | | |
2747 | 2754 | | |
2748 | 2755 | | |
| |||
2760 | 2767 | | |
2761 | 2768 | | |
2762 | 2769 | | |
| 2770 | + | |
2763 | 2771 | | |
2764 | 2772 | | |
2765 | 2773 | | |
| |||
2770 | 2778 | | |
2771 | 2779 | | |
2772 | 2780 | | |
| 2781 | + | |
| 2782 | + | |
2773 | 2783 | | |
2774 | 2784 | | |
2775 | 2785 | | |
| |||
0 commit comments