This is an automated email from the ASF dual-hosted git repository.

yiguolei pushed a commit to branch branch-2.1
in repository https://gitbox.apache.org/repos/asf/doris.git

commit 8aaae4c87377224423e2b9f6aef837c2963780b3
Author: morrySnow <101034200+morrys...@users.noreply.github.com>
AuthorDate: Wed Jan 31 14:58:44 2024 +0800

    [fix](Nereids) div priority is not right (#30575)
---
 .../antlr4/org/apache/doris/nereids/DorisParser.g4 |   4 +-
 regression-test/data/nereids_arith_p0/integer.out  | 414 +++++++++++----------
 .../suites/nereids_arith_p0/integer.groovy         |  12 +
 3 files changed, 236 insertions(+), 194 deletions(-)

diff --git a/fe/fe-core/src/main/antlr4/org/apache/doris/nereids/DorisParser.g4 
b/fe/fe-core/src/main/antlr4/org/apache/doris/nereids/DorisParser.g4
index 3f2ae5a87d6..3943a30ee2a 100644
--- a/fe/fe-core/src/main/antlr4/org/apache/doris/nereids/DorisParser.g4
+++ b/fe/fe-core/src/main/antlr4/org/apache/doris/nereids/DorisParser.g4
@@ -612,8 +612,8 @@ predicate
 valueExpression
     : primaryExpression                                                        
              #valueExpressionDefault
     | operator=(SUBTRACT | PLUS | TILDE) valueExpression                       
              #arithmeticUnary
-    | left=valueExpression operator=(ASTERISK | SLASH | MOD) 
right=valueExpression           #arithmeticBinary
-    | left=valueExpression operator=(PLUS | SUBTRACT | DIV | HAT | PIPE | 
AMPERSAND)
+    | left=valueExpression operator=(ASTERISK | SLASH | MOD | DIV) 
right=valueExpression     #arithmeticBinary
+    | left=valueExpression operator=(PLUS | SUBTRACT | HAT | PIPE | AMPERSAND)
                            right=valueExpression                               
              #arithmeticBinary
     | left=valueExpression comparisonOperator right=valueExpression            
              #comparison
     | operator=(BITAND | BITOR | BITXOR) LEFT_PAREN left = valueExpression
diff --git a/regression-test/data/nereids_arith_p0/integer.out 
b/regression-test/data/nereids_arith_p0/integer.out
index dc9077fbfdc..d2e1904fd65 100644
--- a/regression-test/data/nereids_arith_p0/integer.out
+++ b/regression-test/data/nereids_arith_p0/integer.out
@@ -20724,56 +20724,56 @@
 
 -- !sql_test_LargeInt_DecimalV2_0 --
 \N     \N      \N
-1      1.07090669395E8 1.07090620605E8
-2      2.13965679484E8 2.13965610516E8
-3      4.27715693756E8 4.27715596244E8
-4      8.55215713943E8 8.55215576057E8
-5      1.710215742494E9        1.710215547506E9
-6      3.420215782874E9        3.420215507126E9
-7      6.84021583998E9 6.84021545002E9
-8      1.3680215920741E10      1.3680215369259E10
-9      2.7360216034955E10      2.7360215255045E10
-10     5.4720216196479E10      5.4720215093521E10
-11     1.09440216424908E11     1.09440214865092E11
-12     2.18880216747957E11     2.18880214542043E11
-13     1.07090669395E8 1.07090620605E8
-14     2.13965679484E8 2.13965610516E8
-15     4.27715693756E8 4.27715596244E8
-16     8.55215713943E8 8.55215576057E8
-17     1.710215742494E9        1.710215547506E9
-18     3.420215782874E9        3.420215507126E9
-19     6.84021583998E9 6.84021545002E9
-20     1.3680215920741E10      1.3680215369259E10
-21     2.7360216034955E10      2.7360215255045E10
-22     5.4720216196479E10      5.4720215093521E10
-23     1.09440216424908E11     1.09440214865092E11
-24     2.18880216747957E11     2.18880214542043E11
+1      107090669       107090621
+2      213965679       213965611
+3      427715694       427715596
+4      855215714       855215576
+5      1710215742      1710215548
+6      3420215783      3420215507
+7      6840215840      6840215450
+8      13680215921     13680215369
+9      27360216035     27360215255
+10     54720216196     54720215094
+11     109440216425    109440214865
+12     218880216748    218880214542
+13     107090669       107090621
+14     213965679       213965611
+15     427715694       427715596
+16     855215714       855215576
+17     1710215742      1710215548
+18     3420215783      3420215507
+19     6840215840      6840215450
+20     13680215921     13680215369
+21     27360216035     27360215255
+22     54720216196     54720215094
+23     109440216425    109440214865
+24     218880216748    218880214542
 
 -- !sql_test_LargeInt_DecimalV2_notn_0 --
-1      1.07090669395E8 1.07090620605E8
-2      2.13965679484E8 2.13965610516E8
-3      4.27715693756E8 4.27715596244E8
-4      8.55215713943E8 8.55215576057E8
-5      1.710215742494E9        1.710215547506E9
-6      3.420215782874E9        3.420215507126E9
-7      6.84021583998E9 6.84021545002E9
-8      1.3680215920741E10      1.3680215369259E10
-9      2.7360216034955E10      2.7360215255045E10
-10     5.4720216196479E10      5.4720215093521E10
-11     1.09440216424908E11     1.09440214865092E11
-12     2.18880216747957E11     2.18880214542043E11
-13     1.07090669395E8 1.07090620605E8
-14     2.13965679484E8 2.13965610516E8
-15     4.27715693756E8 4.27715596244E8
-16     8.55215713943E8 8.55215576057E8
-17     1.710215742494E9        1.710215547506E9
-18     3.420215782874E9        3.420215507126E9
-19     6.84021583998E9 6.84021545002E9
-20     1.3680215920741E10      1.3680215369259E10
-21     2.7360216034955E10      2.7360215255045E10
-22     5.4720216196479E10      5.4720215093521E10
-23     1.09440216424908E11     1.09440214865092E11
-24     2.18880216747957E11     2.18880214542043E11
+1      107090669       107090621
+2      213965679       213965611
+3      427715694       427715596
+4      855215714       855215576
+5      1710215742      1710215548
+6      3420215783      3420215507
+7      6840215840      6840215450
+8      13680215921     13680215369
+9      27360216035     27360215255
+10     54720216196     54720215094
+11     109440216425    109440214865
+12     218880216748    218880214542
+13     107090669       107090621
+14     213965679       213965611
+15     427715694       427715596
+16     855215714       855215576
+17     1710215742      1710215548
+18     3420215783      3420215507
+19     6840215840      6840215450
+20     13680215921     13680215369
+21     27360216035     27360215255
+22     54720216196     54720215094
+23     109440216425    109440214865
+24     218880216748    218880214542
 
 -- !sql_test_LargeInt_DecimalV2_1 --
 \N     \N      \N      \N
@@ -20936,56 +20936,56 @@
 
 -- !sql_test_LargeInt_Decimal32V3_0 --
 \N     \N      \N
-1      1.07090657012E8 1.07090632988E8
-2      2.13965668123E8 2.13965621877E8
-3      4.27715679234E8 4.27715610766E8
-4      8.55215690345E8 8.55215599655E8
-5      1.710215701456E9        1.710215588544E9
-6      3.420215712567E9        3.420215577433E9
-7      6.840215723678E9        6.840215566322E9
-8      1.3680215734789E10      1.3680215555211E10
-9      2.73602157459E10        2.73602155441E10
-10     5.4720215757011E10      5.4720215532989E10
-11     1.09440215768122E11     1.09440215521878E11
-12     2.18880215779233E11     2.18880215510767E11
-13     1.07090790344E8 1.07090499656E8
-14     2.13965801455E8 2.13965488545E8
-15     4.27715812566E8 4.27715477434E8
-16     8.55215823677E8 8.55215466323E8
-17     1.710215834788E9        1.710215455212E9
-18     3.420215845899E9        3.420215444101E9
-19     6.84021585701E9 6.84021543299E9
-20     1.3680215868121E10      1.3680215421879E10
-21     2.7360215879232E10      2.7360215410768E10
-22     5.4720215890343E10      5.4720215399657E10
-23     1.09440215901454E11     1.09440215388546E11
-24     2.18880215912565E11     2.18880215377435E11
+1      107090657       107090633
+2      213965668       213965622
+3      427715679       427715611
+4      855215690       855215600
+5      1710215701      1710215589
+6      3420215713      3420215577
+7      6840215724      6840215566
+8      13680215735     13680215555
+9      27360215746     27360215544
+10     54720215757     54720215533
+11     109440215768    109440215522
+12     218880215779    218880215511
+13     107090790       107090500
+14     213965801       213965489
+15     427715813       427715477
+16     855215824       855215466
+17     1710215835      1710215455
+18     3420215846      3420215444
+19     6840215857      6840215433
+20     13680215868     13680215422
+21     27360215879     27360215411
+22     54720215890     54720215400
+23     109440215901    109440215389
+24     218880215913    218880215377
 
 -- !sql_test_LargeInt_Decimal32V3_notn_0 --
-1      1.07090657012E8 1.07090632988E8
-2      2.13965668123E8 2.13965621877E8
-3      4.27715679234E8 4.27715610766E8
-4      8.55215690345E8 8.55215599655E8
-5      1.710215701456E9        1.710215588544E9
-6      3.420215712567E9        3.420215577433E9
-7      6.840215723678E9        6.840215566322E9
-8      1.3680215734789E10      1.3680215555211E10
-9      2.73602157459E10        2.73602155441E10
-10     5.4720215757011E10      5.4720215532989E10
-11     1.09440215768122E11     1.09440215521878E11
-12     2.18880215779233E11     2.18880215510767E11
-13     1.07090790344E8 1.07090499656E8
-14     2.13965801455E8 2.13965488545E8
-15     4.27715812566E8 4.27715477434E8
-16     8.55215823677E8 8.55215466323E8
-17     1.710215834788E9        1.710215455212E9
-18     3.420215845899E9        3.420215444101E9
-19     6.84021585701E9 6.84021543299E9
-20     1.3680215868121E10      1.3680215421879E10
-21     2.7360215879232E10      2.7360215410768E10
-22     5.4720215890343E10      5.4720215399657E10
-23     1.09440215901454E11     1.09440215388546E11
-24     2.18880215912565E11     2.18880215377435E11
+1      107090657       107090633
+2      213965668       213965622
+3      427715679       427715611
+4      855215690       855215600
+5      1710215701      1710215589
+6      3420215713      3420215577
+7      6840215724      6840215566
+8      13680215735     13680215555
+9      27360215746     27360215544
+10     54720215757     54720215533
+11     109440215768    109440215522
+12     218880215779    218880215511
+13     107090790       107090500
+14     213965801       213965489
+15     427715813       427715477
+16     855215824       855215466
+17     1710215835      1710215455
+18     3420215846      3420215444
+19     6840215857      6840215433
+20     13680215868     13680215422
+21     27360215879     27360215411
+22     54720215890     54720215400
+23     109440215901    109440215389
+24     218880215913    218880215377
 
 -- !sql_test_LargeInt_Decimal32V3_2 --
 \N     \N
@@ -21095,56 +21095,56 @@
 
 -- !sql_test_LargeInt_Decimal64V3_0 --
 \N     \N      \N
-1      1.0709187901234E8       1.0708941098766E8
-2      2.1396799012345E8       2.1396329987655E8
-3      4.2771910123456E8       4.2771218876544E8
-4      8.5522021234567E8       8.5521107765433E8
-5      1.71022132345678E9      1.71020996654322E9
-6      3.42022243456789E9      3.42020885543211E9
-7      6.840223545679E9        6.840207744321E9
-8      1.368022465679011E10    1.368020663320989E10
-9      2.736022576790122E10    2.736020552209878E10
-10     5.472022687901233E10    5.472020441098767E10
-11     1.0944022799012344E11   1.0944020329987656E11
-12     2.1888022910123456E11   2.1888020218876544E11
-13     1.0710521234566E8       1.0707607765434E8
-14     2.1398132345677E8       2.1394996654323E8
-15     4.2773243456788E8       4.2769885543212E8
-16     8.5523354567899E8       8.5519774432101E8
-17     1.7102346567901E9       1.7101966332099E9
-18     3.42023576790121E9      3.42019552209879E9
-19     6.84023687901232E9      6.84019441098768E9
-20     1.368023799012343E10    1.368019329987657E10
-21     2.736023910123454E10    2.736019218876546E10
-22     5.472024021234565E10    5.472019107765435E10
-23     1.0944024132345676E11   1.0944018996654324E11
-24     2.1888024243456787E11   2.1888018885543213E11
+1      107091879       107089411
+2      213967990       213963300
+3      427719101       427712189
+4      855220212       855211078
+5      1710221323      1710209967
+6      3420222435      3420208855
+7      6840223546      6840207744
+8      13680224657     13680206633
+9      27360225768     27360205522
+10     54720226879     54720204411
+11     109440227990    109440203300
+12     218880229101    218880202189
+13     107105212       107076078
+14     213981323       213949967
+15     427732435       427698855
+16     855233546       855197744
+17     1710234657      1710196633
+18     3420235768      3420195522
+19     6840236879      6840194411
+20     13680237990     13680193300
+21     27360239101     27360192189
+22     54720240212     54720191078
+23     109440241323    109440189967
+24     218880242435    218880188855
 
 -- !sql_test_LargeInt_Decimal64V3_notn_0 --
-1      1.0709187901234E8       1.0708941098766E8
-2      2.1396799012345E8       2.1396329987655E8
-3      4.2771910123456E8       4.2771218876544E8
-4      8.5522021234567E8       8.5521107765433E8
-5      1.71022132345678E9      1.71020996654322E9
-6      3.42022243456789E9      3.42020885543211E9
-7      6.840223545679E9        6.840207744321E9
-8      1.368022465679011E10    1.368020663320989E10
-9      2.736022576790122E10    2.736020552209878E10
-10     5.472022687901233E10    5.472020441098767E10
-11     1.0944022799012344E11   1.0944020329987656E11
-12     2.1888022910123456E11   2.1888020218876544E11
-13     1.0710521234566E8       1.0707607765434E8
-14     2.1398132345677E8       2.1394996654323E8
-15     4.2773243456788E8       4.2769885543212E8
-16     8.5523354567899E8       8.5519774432101E8
-17     1.7102346567901E9       1.7101966332099E9
-18     3.42023576790121E9      3.42019552209879E9
-19     6.84023687901232E9      6.84019441098768E9
-20     1.368023799012343E10    1.368019329987657E10
-21     2.736023910123454E10    2.736019218876546E10
-22     5.472024021234565E10    5.472019107765435E10
-23     1.0944024132345676E11   1.0944018996654324E11
-24     2.1888024243456787E11   2.1888018885543213E11
+1      107091879       107089411
+2      213967990       213963300
+3      427719101       427712189
+4      855220212       855211078
+5      1710221323      1710209967
+6      3420222435      3420208855
+7      6840223546      6840207744
+8      13680224657     13680206633
+9      27360225768     27360205522
+10     54720226879     54720204411
+11     109440227990    109440203300
+12     218880229101    218880202189
+13     107105212       107076078
+14     213981323       213949967
+15     427732435       427698855
+16     855233546       855197744
+17     1710234657      1710196633
+18     3420235768      3420195522
+19     6840236879      6840194411
+20     13680237990     13680193300
+21     27360239101     27360192189
+22     54720240212     54720191078
+23     109440241323    109440189967
+24     218880242435    218880188855
 
 -- !sql_test_LargeInt_Decimal64V3_2 --
 \N     \N
@@ -21254,56 +21254,56 @@
 
 -- !sql_test_LargeInt_Decimal128V3_0 --
 \N     \N      \N
-1      1.19436323012345E8      9.4744966987655E7
-2      2.37422434123456E8      1.90508855876544E8
-3      4.62283545234567E8      3.93147744765433E8
-4      9.00894656345678E8      8.09536633654322E8
-5      1.767005767456789E9     1.653425522543211E9
-6      3.4881168785679E9       3.3523144114321E9
-7      6.919227989679011E9     6.761203300320989E9
-8      1.3770339100790121E10   1.3590092189209879E10
-9      2.7461450211901234E10   2.7258981078098766E10
-10     5.4832561323012344E10   5.4607869966987656E10
-11     1.0956367243412346E11   1.0931675885587654E11
-12     2.1901478354523456E11   2.1874564774476544E11
-13     2.52769656345677E8      -3.858836634567699E7
-14     3.70755767456788E8      5.7175522543212E7
-15     5.95616878567899E8      2.59814411432101E8
-16     1.03422798967901E9      6.7620330032099E8
-17     1.900339100790121E9     1.520092189209879E9
-18     3.621450211901232E9     3.218981078098768E9
-19     7.052561323012343E9     6.627869966987657E9
-20     1.3903672434123453E10   1.3456758855876547E10
-21     2.7594783545234566E10   2.7125647744765434E10
-22     5.496589465634567E10    5.447453663365433E10
-23     1.0969700576745679E11   1.0918342552254321E11
-24     2.191481168785679E11    2.186123144114321E11
+1      119436323       94744967
+2      237422434       190508856
+3      462283545       393147745
+4      900894656       809536634
+5      1767005767      1653425523
+6      3488116879      3352314411
+7      6919227990      6761203300
+8      13770339101     13590092189
+9      27461450212     27258981078
+10     54832561323     54607869967
+11     109563672434    109316758856
+12     219014783545    218745647745
+13     252769656       -38588366
+14     370755767       57175523
+15     595616879       259814411
+16     1034227990      676203300
+17     1900339101      1520092189
+18     3621450212      3218981078
+19     7052561323      6627869967
+20     13903672434     13456758856
+21     27594783545     27125647745
+22     54965894656     54474536634
+23     109697005767    109183425523
+24     219148116879    218612314411
 
 -- !sql_test_LargeInt_Decimal128V3_notn_0 --
-1      1.19436323012345E8      9.4744966987655E7
-2      2.37422434123456E8      1.90508855876544E8
-3      4.62283545234567E8      3.93147744765433E8
-4      9.00894656345678E8      8.09536633654322E8
-5      1.767005767456789E9     1.653425522543211E9
-6      3.4881168785679E9       3.3523144114321E9
-7      6.919227989679011E9     6.761203300320989E9
-8      1.3770339100790121E10   1.3590092189209879E10
-9      2.7461450211901234E10   2.7258981078098766E10
-10     5.4832561323012344E10   5.4607869966987656E10
-11     1.0956367243412346E11   1.0931675885587654E11
-12     2.1901478354523456E11   2.1874564774476544E11
-13     2.52769656345677E8      -3.858836634567699E7
-14     3.70755767456788E8      5.7175522543212E7
-15     5.95616878567899E8      2.59814411432101E8
-16     1.03422798967901E9      6.7620330032099E8
-17     1.900339100790121E9     1.520092189209879E9
-18     3.621450211901232E9     3.218981078098768E9
-19     7.052561323012343E9     6.627869966987657E9
-20     1.3903672434123453E10   1.3456758855876547E10
-21     2.7594783545234566E10   2.7125647744765434E10
-22     5.496589465634567E10    5.447453663365433E10
-23     1.0969700576745679E11   1.0918342552254321E11
-24     2.191481168785679E11    2.186123144114321E11
+1      119436323       94744967
+2      237422434       190508856
+3      462283545       393147745
+4      900894656       809536634
+5      1767005767      1653425523
+6      3488116879      3352314411
+7      6919227990      6761203300
+8      13770339101     13590092189
+9      27461450212     27258981078
+10     54832561323     54607869967
+11     109563672434    109316758856
+12     219014783545    218745647745
+13     252769656       -38588366
+14     370755767       57175523
+15     595616879       259814411
+16     1034227990      676203300
+17     1900339101      1520092189
+18     3621450212      3218981078
+19     7052561323      6627869967
+20     13903672434     13456758856
+21     27594783545     27125647745
+22     54965894656     54474536634
+23     109697005767    109183425523
+24     219148116879    218612314411
 
 -- !sql_test_LargeInt_Decimal128V3_2 --
 \N     \N
@@ -23213,3 +23213,33 @@
 23     1       109440215645    109440215644
 24     1       218880215645    218880215644
 
+-- !test_div_priority_1 --
+7
+
+-- !test_div_priority_2 --
+3
+
+-- !test_div_priority_3 --
+10
+
+-- !test_div_priority_4 --
+2.5
+
+-- !test_div_priority_5 --
+1
+
+-- !test_div_priority_6 --
+7
+
+-- !test_div_priority_7 --
+-3
+
+-- !test_div_priority_8 --
+10
+
+-- !test_div_priority_9 --
+0
+
+-- !test_div_priority_10 --
+1
+
diff --git a/regression-test/suites/nereids_arith_p0/integer.groovy 
b/regression-test/suites/nereids_arith_p0/integer.groovy
index 0157613c483..e934705cfca 100644
--- a/regression-test/suites/nereids_arith_p0/integer.groovy
+++ b/regression-test/suites/nereids_arith_p0/integer.groovy
@@ -2299,4 +2299,16 @@ suite('nereids_arith_p0_integer') {
                select id, BITAND(klint, kbool), BITOR(klint, kbool), 
BITXOR(klint, kbool) from expr_test order by id"""
        qt_sql_test_LargeInt_Boolean_notn_4 """
                select id, BITAND(klint, kbool), BITOR(klint, kbool), 
BITXOR(klint, kbool) from expr_test_not_nullable order by id"""
+
+       qt_test_div_priority_1 """select 10 div 2 + 2"""
+       qt_test_div_priority_2 """select 10 div 2 - 2"""
+       qt_test_div_priority_3 """select 10 div 2 * 2"""
+       qt_test_div_priority_4 """select 10 div 2 / 2"""
+       qt_test_div_priority_5 """select 10 div 2 % 2"""
+       qt_test_div_priority_6 """select 2 + 10 div 2"""
+       qt_test_div_priority_7 """select 2 - 10 div 2"""
+       qt_test_div_priority_8 """select 2 * 10 div 2"""
+       qt_test_div_priority_9 """select 2 / 10 div 2"""
+       qt_test_div_priority_10 """select 2 % 10 div 2"""
+
 }
\ No newline at end of file


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscr...@doris.apache.org
For additional commands, e-mail: commits-h...@doris.apache.org

Reply via email to