-
Notifications
You must be signed in to change notification settings - Fork 1k
PHOENIX-7766: Generate point lookups while using IS NULL on trailing PK columns #2377
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
Open
sanjeet006py
wants to merge
17
commits into
apache:master
Choose a base branch
from
sanjeet006py:is-null-point-lookup
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+1,338
−62
Open
Changes from all commits
Commits
Show all changes
17 commits
Select commit
Hold shift + click to select a range
0ac2b0e
Generate point lookups for IS NULL
9afd4e9
Add test coverage
0a534e4
Add test coverage
d332911
Separate IT class for nullable PK
08299a8
Add test coverage
299a707
Add test coverage
949959c
Refactor tests
3314e6a
Identfied broken range scans with IS NULL
a44269e
Added all ITs
bd75008
Account for sep byte due to overflow
f8bca18
Fix failing ITs
d5888a4
Merge remote-tracking branch 'apache/master' into is-null-point-lookup
8fad64f
Fix all tests
d17d789
spotless apply
2828cec
Merge remote-tracking branch 'apache/master' into is-null-point-lookup
75221d2
Fix doc comments, checkstyle, add more edge case coverage
ab95c30
Fix checkstyle
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
83 changes: 83 additions & 0 deletions
83
phoenix-core/src/it/java/org/apache/phoenix/end2end/WhereOptimizerForArrayAnyITBase.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,83 @@ | ||
| /* | ||
| * Licensed to the Apache Software Foundation (ASF) under one | ||
| * or more contributor license agreements. See the NOTICE file | ||
| * distributed with this work for additional information | ||
| * regarding copyright ownership. The ASF licenses this file | ||
| * to you under the Apache License, Version 2.0 (the | ||
| * "License"); you may not use this file except in compliance | ||
| * with the License. You may obtain a copy of the License at | ||
| * | ||
| * http://www.apache.org/licenses/LICENSE-2.0 | ||
| * | ||
| * Unless required by applicable law or agreed to in writing, software | ||
| * distributed under the License is distributed on an "AS IS" BASIS, | ||
| * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| * See the License for the specific language governing permissions and | ||
| * limitations under the License. | ||
| */ | ||
| package org.apache.phoenix.end2end; | ||
|
|
||
| import static org.junit.Assert.assertEquals; | ||
| import static org.junit.Assert.assertNull; | ||
|
|
||
| import java.sql.PreparedStatement; | ||
| import java.sql.SQLException; | ||
| import java.util.HashMap; | ||
| import org.apache.phoenix.compile.ExplainPlan; | ||
| import org.apache.phoenix.compile.ExplainPlanAttributes; | ||
| import org.apache.phoenix.compile.QueryPlan; | ||
| import org.apache.phoenix.jdbc.PhoenixPreparedStatement; | ||
| import org.apache.phoenix.query.BaseTest; | ||
| import org.apache.phoenix.util.ReadOnlyProps; | ||
| import org.junit.BeforeClass; | ||
|
|
||
| /** | ||
| * Base class for WhereOptimizerForArrayAnyIT tests containing shared helper methods. | ||
| */ | ||
| public abstract class WhereOptimizerForArrayAnyITBase extends BaseTest { | ||
|
|
||
| @BeforeClass | ||
| public static void setup() throws Exception { | ||
| setUpTestDriver(new ReadOnlyProps(new HashMap<String, String>())); | ||
| } | ||
|
|
||
| protected void assertPointLookupsAreGenerated(PreparedStatement stmt, int noOfPointLookups) | ||
| throws SQLException { | ||
| QueryPlan queryPlan = stmt.unwrap(PhoenixPreparedStatement.class).optimizeQuery(); | ||
| assertPointLookupsAreGenerated(queryPlan, noOfPointLookups); | ||
| } | ||
|
|
||
| protected void assertPointLookupsAreGenerated(QueryPlan queryPlan, int noOfPointLookups) | ||
| throws SQLException { | ||
| ExplainPlan explain = queryPlan.getExplainPlan(); | ||
| ExplainPlanAttributes planAttributes = explain.getPlanStepsAsAttributes(); | ||
| String expectedScanType = | ||
| "POINT LOOKUP ON " + noOfPointLookups + " KEY" + (noOfPointLookups > 1 ? "S " : " "); | ||
| assertEquals(expectedScanType, planAttributes.getExplainScanType()); | ||
| } | ||
|
|
||
| protected void assertSkipScanIsGenerated(PreparedStatement stmt, int skipListSize) | ||
| throws SQLException { | ||
| QueryPlan queryPlan = stmt.unwrap(PhoenixPreparedStatement.class).optimizeQuery(); | ||
| ExplainPlan explain = queryPlan.getExplainPlan(); | ||
| ExplainPlanAttributes planAttributes = explain.getPlanStepsAsAttributes(); | ||
| String expectedScanType = | ||
| "SKIP SCAN ON " + skipListSize + " KEY" + (skipListSize > 1 ? "S " : " "); | ||
| assertEquals(expectedScanType, planAttributes.getExplainScanType()); | ||
| } | ||
|
|
||
| protected void assertRangeScanIsGenerated(PreparedStatement stmt) throws SQLException { | ||
| QueryPlan queryPlan = stmt.unwrap(PhoenixPreparedStatement.class).optimizeQuery(); | ||
| ExplainPlan explain = queryPlan.getExplainPlan(); | ||
| ExplainPlanAttributes planAttributes = explain.getPlanStepsAsAttributes(); | ||
| String expectedScanType = "RANGE SCAN "; | ||
| assertEquals(expectedScanType, planAttributes.getExplainScanType()); | ||
| } | ||
|
|
||
| protected void assertDegenerateScanIsGenerated(PreparedStatement stmt) throws SQLException { | ||
| QueryPlan queryPlan = stmt.unwrap(PhoenixPreparedStatement.class).optimizeQuery(); | ||
| ExplainPlan explain = queryPlan.getExplainPlan(); | ||
| ExplainPlanAttributes planAttributes = explain.getPlanStepsAsAttributes(); | ||
| assertNull(planAttributes.getExplainScanType()); | ||
| } | ||
| } |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Any chance we can use
ByteUtil.nextKey()to generate next key?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.
If we use
ByteUtil.nextKey()then we can miss out on some values to return. Ex- we have a querySELECT * FROM TABLE OFFSET (PK1, PK2) = ('1', null). In this case we would want to return values('1', '1')or('1', '10')also. But if we useByteUtil.nextKey()on thekeyoutput from ScanRanges thenOFFSETwill show all the rows starting('2', null)and we would miss seeing rows starting with'1'.There is an existing IT for exact scenario I described above:
RowValueConstructorOffsetIT#rvcOffsetTrailingNullKeyTest().