Skip to content

Zachmu/index or bug fix #22

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

Merged
merged 40 commits into from
Nov 6, 2019
Merged

Zachmu/index or bug fix #22

merged 40 commits into from
Nov 6, 2019

Conversation

zachmu
Copy link
Member

@zachmu zachmu commented Nov 5, 2019

Fixed a bug in indexing code that would cause queries to return incorrect results. Along the way, implemented index capabilities for the in-memory tables (only for correctness verification), and expanded engine_test to test every combination of indexes, partitions, and parallelism.

zachmu added 30 commits October 28, 2019 13:59

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
… that cannot be merged together. This partial index usage resulted in pushdown getting an IndexableTable for only one side of the OR expression, returning incorrect results.

Signed-off-by: Zach Musgrave <[email protected]>
… using them in engine_test.go to reproduce index-related bugs in SELECT statements

Signed-off-by: Zach Musgrave <[email protected]>
…ementations necessarily need to be coupled, so starting down that path.

Signed-off-by: Zach Musgrave <[email protected]>
…un queries with every combination of indexed / parallel / partitioned

Signed-off-by: Zach Musgrave <[email protected]>
…s over each in the parent table looking for matches -- not here to make queries faster, just to test if they give correct results when indexes are involved.

Signed-off-by: Zach Musgrave <[email protected]>
…tering the number of partitions for the test setup

Signed-off-by: Zach Musgrave <[email protected]>
Signed-off-by: Zach Musgrave <[email protected]>
… and intersect functions

Signed-off-by: Zach Musgrave <[email protected]>
Signed-off-by: Zach Musgrave <[email protected]>
…ion for between operation)

Signed-off-by: Zach Musgrave <[email protected]>
Signed-off-by: Zach Musgrave <[email protected]>
…ilures (probably a mistake in the index Values() implementation)

Signed-off-by: Zach Musgrave <[email protected]>
… to index structs, introduced some new helper functions to cut down on verbosity of test literals

Signed-off-by: Zach Musgrave <[email protected]>
Signed-off-by: Zach Musgrave <[email protected]>
@zachmu zachmu requested a review from Hydrocharged November 5, 2019 23:01
@zachmu
Copy link
Member Author

zachmu commented Nov 5, 2019

@Hydrocharged , please give this a quick sanity check. I know it's big, so don't worry about verifying every line. But let me know if there are any glaring errors I should fix before sending this to src-d.

…ummy from the name. Moved a few interface assertions left over from assignindex_test into the type files.

Signed-off-by: Zach Musgrave <[email protected]>
Copy link
Contributor

@Hydrocharged Hydrocharged left a comment

Choose a reason for hiding this comment

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

I didn't see any bugs or anything that jumped out! Just had a few small questions.

}

func (m *MergedIndexLookup) Indexes() []string {
panic("implement me")
Copy link
Contributor

Choose a reason for hiding this comment

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

Assuming we aren't implementing these just yet?

Copy link
Member Author

Choose a reason for hiding this comment

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

Never going to be implemented -- this method only matters for a primary index, so that the engine can match columns to indexes. For this synthetic index, that never happens.

Copy link
Contributor

Choose a reason for hiding this comment

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

Ah gotcha. I'd change the panic message then in that case.

}

func (m *MergedIndexLookup) Difference(...sql.IndexLookup) sql.IndexLookup {
panic("not implemented")
Copy link
Contributor

Choose a reason for hiding this comment

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

Further down we have panic("negateIndexLookup.Difference is not implemented"), would seem a bit more consistent if this was also panic("mergedIndexLookup.Difference is not implemented"), but this is about a 0.1% on the importance scale lol

Copy link
Member Author

Choose a reason for hiding this comment

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

Good call, I'll fix these.

return float64(val), sql.Float64
case string:
return val, sql.Text
default:panic(fmt.Sprintf("Unsupported type for %v of type %T", val, val))
Copy link
Contributor

Choose a reason for hiding this comment

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

Hard to see from GitHub where this is all used and the impact it would have, but this is converting everything to 64-bit precision and returning the associated SQL type. I think it will but I wanna make sure: this will only be used from the index driver right? As in any value passed in won't make it's way into an insertion?

I ask in the case of a column expecting an int16 but receiving an int64 for storage. There may be a benefit to working with specific types here that I'm not seeing since it's hard to gather the bigger picture from here (like that comparing two ints of different sizes thing you ran into before), but I wanna check.

Copy link
Member Author

Choose a reason for hiding this comment

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

Yeah, this is just for comparison purposes for SELECT statements. Using the widest possible numeric type makes the comparison more straightforward.

Copy link
Contributor

Choose a reason for hiding this comment

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

Okay, just wanted to double check!

@@ -368,7 +368,7 @@ func TestDate(t *testing.T) {
{"null date", sql.NewRow(nil), nil, false},
{"invalid type", sql.NewRow([]byte{0, 1, 2}), nil, false},
{"date as string", sql.NewRow(stringDate), "2007-01-02", false},
{"date as time", sql.NewRow(time.Now()), time.Now().Format("2006-01-02"), false},
{"date as time", sql.NewRow(time.Now().UTC()), time.Now().UTC().Format("2006-01-02"), false},
Copy link
Contributor

Choose a reason for hiding this comment

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

😄

Signed-off-by: Zach Musgrave <[email protected]>
@zachmu zachmu merged commit 697bc20 into ld-master Nov 6, 2019
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.

None yet

2 participants