nebius/SWE-rebench-V2-PRs huggingface dataset:
Repository: vitessio/vitess
Pull request #5883 (2020-03-03 09:48:32)

Instead of failing when trying to skip updates, fallback on slower mode
When updating consistent lookup vindexes, we see if anything really did change,
before updating the vindex. If nothing changes, we can skip updating the vindex.

Sometimes, we encounter errors when checking if we can shortcut the updates.
Instead of passing on there errors, we'll now fall back on the slower mode and execute the update.

Signed-off-by: Andres Taylor <andres@planetscale.com>


Patch:
diff --git a/go/vt/vtgate/vindexes/consistent_lookup.go b/go/vt/vtgate/vindexes/consistent_lookup.go
index 0d62dca4b7..1c64d218cc 100644
--- a/go/vt/vtgate/vindexes/consistent_lookup.go
+++ b/go/vt/vtgate/vindexes/consistent_lookup.go
@@ -307,10 +307,8 @@ func (lu *clCommon) Update(vcursor VCursor, oldValues []sqltypes.Value, ksid []b
 	equal := true
 	for i := range oldValues {
 		result, err := sqltypes.NullsafeCompare(oldValues[i], newValues[i])
-		if err != nil {
-			return err
-		}
-		if result != 0 {
+		// errors from NullsafeCompare can be ignored. if they are real problems, we'll see them in the Create/Update
+		if err != nil || result != 0 {
 			equal = false
 			break
 		}


Test patch:
diff --git a/go/vt/vtgate/vindexes/consistent_lookup_test.go b/go/vt/vtgate/vindexes/consistent_lookup_test.go
index 54a41c005e..dbb95dbc4d 100644
--- a/go/vt/vtgate/vindexes/consistent_lookup_test.go
+++ b/go/vt/vtgate/vindexes/consistent_lookup_test.go
@@ -445,6 +445,41 @@ func TestConsistentLookupNoUpdate(t *testing.T) {
 	vc.verifyLog(t, []string{})
 }
 
+func TestConsistentLookupUpdateBecauseUncomparableTypes(t *testing.T) {
+	lookup := createConsistentLookup(t, "consistent_lookup", false)
+	vc := &loggingVCursor{}
+
+	type test struct {
+		typ querypb.Type
+		val string
+	}
+
+	tests := []test{
+		{querypb.Type_TEXT, "some string"},
+		{querypb.Type_VARCHAR, "some string"},
+		{querypb.Type_CHAR, "some string"},
+		{querypb.Type_BIT, "some string"},
+		{querypb.Type_ENUM, "some string"},
+		{querypb.Type_SET, "some string"},
+		{querypb.Type_GEOMETRY, "some string"},
+		{querypb.Type_JSON, "some string"},
+	}
+
+	for _, val := range tests {
+		t.Run(val.typ.String(), func(t *testing.T) {
+			vc.AddResult(&sqltypes.Result{}, nil)
+			vc.AddResult(&sqltypes.Result{}, nil)
+			sqlVal, err := sqltypes.NewValue(val.typ, []byte(val.val))
+			require.NoError(t, err)
+
+			err = lookup.(Lookup).Update(vc, []sqltypes.Value{sqlVal, sqlVal}, []byte("test"), []sqltypes.Value{sqlVal, sqlVal})
+			require.NoError(t, err)
+			require.NotEmpty(t, vc.log)
+			vc.log = nil
+		})
+	}
+}
+
 func createConsistentLookup(t *testing.T, name string, writeOnly bool) SingleColumn {
 	t.Helper()
 	write := "false"
Repository: vitessio/vitess
Pull request #8593 (2021-08-05 10:42:46)

Fail plan for unsupported aggregate function
Signed-off-by: Harshit Gangal <harshit@planetscale.com>

<!--
  Thank you for your contribution to the Vitess project.
  How to contribute: https://vitess.io/docs/contributing/
  Please first make sure there is an open Issue to discuss the feature/fix suggested in this PR.
  If this is a new feature, please mark the Issue as "RFC".
 -->

<!-- if this PR is Work in Progress please create it as a Draft Pull Request -->

## Description
<!-- A few sentences describing the overall goals of the pull request's commits. -->
<!-- If this is a bug fix and you think the fix should be backported, please write so. -->

Fail query plan for unsupported aggregate function which needs handling on VTGate.

## Related Issue(s)
<!-- List related issues and pull requests. If this PR fixes an issue, please add it using Fixes #????  -->

#7280 

## Checklist
- [ ] Should this PR be backported?
- [x] Tests were added or are not required
- [x] Documentation was added or is not required

## Deployment Notes
<!-- Notes regarding deployment of the contained body of work. These should note any db migrations, etc. -->


Patch:
diff --git a/go/vt/vtgate/planbuilder/horizon_planning.go b/go/vt/vtgate/planbuilder/horizon_planning.go
index a9df10b6cd..5f7f8d555d 100644
--- a/go/vt/vtgate/planbuilder/horizon_planning.go
+++ b/go/vt/vtgate/planbuilder/horizon_planning.go
@@ -166,7 +166,10 @@ func (hp *horizonPlanning) planAggregations() error {
 		if !isFunc {
 			return vterrors.Errorf(vtrpcpb.Code_UNIMPLEMENTED, "unsupported: in scatter query: complex aggregate expression")
 		}
-		opcode := engine.SupportedAggregates[fExpr.Name.Lowered()]
+		opcode, found := engine.SupportedAggregates[fExpr.Name.Lowered()]
+		if !found {
+			return vterrors.Errorf(vtrpcpb.Code_UNIMPLEMENTED, "unsupported: in scatter query: complex aggregate expression")
+		}
 		handleDistinct, innerAliased, err := hp.needDistinctHandling(fExpr, opcode, oa.input)
 		if err != nil {
 			return err


Test patch:
diff --git a/go/vt/vtgate/planbuilder/testdata/unsupported_cases.txt b/go/vt/vtgate/planbuilder/testdata/unsupported_cases.txt
index a93bb6585c..94cc9f27af 100644
--- a/go/vt/vtgate/planbuilder/testdata/unsupported_cases.txt
+++ b/go/vt/vtgate/planbuilder/testdata/unsupported_cases.txt
@@ -478,3 +478,8 @@ Gen4 plan same as above
   }
 }
 Gen4 error: In aggregated query without GROUP BY, expression of SELECT list contains nonaggregated column 'id'; this is incompatible with sql_mode=only_full_group_by
+
+# avg function on scatter query
+"select avg(id) from user"
+"unsupported: in scatter query: complex aggregate expression"
+Gen4 plan same as above
Repository: vitessio/vitess
Pull request #8647 (2021-08-19 12:49:38)

Gen4: Removed default case when dealing with weird/non-unique vindex predicate
## Description
This pull request removes the `Gen4 unsupported error` when dealing with vindex predicates other than `equal`, `in`, `not in`, `like`.

## Checklist
- [x] Tests were added or are not required
- [x] Documentation was added or is not required



Patch:
diff --git a/go/vt/vtgate/planbuilder/jointree.go b/go/vt/vtgate/planbuilder/jointree.go
index 585d43da72..fea29248ed 100644
--- a/go/vt/vtgate/planbuilder/jointree.go
+++ b/go/vt/vtgate/planbuilder/jointree.go
@@ -437,9 +437,6 @@ func (rp *routeTree) searchForNewVindexes(predicates []sqlparser.Expr) (bool, er
 					return false, err
 				}
 				newVindexFound = newVindexFound || found
-
-			default:
-				return false, semantics.Gen4NotSupportedF("%s", sqlparser.String(filter))
 			}
 		case *sqlparser.IsExpr:
 			found, err := rp.planIsExpr(node)


Test patch:
diff --git a/go/vt/vtgate/planbuilder/testdata/filter_cases.txt b/go/vt/vtgate/planbuilder/testdata/filter_cases.txt
index da63bd2338..db5e4bc756 100644
--- a/go/vt/vtgate/planbuilder/testdata/filter_cases.txt
+++ b/go/vt/vtgate/planbuilder/testdata/filter_cases.txt
@@ -2091,3 +2091,22 @@ Gen4 plan same as above
     "Vindex": "vindex1"
   }
 }
+
+# non unique predicate on vindex
+"select id from user where user.id > 5"
+{
+  "QueryType": "SELECT",
+  "Original": "select id from user where user.id \u003e 5",
+  "Instructions": {
+    "OperatorType": "Route",
+    "Variant": "SelectScatter",
+    "Keyspace": {
+      "Name": "user",
+      "Sharded": true
+    },
+    "FieldQuery": "select id from `user` where 1 != 1",
+    "Query": "select id from `user` where `user`.id \u003e 5",
+    "Table": "`user`"
+  }
+}
+Gen4 plan same as above
Repository: vitessio/vitess
Pull request #9131 (2021-11-03 11:18:11)

fix compilation error on main
## Description
Fixes an error that crept in by merging two separate PRs

## Checklist
- [x] Tests were added or are not required
- [x] Documentation was added or is not required



Patch:
diff --git a/go/vt/vtgate/evalengine/arithmetic.go b/go/vt/vtgate/evalengine/arithmetic.go
index c96b5d4950..11809fbf62 100644
--- a/go/vt/vtgate/evalengine/arithmetic.go
+++ b/go/vt/vtgate/evalengine/arithmetic.go
@@ -224,7 +224,7 @@ func NullsafeCompare(v1, v2 sqltypes.Value, collationID collations.ID) (int, err
 		return bytes.Compare(v1.ToBytes(), v2.ToBytes()), nil
 	}
 	if v1.IsText() && v2.IsText() && collationID != collations.Unknown {
-		collation := collations.FromID(collationID)
+		collation := collations.Default().LookupByID(collationID)
 		if collation == nil {
 			return 0, UnsupportedCollationError{
 				ID: collationID,


Test patch:
diff --git a/go/vt/vtgate/engine/ordered_aggregate_test.go b/go/vt/vtgate/engine/ordered_aggregate_test.go
index 80fadaaf6b..000b79fa63 100644
--- a/go/vt/vtgate/engine/ordered_aggregate_test.go
+++ b/go/vt/vtgate/engine/ordered_aggregate_test.go
@@ -1073,7 +1073,7 @@ func TestOrderedAggregateCollate(t *testing.T) {
 		)},
 	}
 
-	collationID, _ := collations.IDFromName("utf8mb4_0900_ai_ci")
+	collationID, _ := collations.Default().LookupID("utf8mb4_0900_ai_ci")
 	oa := &OrderedAggregate{
 		Aggregates: []*AggregateParams{{
 			Opcode: AggregateCount,
@@ -1115,7 +1115,7 @@ func TestOrderedAggregateCollateAS(t *testing.T) {
 		)},
 	}
 
-	collationID, _ := collations.IDFromName("utf8mb4_0900_as_ci")
+	collationID, _ := collations.Default().LookupID("utf8mb4_0900_as_ci")
 	oa := &OrderedAggregate{
 		Aggregates: []*AggregateParams{{
 			Opcode: AggregateCount,
@@ -1159,7 +1159,7 @@ func TestOrderedAggregateCollateKS(t *testing.T) {
 		)},
 	}
 
-	collationID, _ := collations.IDFromName("utf8mb4_ja_0900_as_cs_ks")
+	collationID, _ := collations.Default().LookupID("utf8mb4_ja_0900_as_cs_ks")
 	oa := &OrderedAggregate{
 		Aggregates: []*AggregateParams{{
 			Opcode: AggregateCount,
diff --git a/go/vt/vtgate/evalengine/arithmetic_test.go b/go/vt/vtgate/evalengine/arithmetic_test.go
index dc57600703..882610293d 100644
--- a/go/vt/vtgate/evalengine/arithmetic_test.go
+++ b/go/vt/vtgate/evalengine/arithmetic_test.go
@@ -600,7 +600,7 @@ func TestNullsafeCompare(t *testing.T) {
 }
 
 func getCollationID(collation string) collations.ID {
-	id, _ := collations.IDFromName(collation)
+	id, _ := collations.Default().LookupID(collation)
 	return id
 }
Repository: uber/makisu
Pull request #361 (2021-03-16 03:39:34)

Forgive the case when a whiteout file trying to cover nonexistent path 
Retry #358 

This error happens sometimes with python package's .dist-info or .pth files. For example, installing aiohttp package in a conda environment, then when applying cache of layer, this error message happens often:

[error] 2021-03-09 17:36:12.468002: failed to execute build plan: execute stage: build stage 0: build node: apply cache: untar reader: add hdr from tar to layer: update memfs with file /home/ray/anaconda3/lib/python3.7/site-packages/.wh.aiohttp-3.7.4.dist-info: whiteout nonexistent path /home/ray/anaconda3/lib/python3.7/site-packages/aiohttp-3.7.4.dist-info
Those files were probably created or removed asynchronously.
It doesn't hurt to ignore this case; Change to a warning message instead.


Patch:
diff --git a/lib/snapshot/mem_layer.go b/lib/snapshot/mem_layer.go
index 66ea789..96a14e4 100644
--- a/lib/snapshot/mem_layer.go
+++ b/lib/snapshot/mem_layer.go
@@ -23,6 +23,7 @@ import (
 	"sort"
 	"strings"
 
+	"github.com/uber/makisu/lib/log"
 	"github.com/uber/makisu/lib/pathutils"
 	"github.com/uber/makisu/lib/tario"
 )
@@ -114,7 +115,9 @@ func (f *whiteoutMemFile) updateMemFS(node *memFSNode) error {
 			if i != len(parts)-1 {
 				return fmt.Errorf("missing intermediate dir %s in %s", part, f.del)
 			}
-			return fmt.Errorf("whiteout nonexistent path %s", f.del)
+			// This could happen to files that's cleaned up in the background, like
+			// python package's .dist-info or .pth file.
+			log.Warnf("Trying to whiteout nonexistent path: %s", f.del)
 		}
 	}
 	return nil


Test patch:
diff --git a/lib/snapshot/mem_fs_test.go b/lib/snapshot/mem_fs_test.go
index 1eb9573..9c91cda 100644
--- a/lib/snapshot/mem_fs_test.go
+++ b/lib/snapshot/mem_fs_test.go
@@ -303,7 +303,7 @@ func TestUpdateMemFS(t *testing.T) {
 		require.Equal(os.ErrNotExist, err)
 	})
 
-	t.Run("WhiteoutNonexistentCausesError", func(t *testing.T) {
+	t.Run("WhiteoutNonexistentNotCausingError", func(t *testing.T) {
 		require := require.New(t)
 
 		tmpRoot, err := ioutil.TempDir("/tmp", "makisu-test")
@@ -333,7 +333,7 @@ func TestUpdateMemFS(t *testing.T) {
 		require.NoError(addDirectoryToLayer(l2, tmpRoot, dst21, 0755))
 		dst22 := "/test11/.wh.test13"
 		require.NoError(addDirectoryToLayer(l2, tmpRoot, dst22, 0755))
-		require.Error(fs.merge(l2))
+		require.NoError(fs.merge(l2))
 	})
 }