-
-
Notifications
You must be signed in to change notification settings - Fork 211
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
Correctly handle indexes on virtual columns #2641
Conversation
Notably, there's a comment in the previous logic for adding columns with default/generated values:
However, it appears that in fact the exact opposite is true: the column indexes computed during analysis of an |
f74a998
to
0f9211a
Compare
…currently panics.
0f9211a
to
5bea118
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, thanks for the fixes
}, | ||
}, | ||
{ | ||
Name: "creating unique index on stored generated column", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Test for enforcing uniqueness?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
{ | ||
Query: "select * from t1 where b = 2 order by a", | ||
Expected: []sql.Row{{1, float64(2)}}, | ||
Skip: true, // https://github.com/dolthub/dolt/issues/8276 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should this still be skipped?
}, | ||
}, | ||
{ | ||
Name: "creating unique index on virtual generated column", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Check uniqueness is enforced?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
@@ -276,6 +276,14 @@ func (td *TableData) numRows(ctx *sql.Context) (uint64, error) { | |||
// throws an error if any two or more rows share the same |cols| values. | |||
func (td *TableData) errIfDuplicateEntryExist(cols []string, idxName string) error { | |||
columnMapping, err := td.columnIndexes(cols) | |||
|
|||
// We currently skip validating duplicates on unique virtual columns. | |||
for _, i := range columnMapping { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should have a skipped test assertion for this
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done, and added comments.
Unfortunately the assertion will get skipped for both GMS and Dolt, but I don't think we have a way to just disable it for GMS.
Fixes dolthub/dolt#8276
Lots of small behaviors around virtual columns were not working correctly:
This PR adds tests for these cases and fixes them by tweaking the logic for projections on tables with generated columns.