Skip to content

Conversation

@karteekmurthys
Copy link
Contributor

@karteekmurthys karteekmurthys commented Sep 9, 2022

Test plan -
Run and compare SQL queries with Decimal Arithmetic operations on PrestoDB and PrestoCPP.

Removed "Decimal overflow" related tests as they trigger this issue in Prestissimo. Will re-add them once that issue is fixed.

@karteekmurthys karteekmurthys requested a review from a team as a code owner September 9, 2022 07:00
@karteekmurthys karteekmurthys marked this pull request as draft September 9, 2022 07:00
@karteekmurthys karteekmurthys force-pushed the decimal-arithmetic-e2e branch 3 times, most recently from 874d2de to 1ba5b46 Compare September 16, 2022 17:14
Copy link
Collaborator

@majetideepak majetideepak left a comment

Choose a reason for hiding this comment

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

The coverage looks good. Will be nice to add a few with bounds.

Copy link
Collaborator

Choose a reason for hiding this comment

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

I feel reviewers might be confused as to why the type is DECIMAL(35,20) when none of the inputs carry that. Should we simply say decimal '999999999999999.999' like below and clarify that the inferred column type is DECIMAL(35,20)

Copy link
Collaborator

Choose a reason for hiding this comment

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

Do we need cast? can we simply say decimal '99999999999999999999999999999999999999'?

Copy link
Collaborator

Choose a reason for hiding this comment

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

Should we add a test between decimal limits? between [min, max] and [max, min].

Copy link
Collaborator

Choose a reason for hiding this comment

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

Test limits here and other functions below?

@karteekmurthys karteekmurthys changed the title [WIP] Decimal arithmetic e2e tests [WIP] Decimal arithmetic and logical functions e2e tests Sep 19, 2022
@karteekmurthys karteekmurthys force-pushed the decimal-arithmetic-e2e branch 2 times, most recently from 02d58d0 to 751afab Compare September 21, 2022 07:17
@karteekmurthys karteekmurthys changed the title [WIP] Decimal arithmetic and logical functions e2e tests Decimal arithmetic and logical functions e2e tests Sep 30, 2022
@karteekmurthys karteekmurthys self-assigned this Sep 30, 2022
@karteekmurthys karteekmurthys force-pushed the decimal-arithmetic-e2e branch 5 times, most recently from 45c1687 to 23d899e Compare October 5, 2022 21:46
@karteekmurthys karteekmurthys force-pushed the decimal-arithmetic-e2e branch 6 times, most recently from fdfa0ce to fae254a Compare November 1, 2022 19:54
@karteekmurthys karteekmurthys force-pushed the decimal-arithmetic-e2e branch 4 times, most recently from 9ad5b3a to 825b0f5 Compare November 10, 2022 07:38
@karteekmurthys karteekmurthys force-pushed the decimal-arithmetic-e2e branch 2 times, most recently from 7d95dd0 to 5c28826 Compare November 28, 2022 23:26
@karteekmurthys karteekmurthys marked this pull request as ready for review November 29, 2022 17:35
@karteekmurthys
Copy link
Contributor Author

karteekmurthys commented Nov 29, 2022

@mbasmanova @kagamiori Would you please review this. I had to remove the "Decimal overflow" related tests and I have explained in the description.
test native / build-and-test which executes e2e tests is passing.

Comment on lines +400 to +406
Copy link
Contributor

Choose a reason for hiding this comment

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

Hi Karteek, Queries that process only literal values like this may be constant folded by Prestissimo coordinator without invoking Velox evaluation. Could you try selecting from columns instead of literal values only? (cc @amitkdutta)

Copy link
Contributor Author

@karteekmurthys karteekmurthys Nov 30, 2022

Choose a reason for hiding this comment

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

I understand just executing literals may be constant folded. But, here we are testing arithmetic operation and Presto Query plan has SUBTRACT operator here:
Screen Shot 2022-11-30 at 11 16 55 AM

Copy link
Contributor

@kagamiori kagamiori Dec 1, 2022

Choose a reason for hiding this comment

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

My concern is that the constant folding may use Presto's code instead of Velox code (that you would like to test IIUC). Let me try if I can verify this locally.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The concern is valid. From what I understand if the plan says there is a SUBTRACT operator, then that is what gets executed in the backend. Or else, we would just see a project node. CMIW.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@kagamiori did you get a chance to verify this?

Copy link
Contributor

Choose a reason for hiding this comment

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

Hi @karteekmurthys, I'm having trouble running the e2e query on my laptop (due to my setup of Prestissimo). I'm asking @amitkdutta and @mbasmanova to help confirm.

Copy link
Contributor

Choose a reason for hiding this comment

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

@karteekmurthys Karteek, to speed up the review, would you share the output of EXPLAIN (TYPE DISTRIBUTED) command for one of these queries?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

presto:default> explain (type distributed) SELECT n - m from (values (CAST('999999999999999.999' as decimal(18,3)), CAST('1' as decimal(1,0)))) t(n, m);
                                         Query Plan                                         
--------------------------------------------------------------------------------------------
 Fragment 0 [SINGLE]                                                                       +
     Output layout: [expr_6]                                                               +
     Output partitioning: SINGLE []                                                        +
     Stage Execution Strategy: UNGROUPED_EXECUTION                                         +
     - Output[_col0] => [expr_6:decimal(19,3)]                                             +
             Estimates: {rows: 1 (17B), cpu: 35.00, memory: 0.00, network: 0.00}           +
             _col0 := expr_6 (1:37)                                                        +
         - Project[projectLocality = LOCAL] => [expr_6:decimal(19,3)]                      +
                 Estimates: {rows: 1 (17B), cpu: 35.00, memory: 0.00, network: 0.00}       +
                 expr_6 := (field) - (field_0) (1:48)                                      +
             - LocalExchange[ROUND_ROBIN] () => [field:decimal(18,3), field_0:decimal(1,0)]+
                     Estimates: {rows: 1 (18B), cpu: 18.00, memory: 0.00, network: 0.00}   +
                 - Values => [field:decimal(18,3), field_0:decimal(1,0)]                   +
                         Estimates: {rows: 1 (18B), cpu: 0.00, memory: 0.00, network: 0.00}+
                         (DECIMAL'999999999999999.999', DECIMAL'1')                        +
                                                                                           +
                                                                                            

Copy link
Contributor

Choose a reason for hiding this comment

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

@karteekmurthys Thanks. This plan shows that the computation (a - b) will happen on the worker.

Copy link
Contributor

Choose a reason for hiding this comment

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

Thanks @mbasmanova for confirming!

Copy link
Contributor

@kagamiori kagamiori left a comment

Choose a reason for hiding this comment

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

LGTM. Thank you for adding the test!

Comment on lines +400 to +406
Copy link
Contributor

Choose a reason for hiding this comment

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

Thanks @mbasmanova for confirming!

@kagamiori
Copy link
Contributor

kagamiori commented Dec 6, 2022

There is a failure of "product test (basic)". Please resolve it before landing the code.

@karteekmurthys
Copy link
Contributor Author

@kagamiori The e2e tests are executed in test native / build-and-test (pull_request) which is green and the failures seem unrelated to this change. A different test fails each time, not necessarily related to this change. I will try to rerun again.

@karteekmurthys
Copy link
Contributor Author

@kagamiori @mbasmanova there is one failure, which is unrelated:

Error:  Failures: 
Error:    TestHiveDistributedJoinQueriesWithDynamicFiltering>AbstractTestJoinQueries.testShuffledStatsWithInnerJoin:88 expected [75175] but found [74541]
[INFO] 
Error:  Tests run: 2531, Failures: 1, Errors: 0, Skipped: 90
[INFO] 

Let me know if this is a blocker to merge this PR.

@mbasmanova
Copy link
Contributor

@tdcmeehan @highker Tim, James, is it expected to have intermittent test failures? What should we do in these cases?

@karteekmurthys
Copy link
Contributor Author

@mbasmanova @tdcmeehan just following up on this.

@ethanyzhang
Copy link
Contributor

@mbasmanova Can you help merge this? Thanks a lot!

@aditi-pandit aditi-pandit merged commit 760a0ea into prestodb:master Dec 16, 2022
@mbasmanova
Copy link
Contributor

@yzhang1991 I see that Aditi already merged this PR. Thank you, Aditi.

@wanglinsong wanglinsong mentioned this pull request Jan 12, 2023
30 tasks
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.

6 participants