Skip to content

[WIP] Return proper unenforced constraint for base-jdbc connector#12173

Closed
Praveen2112 wants to merge 1 commit intoprestodb:masterfrom
Praveen2112:base_jdbc_uenforced_constraint
Closed

[WIP] Return proper unenforced constraint for base-jdbc connector#12173
Praveen2112 wants to merge 1 commit intoprestodb:masterfrom
Praveen2112:base_jdbc_uenforced_constraint

Conversation

@Praveen2112
Copy link
Contributor

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.

Copy link
Contributor

@findepi findepi left a comment

Choose a reason for hiding this comment

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

Since all the jdbc connector enforce all of the domains that are passed as a constraint

This isn't a correct assumption.

  1. there is com.facebook.presto.plugin.jdbc.QueryBuilder#isAcceptedType, so some constraints are not being pushed down
  2. this will become more flexible in #12151

@Praveen2112 Praveen2112 force-pushed the base_jdbc_uenforced_constraint branch from fbd06a7 to 70002c6 Compare January 4, 2019 02:15
@Praveen2112 Praveen2112 force-pushed the base_jdbc_uenforced_constraint branch from 70002c6 to daaf714 Compare January 4, 2019 02:49
@Praveen2112
Copy link
Contributor Author

Praveen2112 commented Jan 4, 2019

@findepi . Thanks for the review. I have updated it. Now we create a TupleDomain which has the constraints which is not being pushed down. Can also be moved to the model as proposed in #12151

Copy link
Contributor

@kokosing kokosing left a comment

Choose a reason for hiding this comment

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

Still no tests.

{
}

public static boolean isAcceptedType(Type type)
Copy link
Contributor

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.

Copy link
Contributor Author

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 BaseJdbcClient so that the jdbc connector can override it.

Copy link
Contributor

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?

Copy link
Contributor

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.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@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.

Copy link
Contributor

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 ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@findepi yes

Copy link
Contributor

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#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

Copy link
Contributor Author

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 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;
}

@Praveen2112 Praveen2112 changed the title Return proper unenforced constraint for base-jdbc connector [WIP] Return proper unenforced constraint for base-jdbc connector Jan 4, 2019
@electrum
Copy link
Contributor

electrum commented Jan 8, 2019

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?

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.

5 participants