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

fix keyless duplicate update #5514

Merged
merged 4 commits into from
Mar 10, 2023
Merged

fix keyless duplicate update #5514

merged 4 commits into from
Mar 10, 2023

Conversation

jycor
Copy link
Contributor

@jycor jycor commented Mar 8, 2023

@timsehn
Copy link
Contributor

timsehn commented Mar 8, 2023

Does this also fix #5433 ?

@jycor
Copy link
Contributor Author

jycor commented Mar 8, 2023

Nice catch, it looks like this does address #5433
Will add this case when writing the tests

Copy link
Contributor

@max-hoffman max-hoffman left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm, small suggestion so that we don't have to add a cardinality offset every time we use the ordinality mapping

@@ -160,7 +160,8 @@ func (k prollyKeylessWriter) uniqueKeyError(ctx context.Context, keyStr string,
vd := k.valBld.Desc
for from := range k.valMap {
to := k.valMap.MapOrdinal(from)
if existing[to], err = index.GetField(ctx, vd, from, value, k.mut.NodeStore()); err != nil {
// offset from index for keyless rows, as first field is the count
if existing[to], err = index.GetField(ctx, vd, from+1, value, k.mut.NodeStore()); err != nil {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it might be better for valMap to just have the right mappings, embed the cardinality offset so that other methods don't have to add 1 everywhere

Copy link
Contributor Author

@jycor jycor Mar 9, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That was my initial approach, but I don't think the valMap or the tuple descriptors can tell if the first field is encoding the cardinality or a column of type uint64. Maybe it's worth modifying them? or changing MapOrdinal to take a keyless bool or something like that?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

something like this?

func ordinalMappingsFromSchema(from sql.Schema, to schema.Schema) (km, vm val.OrdinalMapping) {
	keyless := schema.IsKeyless(to)
	km = makeOrdinalMapping(from, to.GetPKCols(), keyless)
	vm = makeOrdinalMapping(from, to.GetNonPKCols(), keyless)
	return
}

@jycor jycor merged commit a15b69f into main Mar 10, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants