-
Notifications
You must be signed in to change notification settings - Fork 3.7k
[fix](named_struct) fix named_struct signature which deduce wrong for nested decimal precision #48964
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
Conversation
|
run buildall |
|
Thank you for your contribution to Apache Doris. Please clearly describe your PR:
|
TPC-H: Total hot run time: 32514 ms |
TPC-DS: Total hot run time: 184441 ms |
ClickBench: Total hot run time: 30.53 s |
...main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/CreateNamedStruct.java
Outdated
Show resolved
Hide resolved
|
run buildall |
TPC-H: Total hot run time: 33129 ms |
TPC-DS: Total hot run time: 191266 ms |
ClickBench: Total hot run time: 31.04 s |
|
PR approved by at least one committer and no changes requested. |
|
PR approved by anyone and no changes requested. |
eldenmoon
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
… nested decimal precision (#48964) before this pr , we deduce the precision of the function named_struct containing the decimal type is same with the precision of the decimal type in select . In this case we can not make right named_struct for multiple decimal value like : ``` mysql> create table t01 (a decimal(6,3), d struct<col:bigint, col1:decimal(7,2)>) properties ("replication_num"="1"); Query OK, 0 rows affected (0.14 sec) mysql> insert into t01 values (123.321, named_struct('col', 1, 'col1', 345.24)); Query OK, 1 row affected (0.26 sec) {'label':'label_a2dc895ee7834701_841639ad6d93923f', 'status':'VISIBLE', 'txnId':'9010'} mysql> select named_struct("col_11", a, "col_12", d) from t01; +--------------------------------------------------------+ | named_struct("col_11", a, "col_12", d) | +--------------------------------------------------------+ | {"col_11":123.321, "col_12":{"col":1, "col1":345.240}} | +--------------------------------------------------------+ 1 row in set (0.17 sec) mysql> insert into t01 values (123.321, named_struct('col', 1, 'col1', 12345.24)); Query OK, 1 row affected (0.17 sec) {'label':'label_77ed6047f6a6494d_810c26becfd0535c', 'status':'VISIBLE', 'txnId':'9011'} mysql> select named_struct("col_11", a, "col_12", d) from t01; ERROR 1105 (HY000): errCode = 2, detailMessage = (10.16.10.6)[E-255]Arithmetic overflow when converting value 12345.24 from type Decimal(7, 2) to type Decimal(6, 3) mysql> desc verbose select named_struct("col_11", a, "col_12", d) from t01; +----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | Explain String(Nereids Planner) | +----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | PLAN FRAGMENT 0 | | OUTPUT EXPRS: | | named_struct("col_11", a, "col_12", d)[#2] | | PARTITION: RANDOM | | | | HAS_COLO_PLAN_NODE: false | | | | VRESULT SINK | | MYSQL_PROTOCAL | | | | 0:VOlapScanNode(50) | | TABLE: tt.t01(t01), PREAGGREGATION: ON | | partitions=1/1 (t01) | | tablets=10/10, tabletList=1741751856342,1741751856344,1741751856346 ... | | cardinality=2, avgRowSize=2955.0, numNodes=1 | | pushAggOp=NONE | | final projections: named_struct('col_11', a[#0], 'col_12', CAST(d[#1] AS struct<col:bigint,col1:decimalv3(6,3)>)) | | final project output tuple id: 1 | | tuple ids: 0 | | | | Tuples: | | TupleDescriptor{id=0, tbl=t01} | | SlotDescriptor{id=0, col=a, colUniqueId=0, type=decimalv3(6,3), nullable=true, isAutoIncrement=false, subColPath=null} | | SlotDescriptor{id=1, col=d, colUniqueId=1, type=struct<col:bigint,col1:decimalv3(7,2)>, nullable=true, isAutoIncrement=false, subColPath=null} | | | | TupleDescriptor{id=1, tbl=t01} | | SlotDescriptor{id=2, col=null, colUniqueId=null, type=struct<col_11:decimalv3(6,3),col_12:struct<col:bigint,col1:decimalv3(6,3)>>, nullable=false, isAutoIncrement=false, subColPath=null} | | | | | | ```
… nested decimal precision (#48964) before this pr , we deduce the precision of the function named_struct containing the decimal type is same with the precision of the decimal type in select . In this case we can not make right named_struct for multiple decimal value like : ``` mysql> create table t01 (a decimal(6,3), d struct<col:bigint, col1:decimal(7,2)>) properties ("replication_num"="1"); Query OK, 0 rows affected (0.14 sec) mysql> insert into t01 values (123.321, named_struct('col', 1, 'col1', 345.24)); Query OK, 1 row affected (0.26 sec) {'label':'label_a2dc895ee7834701_841639ad6d93923f', 'status':'VISIBLE', 'txnId':'9010'} mysql> select named_struct("col_11", a, "col_12", d) from t01; +--------------------------------------------------------+ | named_struct("col_11", a, "col_12", d) | +--------------------------------------------------------+ | {"col_11":123.321, "col_12":{"col":1, "col1":345.240}} | +--------------------------------------------------------+ 1 row in set (0.17 sec) mysql> insert into t01 values (123.321, named_struct('col', 1, 'col1', 12345.24)); Query OK, 1 row affected (0.17 sec) {'label':'label_77ed6047f6a6494d_810c26becfd0535c', 'status':'VISIBLE', 'txnId':'9011'} mysql> select named_struct("col_11", a, "col_12", d) from t01; ERROR 1105 (HY000): errCode = 2, detailMessage = (10.16.10.6)[E-255]Arithmetic overflow when converting value 12345.24 from type Decimal(7, 2) to type Decimal(6, 3) mysql> desc verbose select named_struct("col_11", a, "col_12", d) from t01; +----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | Explain String(Nereids Planner) | +----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | PLAN FRAGMENT 0 | | OUTPUT EXPRS: | | named_struct("col_11", a, "col_12", d)[#2] | | PARTITION: RANDOM | | | | HAS_COLO_PLAN_NODE: false | | | | VRESULT SINK | | MYSQL_PROTOCAL | | | | 0:VOlapScanNode(50) | | TABLE: tt.t01(t01), PREAGGREGATION: ON | | partitions=1/1 (t01) | | tablets=10/10, tabletList=1741751856342,1741751856344,1741751856346 ... | | cardinality=2, avgRowSize=2955.0, numNodes=1 | | pushAggOp=NONE | | final projections: named_struct('col_11', a[#0], 'col_12', CAST(d[#1] AS struct<col:bigint,col1:decimalv3(6,3)>)) | | final project output tuple id: 1 | | tuple ids: 0 | | | | Tuples: | | TupleDescriptor{id=0, tbl=t01} | | SlotDescriptor{id=0, col=a, colUniqueId=0, type=decimalv3(6,3), nullable=true, isAutoIncrement=false, subColPath=null} | | SlotDescriptor{id=1, col=d, colUniqueId=1, type=struct<col:bigint,col1:decimalv3(7,2)>, nullable=true, isAutoIncrement=false, subColPath=null} | | | | TupleDescriptor{id=1, tbl=t01} | | SlotDescriptor{id=2, col=null, colUniqueId=null, type=struct<col_11:decimalv3(6,3),col_12:struct<col:bigint,col1:decimalv3(6,3)>>, nullable=false, isAutoIncrement=false, subColPath=null} | | | | | | ```
… nested decimal precision (apache#48964) before this pr , we deduce the precision of the function named_struct containing the decimal type is same with the precision of the decimal type in select . In this case we can not make right named_struct for multiple decimal value like : ``` mysql> create table t01 (a decimal(6,3), d struct<col:bigint, col1:decimal(7,2)>) properties ("replication_num"="1"); Query OK, 0 rows affected (0.14 sec) mysql> insert into t01 values (123.321, named_struct('col', 1, 'col1', 345.24)); Query OK, 1 row affected (0.26 sec) {'label':'label_a2dc895ee7834701_841639ad6d93923f', 'status':'VISIBLE', 'txnId':'9010'} mysql> select named_struct("col_11", a, "col_12", d) from t01; +--------------------------------------------------------+ | named_struct("col_11", a, "col_12", d) | +--------------------------------------------------------+ | {"col_11":123.321, "col_12":{"col":1, "col1":345.240}} | +--------------------------------------------------------+ 1 row in set (0.17 sec) mysql> insert into t01 values (123.321, named_struct('col', 1, 'col1', 12345.24)); Query OK, 1 row affected (0.17 sec) {'label':'label_77ed6047f6a6494d_810c26becfd0535c', 'status':'VISIBLE', 'txnId':'9011'} mysql> select named_struct("col_11", a, "col_12", d) from t01; ERROR 1105 (HY000): errCode = 2, detailMessage = (10.16.10.6)[E-255]Arithmetic overflow when converting value 12345.24 from type Decimal(7, 2) to type Decimal(6, 3) mysql> desc verbose select named_struct("col_11", a, "col_12", d) from t01; +----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | Explain String(Nereids Planner) | +----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | PLAN FRAGMENT 0 | | OUTPUT EXPRS: | | named_struct("col_11", a, "col_12", d)[apache#2] | | PARTITION: RANDOM | | | | HAS_COLO_PLAN_NODE: false | | | | VRESULT SINK | | MYSQL_PROTOCAL | | | | 0:VOlapScanNode(50) | | TABLE: tt.t01(t01), PREAGGREGATION: ON | | partitions=1/1 (t01) | | tablets=10/10, tabletList=1741751856342,1741751856344,1741751856346 ... | | cardinality=2, avgRowSize=2955.0, numNodes=1 | | pushAggOp=NONE | | final projections: named_struct('col_11', a[#0], 'col_12', CAST(d[#1] AS struct<col:bigint,col1:decimalv3(6,3)>)) | | final project output tuple id: 1 | | tuple ids: 0 | | | | Tuples: | | TupleDescriptor{id=0, tbl=t01} | | SlotDescriptor{id=0, col=a, colUniqueId=0, type=decimalv3(6,3), nullable=true, isAutoIncrement=false, subColPath=null} | | SlotDescriptor{id=1, col=d, colUniqueId=1, type=struct<col:bigint,col1:decimalv3(7,2)>, nullable=true, isAutoIncrement=false, subColPath=null} | | | | TupleDescriptor{id=1, tbl=t01} | | SlotDescriptor{id=2, col=null, colUniqueId=null, type=struct<col_11:decimalv3(6,3),col_12:struct<col:bigint,col1:decimalv3(6,3)>>, nullable=false, isAutoIncrement=false, subColPath=null} | | | | | | ```
… nested decimal precision (apache#48964) before this pr , we deduce the precision of the function named_struct containing the decimal type is same with the precision of the decimal type in select . In this case we can not make right named_struct for multiple decimal value like : ``` mysql> create table t01 (a decimal(6,3), d struct<col:bigint, col1:decimal(7,2)>) properties ("replication_num"="1"); Query OK, 0 rows affected (0.14 sec) mysql> insert into t01 values (123.321, named_struct('col', 1, 'col1', 345.24)); Query OK, 1 row affected (0.26 sec) {'label':'label_a2dc895ee7834701_841639ad6d93923f', 'status':'VISIBLE', 'txnId':'9010'} mysql> select named_struct("col_11", a, "col_12", d) from t01; +--------------------------------------------------------+ | named_struct("col_11", a, "col_12", d) | +--------------------------------------------------------+ | {"col_11":123.321, "col_12":{"col":1, "col1":345.240}} | +--------------------------------------------------------+ 1 row in set (0.17 sec) mysql> insert into t01 values (123.321, named_struct('col', 1, 'col1', 12345.24)); Query OK, 1 row affected (0.17 sec) {'label':'label_77ed6047f6a6494d_810c26becfd0535c', 'status':'VISIBLE', 'txnId':'9011'} mysql> select named_struct("col_11", a, "col_12", d) from t01; ERROR 1105 (HY000): errCode = 2, detailMessage = (10.16.10.6)[E-255]Arithmetic overflow when converting value 12345.24 from type Decimal(7, 2) to type Decimal(6, 3) mysql> desc verbose select named_struct("col_11", a, "col_12", d) from t01; +----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | Explain String(Nereids Planner) | +----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | PLAN FRAGMENT 0 | | OUTPUT EXPRS: | | named_struct("col_11", a, "col_12", d)[apache#2] | | PARTITION: RANDOM | | | | HAS_COLO_PLAN_NODE: false | | | | VRESULT SINK | | MYSQL_PROTOCAL | | | | 0:VOlapScanNode(50) | | TABLE: tt.t01(t01), PREAGGREGATION: ON | | partitions=1/1 (t01) | | tablets=10/10, tabletList=1741751856342,1741751856344,1741751856346 ... | | cardinality=2, avgRowSize=2955.0, numNodes=1 | | pushAggOp=NONE | | final projections: named_struct('col_11', a[#0], 'col_12', CAST(d[apache#1] AS struct<col:bigint,col1:decimalv3(6,3)>)) | | final project output tuple id: 1 | | tuple ids: 0 | | | | Tuples: | | TupleDescriptor{id=0, tbl=t01} | | SlotDescriptor{id=0, col=a, colUniqueId=0, type=decimalv3(6,3), nullable=true, isAutoIncrement=false, subColPath=null} | | SlotDescriptor{id=1, col=d, colUniqueId=1, type=struct<col:bigint,col1:decimalv3(7,2)>, nullable=true, isAutoIncrement=false, subColPath=null} | | | | TupleDescriptor{id=1, tbl=t01} | | SlotDescriptor{id=2, col=null, colUniqueId=null, type=struct<col_11:decimalv3(6,3),col_12:struct<col:bigint,col1:decimalv3(6,3)>>, nullable=false, isAutoIncrement=false, subColPath=null} | | | | | | ```
What problem does this PR solve?
before this pr , we deduce the precision of the function named_struct containing the decimal type is same with the precision of the decimal type in select . In this case we can not make right named_struct for multiple decimal value
like :
Issue Number: close #xxx
Related PR: #xxx
Problem Summary:
Release note
None
Check List (For Author)
Test
Behavior changed:
Does this need documentation?
Check List (For Reviewer who merge this PR)