-
Notifications
You must be signed in to change notification settings - Fork 5.5k
[WIP] Return proper unenforced constraint for base-jdbc connector #12173
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
Closed
Praveen2112
wants to merge
1
commit into
prestodb:master
from
Praveen2112:base_jdbc_uenforced_constraint
Closed
Changes from all commits
Commits
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
56 changes: 56 additions & 0 deletions
56
presto-base-jdbc/src/main/java/com/facebook/presto/plugin/jdbc/JdbcUtil.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,56 @@ | ||
| /* | ||
| * Licensed 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 com.facebook.presto.plugin.jdbc; | ||
|
|
||
| import com.facebook.presto.spi.type.BigintType; | ||
| import com.facebook.presto.spi.type.BooleanType; | ||
| import com.facebook.presto.spi.type.DateType; | ||
| import com.facebook.presto.spi.type.DoubleType; | ||
| import com.facebook.presto.spi.type.IntegerType; | ||
| import com.facebook.presto.spi.type.RealType; | ||
| import com.facebook.presto.spi.type.SmallintType; | ||
| import com.facebook.presto.spi.type.TimeType; | ||
| import com.facebook.presto.spi.type.TimeWithTimeZoneType; | ||
| import com.facebook.presto.spi.type.TimestampType; | ||
| import com.facebook.presto.spi.type.TimestampWithTimeZoneType; | ||
| import com.facebook.presto.spi.type.TinyintType; | ||
| import com.facebook.presto.spi.type.Type; | ||
| import com.facebook.presto.spi.type.VarcharType; | ||
|
|
||
| import static java.util.Objects.requireNonNull; | ||
|
|
||
| public class JdbcUtil | ||
| { | ||
| private JdbcUtil() | ||
| { | ||
| } | ||
|
|
||
| public static boolean isAcceptedType(Type type) | ||
| { | ||
| Type validType = requireNonNull(type, "type is null"); | ||
| return validType.equals(BigintType.BIGINT) || | ||
| validType.equals(TinyintType.TINYINT) || | ||
| validType.equals(SmallintType.SMALLINT) || | ||
| validType.equals(IntegerType.INTEGER) || | ||
| validType.equals(DoubleType.DOUBLE) || | ||
| validType.equals(RealType.REAL) || | ||
| validType.equals(BooleanType.BOOLEAN) || | ||
| validType.equals(DateType.DATE) || | ||
| validType.equals(TimeType.TIME) || | ||
| validType.equals(TimeWithTimeZoneType.TIME_WITH_TIME_ZONE) || | ||
| validType.equals(TimestampType.TIMESTAMP) || | ||
| validType.equals(TimestampWithTimeZoneType.TIMESTAMP_WITH_TIME_ZONE) || | ||
| validType instanceof VarcharType; | ||
| } | ||
| } | ||
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.
This should be something that every jdbc connector could override.
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.
So can we push it to
BaseJdbcClientso that the jdbc connector can override it.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.
@findepi what do you think about this location?
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.
@Praveen2112 the PR i linked before (#12151) refactors the code base around pushdown and already delegates the responsibility to the
BaseJdbcClient. I recommend that you base your work on that PR.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.
@findepi
isAcceptedTypein present inQueryBuilderas a private static method can we move it to some Util class so that it could be accessed byJdbcMetadataandQueryBuilder.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.
@Praveen2112 do you mean the code in #12151 ?
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.
@findepi yes
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.
good. there --
com.facebook.presto.plugin.jdbc.QueryBuilder#isAcceptedTypeis now an impl detail of QueryBuilder and has no logic.com.facebook.presto.plugin.jdbc.ColumnMapping#isPredicatePushDownAllowedis where the information now livesThere 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.
@findepi Okay so If I am not wrong we would fetch the
ColumnMappingfrom the above API inJdbcClient#toPrestoTypeand use it to do the constraint check.The code will be something like this