Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

patch with tag collision test #8567

Merged
merged 1 commit into from
Nov 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 15 additions & 3 deletions go/libraries/doltcore/diff/table_deltas.go
Original file line number Diff line number Diff line change
Expand Up @@ -320,9 +320,21 @@ func matchTableDeltas(fromDeltas, toDeltas []TableDelta) (deltas []TableDelta) {
}

func schemasOverlap(from, to schema.Schema) bool {
f := set.NewUint64Set(from.GetAllCols().Tags)
t := set.NewUint64Set(to.GetAllCols().Tags)
return f.Intersection(t).Size() > 0
fromCols := from.GetAllCols()
toCols := to.GetAllCols()
fromColSet := set.NewUint64Set(fromCols.Tags)
toColSet := set.NewUint64Set(toCols.Tags)

overlappingTags := fromColSet.Intersection(toColSet)
numOverlaps := overlappingTags.Size()
for _, tag := range overlappingTags.AsSlice() {
fromCol, _ := fromCols.GetByTag(tag)
toCol, _ := toCols.GetByTag(tag)
if fromCol.Name != toCol.Name {
numOverlaps--
}
}
return numOverlaps > 0
}

// IsAdd returns true if the table was added between the fromRoot and toRoot.
Expand Down
99 changes: 99 additions & 0 deletions go/libraries/doltcore/sqle/enginetest/dolt_queries_diff.go
Original file line number Diff line number Diff line change
Expand Up @@ -3639,6 +3639,105 @@ var PatchTableFunctionScriptTests = []queries.ScriptTest{
},
},
},
{
Name: "tag collision",
SetUpScript: []string{
"CALL dolt_checkout('-b', 'other')",
"CREATE TABLE `MOTOR_TARIFA_COEFICIENTE_RIESGO_144_075_01` (\n" +
" `ID` varchar(8) NOT NULL,\n" +
" `PRODUCTO` varchar(255),\n" +
" `TARIFA` int,\n" +
" `VERSION_INICIO` int,\n" +
" `VERSION_FIN` int,\n" +
" `COBERTURA` varchar(255),\n" +
" `INDICADOR_NM` varchar(255),\n" +
" `ANOS_COMPANIA_PROCEDENCIA_MIN` int,\n" +
" `ANOS_COMPANIA_PROCEDENCIA_MAX` int,\n" +
" `COEFICIENTE` double,\n" +
" `DWB_IDENTITY` varchar(64),\n" +
" PRIMARY KEY (`ID`)\n" +
") ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_bin;",
"CREATE TABLE `MOTOR_TARIFA_COEFICIENTE_RIESGO_144_075` (\n" +
" `ID` varchar(8) NOT NULL,\n" +
" `PRODUCTO` varchar(255),\n" +
" `TARIFA` int,\n" +
" `VERSION_INICIO` int,\n" +
" `VERSION_FIN` int,\n" +
" `COBERTURA` varchar(255),\n" +
" `INDICADOR_NM` varchar(255),\n" +
" `ANOS_COMPANIA_PROCEDENCIA_MIN` int,\n" +
" `ANOS_COMPANIA_PROCEDENCIA_MAX` int,\n" +
" `COEFICIENTE` double,\n" +
" `DWB_IDENTITY` varchar(64),\n" +
" PRIMARY KEY (`ID`)\n" +
") ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_bin;",
"CALL dolt_commit('-A', '-m', 'create tables on other');",

"CALL dolt_checkout('main')",
"CREATE TABLE `MOTOR_TARIFA_COEFICIENTE_RIESGO_060` (\n" +
" `ID` varchar(8) NOT NULL,\n" +
" `PRODUCTO` varchar(255),\n" +
" `TARIFA` int,\n" +
" `VERSION_INICIO` int,\n" +
" `VERSION_FIN` int,\n" +
" `COBERTURA` varchar(255),\n" +
" `FRECUENCIA_PAGO` varchar(255),\n" +
" `COEFICIENTE` double,\n" +
" `DWB_IDENTITY` varchar(64),\n" +
" PRIMARY KEY (`ID`)\n" +
") ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_bin;",
"CREATE TABLE `MOTOR_TARIFA_COEFICIENTE_RIESGO_060_01` (\n" +
" `ID` varchar(8) NOT NULL,\n" +
" `PRODUCTO` varchar(255),\n" +
" `TARIFA` int,\n" +
" `VERSION_INICIO` int,\n" +
" `VERSION_FIN` int,\n" +
" `COBERTURA` varchar(255),\n" +
" `FRECUENCIA_PAGO` varchar(255),\n" +
" `COEFICIENTE` double,\n" +
" `DWB_IDENTITY` varchar(64),\n" +
" PRIMARY KEY (`ID`)\n" +
") ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_bin;",
"call dolt_commit('-A', '-m', 'create tables on main');",
},
Assertions: []queries.ScriptTestAssertion{
{
Query: "SELECT statement FROM dolt_patch('main', 'other') ORDER BY statement_order",
Expected: []sql.Row{
{"DROP TABLE `MOTOR_TARIFA_COEFICIENTE_RIESGO_060`;"},
{"DROP TABLE `MOTOR_TARIFA_COEFICIENTE_RIESGO_060_01`;"},
{"CREATE TABLE `MOTOR_TARIFA_COEFICIENTE_RIESGO_144_075` (\n" +
" `ID` varchar(8) NOT NULL,\n" +
" `PRODUCTO` varchar(255),\n" +
" `TARIFA` int,\n" +
" `VERSION_INICIO` int,\n" +
" `VERSION_FIN` int,\n" +
" `COBERTURA` varchar(255),\n" +
" `INDICADOR_NM` varchar(255),\n" +
" `ANOS_COMPANIA_PROCEDENCIA_MIN` int,\n" +
" `ANOS_COMPANIA_PROCEDENCIA_MAX` int,\n" +
" `COEFICIENTE` double,\n" +
" `DWB_IDENTITY` varchar(64),\n" +
" PRIMARY KEY (`ID`)\n" +
") ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_bin;"},
{"CREATE TABLE `MOTOR_TARIFA_COEFICIENTE_RIESGO_144_075_01` (\n" +
" `ID` varchar(8) NOT NULL,\n" +
" `PRODUCTO` varchar(255),\n" +
" `TARIFA` int,\n" +
" `VERSION_INICIO` int,\n" +
" `VERSION_FIN` int,\n" +
" `COBERTURA` varchar(255),\n" +
" `INDICADOR_NM` varchar(255),\n" +
" `ANOS_COMPANIA_PROCEDENCIA_MIN` int,\n" +
" `ANOS_COMPANIA_PROCEDENCIA_MAX` int,\n" +
" `COEFICIENTE` double,\n" +
" `DWB_IDENTITY` varchar(64),\n" +
" PRIMARY KEY (`ID`)\n" +
") ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_bin;"},
},
},
},
},
}

var UnscopedDiffSystemTableScriptTests = []queries.ScriptTest{
Expand Down
Loading