Implement interfaces for RowExpressionTranslation#13491
Implement interfaces for RowExpressionTranslation#13491highker merged 1 commit intoprestodb:masterfrom
Conversation
...ase-jdbc/src/main/java/com/facebook/presto/plugin/jdbc/optimization/JdbcComputePushdown.java
Outdated
Show resolved
Hide resolved
...om/facebook/presto/operator/scalar/annotations/FunctionTranslationFromAnnotationsParser.java
Outdated
Show resolved
Hide resolved
presto-main/src/main/java/com/facebook/presto/sql/planner/ConnectorPlanOptimizerManager.java
Outdated
Show resolved
Hide resolved
presto-spi/src/main/java/com/facebook/presto/spi/connector/ConnectorPlanOptimizerProvider.java
Outdated
Show resolved
Hide resolved
presto-spi/src/main/java/com/facebook/presto/spi/relation/DefaultRowExpressionTranslator.java
Outdated
Show resolved
Hide resolved
|
@sachdevs , let's sync up offline? I made some changes on top @highker and your code, which I hope can make discussing it a little easier? |
9090c43 to
e3a3f60
Compare
|
Added Yi's changes and now addressing James' comments + cleaning up further. |
e3a3f60 to
9d14e3c
Compare
|
Added tests, ensured basic code paths work correctly, and cleaned up further.
Other TODOs:
|
9d14e3c to
992e822
Compare
|
Added another test suite, now splitting up commits + cleaning up. |
afed528 to
848313c
Compare
|
Feel free to take a look for any high-level mistakes/ things I'm still missing before I start to get deeper into implementing the JDBC connector using this interface. |
highker
left a comment
There was a problem hiding this comment.
Discussed offline with some changes based on highker@cb77e79
|
How confident are we about this is the right approach to do translation and these are the right interfaces? Should we consider putting these in a separate package rather than add all them to spi until we get better understanding and confidence that these are the right things to do? |
|
After discussing with James, moving to a separate module and decoupling SPI from this PR. |
848313c to
92ba87d
Compare
|
Refactored to be in separate new top-level library module |
highker
left a comment
There was a problem hiding this comment.
Could you add unit tests to cover the critical codepath?
...expressions/src/main/java/com/facebook/presto/expressions/ConnectorPlanOptimizerManager.java
Outdated
Show resolved
Hide resolved
...ns/src/main/java/com/facebook/presto/expressions/annotations/ScalarImplementationHeader.java
Outdated
Show resolved
Hide resolved
...ns/src/main/java/com/facebook/presto/expressions/annotations/TranslatorAnnotationParser.java
Outdated
Show resolved
Hide resolved
...expressions/src/main/java/com/facebook/presto/expressions/translator/FunctionTranslator.java
Outdated
Show resolved
Hide resolved
...ns/src/main/java/com/facebook/presto/expressions/annotations/TranslatorAnnotationParser.java
Outdated
Show resolved
Hide resolved
92ba87d to
0341598
Compare
|
Cleaned up, adding unit tests now. |
18bb400 to
8bfaf9d
Compare
|
Finished writing tests. Let me know if we would like more coverage on any specific code path. Currently I'm hitting most parts of the translator and annotation parser. |
...ns/src/test/java/com/facebook/presto/expressions/translator/TestRowExpressionTranslator.java
Outdated
Show resolved
Hide resolved
...ns/src/test/java/com/facebook/presto/expressions/translator/TestRowExpressionTranslator.java
Outdated
Show resolved
Hide resolved
...ns/src/test/java/com/facebook/presto/expressions/translator/TestRowExpressionTranslator.java
Outdated
Show resolved
Hide resolved
...ns/src/test/java/com/facebook/presto/expressions/translator/TestRowExpressionTranslator.java
Outdated
Show resolved
Hide resolved
...ns/src/test/java/com/facebook/presto/expressions/translator/TestRowExpressionTranslator.java
Outdated
Show resolved
Hide resolved
...expressions/src/main/java/com/facebook/presto/expressions/translator/FunctionTranslator.java
Outdated
Show resolved
Hide resolved
...ssions/src/main/java/com/facebook/presto/expressions/translator/RowExpressionTranslator.java
Outdated
Show resolved
Hide resolved
...ns/src/main/java/com/facebook/presto/expressions/translator/RowExpressionTreeTranslator.java
Outdated
Show resolved
Hide resolved
...ssions/src/main/java/com/facebook/presto/expressions/translator/RowExpressionTranslator.java
Outdated
Show resolved
Hide resolved
...ssions/src/main/java/com/facebook/presto/expressions/translator/RowExpressionTranslator.java
Outdated
Show resolved
Hide resolved
8bfaf9d to
1fc4526
Compare
|
Looks like I missed the checkstyle run on my last revision, fixed those issues now. The refactor also resulted in me getting rid of the tests that check the "automatic" subtree translation by the library. Let me know if there are any other tests I am missing. Is it worthwhile to unit test annotation parsing/FunctionTranslator in isolation? I.e. make a temp class to parse and ensure correct entries show up in the functionMapping? |
...expressions/src/main/java/com/facebook/presto/expressions/translator/FunctionTranslator.java
Outdated
Show resolved
Hide resolved
...expressions/src/main/java/com/facebook/presto/expressions/translator/FunctionTranslator.java
Outdated
Show resolved
Hide resolved
...expressions/src/main/java/com/facebook/presto/expressions/translator/FunctionTranslator.java
Outdated
Show resolved
Hide resolved
...expressions/src/main/java/com/facebook/presto/expressions/translator/FunctionTranslator.java
Outdated
Show resolved
Hide resolved
...ssions/src/main/java/com/facebook/presto/expressions/translator/RowExpressionTranslator.java
Outdated
Show resolved
Hide resolved
...ssions/src/main/java/com/facebook/presto/expressions/translator/RowExpressionTranslator.java
Outdated
Show resolved
Hide resolved
...ns/src/main/java/com/facebook/presto/expressions/translator/RowExpressionTreeTranslator.java
Outdated
Show resolved
Hide resolved
...ns/src/main/java/com/facebook/presto/expressions/translator/RowExpressionTreeTranslator.java
Outdated
Show resolved
Hide resolved
hellium01
left a comment
There was a problem hiding this comment.
Looks good, have some comments but we can iterate on later commits.
...ssions/src/main/java/com/facebook/presto/expressions/translator/RowExpressionTranslator.java
Outdated
Show resolved
Hide resolved
...ssions/src/main/java/com/facebook/presto/expressions/translator/RowExpressionTranslator.java
Outdated
Show resolved
Hide resolved
...ns/src/main/java/com/facebook/presto/expressions/translator/RowExpressionTreeTranslator.java
Outdated
Show resolved
Hide resolved
...ns/src/test/java/com/facebook/presto/expressions/translator/TestRowExpressionTranslator.java
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
We don't need to put this logic in the RowExpressionTreeTranslator, the user of translateWith need to do before they call translateWith.
There was a problem hiding this comment.
Are there any side-effects of this assumption? I.e. if the user does not convert the expression/predicate to conjunctive form, could their be any resultant issues other than building the minimal converted rowexpression? I just want to make sure that by moving this out we dont make the code less fool-proof.
There was a problem hiding this comment.
I don't think we need logicalRowExpressions. That is too specialized for predicates.
There was a problem hiding this comment.
I don't think this convertToConjunctiveNormalForm is needed for all translations, it is only used to make predicate pushdown easier, so definitely remove it from the common interface.
...expressions/src/main/java/com/facebook/presto/expressions/translator/FunctionTranslator.java
Outdated
Show resolved
Hide resolved
...ns/src/test/java/com/facebook/presto/expressions/translator/TestRowExpressionTranslator.java
Outdated
Show resolved
Hide resolved
...ns/src/test/java/com/facebook/presto/expressions/translator/TestRowExpressionTranslator.java
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
We also might want to cover:
some types of constant that is not translatable.
There was a problem hiding this comment.
what type of constant would that be? untranslatable constants wouldnt make it past expression creation no? since the type provider entry will be missing?
There was a problem hiding this comment.
I would prefer we do some checking on return type and argument type during parseFunctionDefinition rather than throw later when we call translation if we have wrongly defined translate functions.
There was a problem hiding this comment.
Yeah I can see why that is useful. Makes the code more defensible and we fail earlier.
1fc4526 to
ad8048b
Compare
|
Updated PR with comments from @highker and @hellium01. Just looking for verification on what we need to do about the unresolved comments and lets finish this up 😄 |
hellium01
left a comment
There was a problem hiding this comment.
Please definitely remove the deterministicEvaluator/functionResolution/functionMetadataManger from translateWith, otherwise, it looks good.
There was a problem hiding this comment.
I don't think this convertToConjunctiveNormalForm is needed for all translations, it is only used to make predicate pushdown easier, so definitely remove it from the common interface.
ad8048b to
7ef880a
Compare
|
Done, removed those params. 🚢 |
...expressions/src/main/java/com/facebook/presto/expressions/translator/FunctionTranslator.java
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
I don't think we need logicalRowExpressions. That is too specialized for predicates.
...ns/src/main/java/com/facebook/presto/expressions/translator/RowExpressionTreeTranslator.java
Outdated
Show resolved
Hide resolved
...ons/src/main/java/com/facebook/presto/expressions/translator/TranslatorAnnotationParser.java
Outdated
Show resolved
Hide resolved
...ons/src/main/java/com/facebook/presto/expressions/translator/TranslatorAnnotationParser.java
Outdated
Show resolved
Hide resolved
...ons/src/main/java/com/facebook/presto/expressions/translator/TranslatorAnnotationParser.java
Outdated
Show resolved
Hide resolved
...ons/src/main/java/com/facebook/presto/expressions/translator/TranslatorAnnotationParser.java
Outdated
Show resolved
Hide resolved
...pressions/src/main/java/com/facebook/presto/expressions/translator/TranslatedExpression.java
Outdated
Show resolved
Hide resolved
...ns/src/test/java/com/facebook/presto/expressions/translator/TestRowExpressionTranslator.java
Outdated
Show resolved
Hide resolved
7ef880a to
df0b547
Compare
Implement Row Expression translation interfaces in new module presto-expression.
NOTE: See an example implementation using these interfaces in #13526