Skip to content
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

Easier way to add support for more scalar functions during JDBC predicate pushdown #23605

Open
aaneja opened this issue Sep 7, 2024 · 0 comments
Assignees

Comments

@aaneja
Copy link
Contributor

aaneja commented Sep 7, 2024

Issue

During JDBC predicate pushdown, we parse the OperatorTranslators registry with the TranslatorAnnotationParser#parseFunctionDefinitions to build a Map<FunctionMetadata, MethodHandle>

These map is then used in FunctionMetadata#translate to check if the predicate expression will translate into a JdbcExpression

This approach works, but for every new scalar function (or variant with different type parameters), we would need to add a new method in the OperatorTranslators class.
For example, to support INTEGER addition, we would need to add the below method in OperatorTranslators -

@ScalarOperator(ADD)
@SqlType(StandardTypes.INTEGER)
public static JdbcExpression addInteger(@SqlType(StandardTypes.INTEGER) JdbcExpression left, @SqlType(StandardTypes.INTEGER) JdbcExpression right)
{
    return new JdbcExpression(infixOperation("+", left, right), forwardBindVariables(left, right));
}

This would need to be repeated for other type variants like DOUBLE, SMALLINT, TINYINT - which gets quite onerous

Change needed

Instead of using methods with Java annotations to build the Map<FunctionMetadata, MethodHandle> we need an easier way to support the common operators that should translate with most Jdbc backends

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants