[WIP] Return proper unenforced constraint for base-jdbc connector#12173
[WIP] Return proper unenforced constraint for base-jdbc connector#12173Praveen2112 wants to merge 1 commit intoprestodb:masterfrom
Conversation
presto-base-jdbc/src/main/java/com/facebook/presto/plugin/jdbc/JdbcMetadata.java
Outdated
Show resolved
Hide resolved
findepi
left a comment
There was a problem hiding this comment.
Since all the jdbc connector enforce all of the domains that are passed as a constraint
This isn't a correct assumption.
- there is
com.facebook.presto.plugin.jdbc.QueryBuilder#isAcceptedType, so some constraints are not being pushed down - this will become more flexible in #12151
fbd06a7 to
70002c6
Compare
70002c6 to
daaf714
Compare
| { | ||
| } | ||
|
|
||
| public static boolean isAcceptedType(Type type) |
There was a problem hiding this comment.
This should be something that every jdbc connector could override.
There was a problem hiding this comment.
So can we push it to BaseJdbcClient so that the jdbc connector can override it.
There was a problem hiding this comment.
@findepi what do you think about this location?
There was a problem hiding this comment.
@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.
@findepi isAcceptedType in present in QueryBuilder as a private static method can we move it to some Util class so that it could be accessed by JdbcMetadata and QueryBuilder.
There was a problem hiding this comment.
good. there -- com.facebook.presto.plugin.jdbc.QueryBuilder#isAcceptedType is now an impl detail of QueryBuilder and has no logic.
com.facebook.presto.plugin.jdbc.ColumnMapping#isPredicatePushDownAllowed is where the information now lives
There was a problem hiding this comment.
@findepi Okay so If I am not wrong we would fetch the ColumnMapping from the above API in JdbcClient#toPrestoType and use it to do the constraint check.
The code will be something like this
Optional<ColumnMapping> mapping = client.toPrestoType(session, column.getJdbcTypeHandle())
if (mapping.isPresent() && mapping.get().isPredicatePushDownAllowed()) {
return null;
}
|
I am doubtful this is a worthwhile change. We are trading what is likely minimal extra CPU usage for complexity and potential correctness bugs. Have you run any benchmarks to determine if this has an impact for real queries? |
Since all the jdbc connector enforce all of the domains that are passed as a constraint, we can return the unenforced constraint as
TupleDomain.all()so that Presto need not apply those filter criteria once again.