@@ -606,7 +606,7 @@ class TYtDataSinkTypeAnnotationTransformer : public TVisitorTransformerBase {
606
606
if (contentRowSpecs) {
607
607
size_t from = 0 ;
608
608
if (initialWrite) {
609
- ++ nextDescription.WriteValidateCount ;
609
+ nextDescription.RowSpecSortReady = true ;
610
610
if (nextDescription.IsReplaced ) {
611
611
nextDescription.RowSpec ->CopySortness (ctx, *contentRowSpecs.front (), TYqlRowSpecInfo::ECopySort::Exact);
612
612
if (auto contentNativeType = contentRowSpecs.front ()->GetNativeYtType ()) {
@@ -630,7 +630,7 @@ class TYtDataSinkTypeAnnotationTransformer : public TVisitorTransformerBase {
630
630
<< " setting cannot be used with a unsorted table" ));
631
631
return TStatus::Error;
632
632
}
633
- } else {
633
+ } else if (nextDescription. RowSpecSortReady ) {
634
634
if (!nextDescription.MonotonicKeys ) {
635
635
nextDescription.MonotonicKeys = monotonicKeys;
636
636
} else if (*nextDescription.MonotonicKeys != monotonicKeys) {
@@ -642,43 +642,50 @@ class TYtDataSinkTypeAnnotationTransformer : public TVisitorTransformerBase {
642
642
}
643
643
}
644
644
645
- const bool uniqueKeys = nextDescription.RowSpec ->UniqueKeys ;
646
- for (size_t s = from; s < contentRowSpecs.size (); ++s) {
647
- const bool hasSortChanges = nextDescription.RowSpec ->MakeCommonSortness (ctx, *contentRowSpecs[s]);
648
- const bool breaksSorting = hasSortChanges || !nextDescription.RowSpec ->CompareSortness (*contentRowSpecs[s], false );
649
- if (monotonicKeys) {
650
- if (breaksSorting) {
651
- ctx.AddError (TIssue (pos, TStringBuilder ()
652
- << " Inserts with "
653
- << ToString (EYtSettingType::MonotonicKeys).Quote ()
654
- << " setting must not change output table sorting" ));
655
- return TStatus::Error;
645
+ if (nextDescription.RowSpecSortReady ) {
646
+ const bool uniqueKeys = nextDescription.RowSpec ->UniqueKeys ;
647
+ for (size_t s = from; s < contentRowSpecs.size (); ++s) {
648
+ const bool hasSortChanges = nextDescription.RowSpec ->MakeCommonSortness (ctx, *contentRowSpecs[s]);
649
+ const bool breaksSorting = hasSortChanges || !nextDescription.RowSpec ->CompareSortness (*contentRowSpecs[s], false );
650
+ if (monotonicKeys) {
651
+ if (breaksSorting) {
652
+ ctx.AddError (TIssue (pos, TStringBuilder ()
653
+ << " Inserts with "
654
+ << ToString (EYtSettingType::MonotonicKeys).Quote ()
655
+ << " setting must not change output table sorting" ));
656
+ return TStatus::Error;
657
+ }
658
+ nextDescription.RowSpec ->UniqueKeys = uniqueKeys;
656
659
}
657
- nextDescription.RowSpec ->UniqueKeys = uniqueKeys;
658
- }
659
- if (nextDescription.WriteValidateCount < 2 ) {
660
- TStringBuilder warning;
661
- if (breaksSorting) {
662
- warning << " Sort order of written data differs from the order of "
663
- << outTableInfo.Name .Quote () << " table content. Result table content will be " ;
664
- if (nextDescription.RowSpec ->IsSorted ()) {
665
- warning << " ordered by " ;
666
- for (size_t i: xrange (nextDescription.RowSpec ->SortMembers .size ())) {
667
- if (i != 0 ) {
668
- warning << ' ,' ;
660
+ ui32 mutationId = 0 ;
661
+ if (auto setting = NYql::GetSetting (settings, EYtSettingType::MutationId)) {
662
+ mutationId = FromString<ui32>(setting->Child (1 )->Content ());
663
+ }
664
+
665
+ if (++nextDescription.WriteValidateCount [mutationId] < 2 ) {
666
+ TStringBuilder warning;
667
+ if (breaksSorting) {
668
+ warning << " Sort order of written data differs from the order of "
669
+ << outTableInfo.Name .Quote () << " table content. Result table content will be " ;
670
+ if (nextDescription.RowSpec ->IsSorted ()) {
671
+ warning << " ordered by " ;
672
+ for (size_t i: xrange (nextDescription.RowSpec ->SortMembers .size ())) {
673
+ if (i != 0 ) {
674
+ warning << ' ,' ;
675
+ }
676
+ warning << nextDescription.RowSpec ->SortMembers [i] << ' ('
677
+ << (nextDescription.RowSpec ->SortDirections [i] ? " asc" : " desc" ) << " )" ;
669
678
}
670
- warning << nextDescription. RowSpec -> SortMembers [i] << ' ( '
671
- << (nextDescription. RowSpec -> SortDirections [i] ? " asc " : " desc " ) << " ) " ;
679
+ } else {
680
+ warning << " unordered " ;
672
681
}
673
- } else {
674
- warning << " unordered " ;
682
+ } else if (uniqueKeys && !nextDescription. RowSpec -> UniqueKeys ) {
683
+ warning << " Result table content will have non unique keys " ;
675
684
}
676
- } else if (uniqueKeys && !nextDescription.RowSpec ->UniqueKeys ) {
677
- warning << " Result table content will have non unique keys" ;
678
- }
679
685
680
- if (warning && !ctx.AddWarning (YqlIssue (pos, EYqlIssueCode::TIssuesIds_EIssueCode_YT_SORT_ORDER_CHANGE, warning))) {
681
- return TStatus::Error;
686
+ if (warning && !ctx.AddWarning (YqlIssue (pos, EYqlIssueCode::TIssuesIds_EIssueCode_YT_SORT_ORDER_CHANGE, warning))) {
687
+ return TStatus::Error;
688
+ }
682
689
}
683
690
}
684
691
}
0 commit comments