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

[BugFix] List partition values should not contain NULL partition value if this column is not nullable (backport #51086) (backport #51147) #51163

Closed
wants to merge 1 commit into from

Conversation

mergify[bot]
Copy link
Contributor

@mergify mergify bot commented Sep 19, 2024

Why I'm doing:

Bug1: Primary key column is not null by default, add a null value partition should not be valid.

CREATE TABLE t3 (
  dt date,
  city varchar(20),
  name varchar(20),
  num int
) ENGINE=OLAP
PRIMARY KEY(dt, city, name)
COMMENT "OLAP"
PARTITION BY LIST (dt) (
    PARTITION p1 VALUES IN ((NULL), ("2022-04-01")),
    PARTITION p2 VALUES IN (("2022-04-02")),
    PARTITION p3 VALUES IN (("2022-04-03"))
)
DISTRIBUTED BY HASH(dt) BUCKETS 3
PROPERTIES (
    "replication_num" = "1"
);

INSERT INTO t3 VALUES ('2022-04-01', 'beijing', 'jack', 1),
                      ('2022-04-02', 'beijing', 'jack', 2),
                      ('2022-04-02', 'beijing', 'jack', 3),
                      ('2022-04-02', 'shanghai', 'nacy', 3),
                      (null, 'shanghai', 'nacy', 6);

 (1064, 'invalid date literal in partition column, date=TDateLiteral(value=) backend [id=10002] [host=172.26.95.121]'
 

Bug2: t3 only contains 3 partitions but displays partitionsRatio=3/4


| PLAN FRAGMENT 2(F00)                                                                                                 |                                                                                                                                                                                                                                            |                                                                                                                      |                                                                                                                                                                                                                                            |   Input Partition: RANDOM                                                                                            |                                                                                                                                                                                                                                            |   OutPut Partition: HASH_PARTITIONED: 8: dt, 9: province                                                             |                                                                                                                                                                                                                                            |   OutPut Exchange Id: 02                                                                                             |                                                                                                                                                                                                                                            |                                                                                                                      |                                                                                                                                                                                                                                            |   1:AGGREGATE (update serialize)                                                                                     |                                                                                                                                                                                                                                            |   |  STREAMING                                                                                                       |                                                                                                                                                                                                                                            |   |  aggregate: sum[([3: num, INT, true]); args: INT; result: BIGINT; args nullable: true; result nullable: true]    |                                                                                                                                                                                                                                            |   |  group by: [8: dt, INT, true], [9: province, INT, true]                                                          |                                                                                                                                                                                                                                            |   |  cardinality: 5                                                                                                  |                                                                                                                                                                                                                                            |   |  column statistics:                                                                                              |                                                                                                                                                                                                                                            |   |  * dt-->[-Infinity, Infinity, 0.0, 10.0, 3.0] ESTIMATE                                                           |                                                                                                                                                                                                                                            |   |  * province-->[-Infinity, Infinity, 0.0, 7.25, 3.0] ESTIMATE                                                     |                                                                                                                                                                                                                                            |   |  * sum-->[1.0, 5.0, 0.0, 8.0, 4.0] ESTIMATE                                                                      |                                                                                                                                                                                                                                            |   |                                                                                                                  |                                                                                                                                                                                                                                            |   0:OlapScanNode                                                                                                     |                                                                                                                                                                                                                                            |      table: t1, rollup: t1                                                                                           |                                                                                                                                                                                                                                            |      preAggregation: on                                                                                              |                                                                                                                                                                                                                                            |      dict_col=dt,province                                                                                            |                                                                                                                                                                                                                                            |      partitionsRatio=3/4, tabletsRatio=3/3                                                                           |                                                                                                                                                                                                                                            |      tabletList=90891,90885,90888                                                                                    |                                                                                                                                                                                                                                            |      actualRows=5, avgRowSize=21.25                                                                                  |                                                                                                                                                                                                                                            |      cardinality: 5                                                                                                  |                                                                                                                                                                                                                                            |      column statistics:                                                                                              |                                                                                                                                                                                                                                            |      * dt-->[-Infinity, Infinity, 0.0, 10.0, 3.0] ESTIMATE                                                           |                                                                                                                                                                                                                                            |      * province-->[-Infinity, Infinity, 0.0, 7.25, 3.0] ESTIMATE                                                     |                                                                                                                                                                                                                                            |      * num-->[1.0, 4.0, 0.0, 4.0, 4.0] ESTIMATE                                                                      |                                                                                                                                                                                                                                            +----------------------------------------------------------------------------------------------------------------------+                                                                                                                                                                                                                                            83 rows in set (1 min 53.25 sec)

What I'm doing:

  • List partition values should not contain NULL partition value if this column is not nullable
  • Display partition values should use visible partitions' size rather than all partitions.

Fixes https://github.com/StarRocks/StarRocksTest/issues/8590

What type of PR is this:

  • BugFix
  • Feature
  • Enhancement
  • Refactor
  • UT
  • Doc
  • Tool

Does this PR entail a change in behavior?

  • Yes, this PR will result in a change in behavior.
  • No, this PR will not result in a change in behavior.

If yes, please specify the type of change:

  • Interface/UI changes: syntax, type conversion, expression evaluation, display information
  • Parameter changes: default values, similar parameters but with different default values
  • Policy changes: use new policy to replace old one, functionality automatically enabled
  • Feature removed
  • Miscellaneous: upgrade & downgrade compatibility, etc.

Checklist:

  • I have added test cases for my bug fix or my new feature
  • This pr needs user documentation (for new or modified features or behaviors)
    • I have added documentation for my new feature or new function
  • This is a backport pr

Bugfix cherry-pick branch check:

  • I have checked the version labels which the pr will be auto-backported to the target branch
    • 3.3
    • 3.2
    • 3.1
    • 3.0
    • 2.5

This is an automatic backport of pull request #51086 done by [Mergify](https://mergify.com). ## Why I'm doing:

Bug1: Primary key column is not null by default, add a null value partition should not be valid.

CREATE TABLE t3 (
  dt date,
  city varchar(20),
  name varchar(20),
  num int
) ENGINE=OLAP
PRIMARY KEY(dt, city, name)
COMMENT "OLAP"
PARTITION BY LIST (dt) (
    PARTITION p1 VALUES IN ((NULL), ("2022-04-01")),
    PARTITION p2 VALUES IN (("2022-04-02")),
    PARTITION p3 VALUES IN (("2022-04-03"))
)
DISTRIBUTED BY HASH(dt) BUCKETS 3
PROPERTIES (
    "replication_num" = "1"
);

INSERT INTO t3 VALUES ('2022-04-01', 'beijing', 'jack', 1),
                      ('2022-04-02', 'beijing', 'jack', 2),
                      ('2022-04-02', 'beijing', 'jack', 3),
                      ('2022-04-02', 'shanghai', 'nacy', 3),
                      (null, 'shanghai', 'nacy', 6);

 (1064, 'invalid date literal in partition column, date=TDateLiteral(value=) backend [id=10002] [host=172.26.95.121]'
 

Bug2: t3 only contains 3 partitions but displays partitionsRatio=3/4


| PLAN FRAGMENT 2(F00)                                                                                                 |                                                                                                                                                                                                                                            |                                                                                                                      |                                                                                                                                                                                                                                            |   Input Partition: RANDOM                                                                                            |                                                                                                                                                                                                                                            |   OutPut Partition: HASH_PARTITIONED: 8: dt, 9: province                                                             |                                                                                                                                                                                                                                            |   OutPut Exchange Id: 02                                                                                             |                                                                                                                                                                                                                                            |                                                                                                                      |                                                                                                                                                                                                                                            |   1:AGGREGATE (update serialize)                                                                                     |                                                                                                                                                                                                                                            |   |  STREAMING                                                                                                       |                                                                                                                                                                                                                                            |   |  aggregate: sum[([3: num, INT, true]); args: INT; result: BIGINT; args nullable: true; result nullable: true]    |                                                                                                                                                                                                                                            |   |  group by: [8: dt, INT, true], [9: province, INT, true]                                                          |                                                                                                                                                                                                                                            |   |  cardinality: 5                                                                                                  |                                                                                                                                                                                                                                            |   |  column statistics:                                                                                              |                                                                                                                                                                                                                                            |   |  * dt-->[-Infinity, Infinity, 0.0, 10.0, 3.0] ESTIMATE                                                           |                                                                                                                                                                                                                                            |   |  * province-->[-Infinity, Infinity, 0.0, 7.25, 3.0] ESTIMATE                                                     |                                                                                                                                                                                                                                            |   |  * sum-->[1.0, 5.0, 0.0, 8.0, 4.0] ESTIMATE                                                                      |                                                                                                                                                                                                                                            |   |                                                                                                                  |                                                                                                                                                                                                                                            |   0:OlapScanNode                                                                                                     |                                                                                                                                                                                                                                            |      table: t1, rollup: t1                                                                                           |                                                                                                                                                                                                                                            |      preAggregation: on                                                                                              |                                                                                                                                                                                                                                            |      dict_col=dt,province                                                                                            |                                                                                                                                                                                                                                            |      partitionsRatio=3/4, tabletsRatio=3/3                                                                           |                                                                                                                                                                                                                                            |      tabletList=90891,90885,90888                                                                                    |                                                                                                                                                                                                                                            |      actualRows=5, avgRowSize=21.25                                                                                  |                                                                                                                                                                                                                                            |      cardinality: 5                                                                                                  |                                                                                                                                                                                                                                            |      column statistics:                                                                                              |                                                                                                                                                                                                                                            |      * dt-->[-Infinity, Infinity, 0.0, 10.0, 3.0] ESTIMATE                                                           |                                                                                                                                                                                                                                            |      * province-->[-Infinity, Infinity, 0.0, 7.25, 3.0] ESTIMATE                                                     |                                                                                                                                                                                                                                            |      * num-->[1.0, 4.0, 0.0, 4.0, 4.0] ESTIMATE                                                                      |                                                                                                                                                                                                                                            +----------------------------------------------------------------------------------------------------------------------+                                                                                                                                                                                                                                            83 rows in set (1 min 53.25 sec)

What I'm doing:

  • List partition values should not contain NULL partition value if this column is not nullable
  • Display partition values should use visible partitions' size rather than all partitions.

Fixes https://github.com/StarRocks/StarRocksTest/issues/8590

What type of PR is this:

  • BugFix
  • Feature
  • Enhancement
  • Refactor
  • UT
  • Doc
  • Tool

Does this PR entail a change in behavior?

  • Yes, this PR will result in a change in behavior.
  • No, this PR will not result in a change in behavior.

If yes, please specify the type of change:

  • Interface/UI changes: syntax, type conversion, expression evaluation, display information
  • Parameter changes: default values, similar parameters but with different default values
  • Policy changes: use new policy to replace old one, functionality automatically enabled
  • Feature removed
  • Miscellaneous: upgrade & downgrade compatibility, etc.

Checklist:

  • I have added test cases for my bug fix or my new feature
  • This pr needs user documentation (for new or modified features or behaviors)
    • I have added documentation for my new feature or new function
  • This is a backport pr

This is an automatic backport of pull request #51147 done by [Mergify](https://mergify.com).

…e if this column is not nullable (backport #51086) (#51147)

Signed-off-by: shuming.li <[email protected]>
Co-authored-by: shuming.li <[email protected]>
(cherry picked from commit a0f340b)

# Conflicts:
#	fe/fe-core/src/test/java/com/starrocks/scheduler/PCTRefreshListPartitionOlapTest.java
@mergify mergify bot added the conflicts label Sep 19, 2024
Copy link
Contributor Author

mergify bot commented Sep 19, 2024

Cherry-pick of a0f340b has failed:

On branch mergify/bp/branch-3.3.4/pr-51147
Your branch is up to date with 'origin/branch-3.3.4'.

You are currently cherry-picking commit a0f340bdbd.
  (fix conflicts and run "git cherry-pick --continue")
  (use "git cherry-pick --skip" to skip this patch)
  (use "git cherry-pick --abort" to cancel the cherry-pick operation)

Changes to be committed:
	modified:   fe/fe-core/src/main/java/com/starrocks/catalog/OlapTable.java
	modified:   fe/fe-core/src/main/java/com/starrocks/planner/OlapScanNode.java
	modified:   fe/fe-core/src/main/java/com/starrocks/sql/Explain.java
	modified:   fe/fe-core/src/main/java/com/starrocks/sql/ast/ListPartitionDesc.java
	modified:   fe/fe-core/src/main/java/com/starrocks/sql/optimizer/rewrite/OptOlapPartitionPruner.java
	modified:   fe/fe-core/src/test/java/com/starrocks/analysis/CreateMaterializedViewTest.java
	modified:   fe/fe-core/src/test/java/com/starrocks/catalog/CreateTableTest.java
	modified:   fe/fe-core/src/test/java/com/starrocks/sql/optimizer/OptimizerTaskTest.java
	modified:   fe/fe-core/src/test/java/com/starrocks/sql/plan/PartitionPruneTest.java
	modified:   test/sql/test_list_partition/R/test_list_partition_prune
	modified:   test/sql/test_list_partition/T/test_list_partition_prune

Unmerged paths:
  (use "git add <file>..." to mark resolution)
	both modified:   fe/fe-core/src/test/java/com/starrocks/scheduler/PCTRefreshListPartitionOlapTest.java

To fix up this pull request, you can check it out locally. See documentation: https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/reviewing-changes-in-pull-requests/checking-out-pull-requests-locally

@CLAassistant
Copy link

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.
You have signed the CLA already but the status is still pending? Let us recheck it.

@wanpengfei-git wanpengfei-git enabled auto-merge (squash) September 19, 2024 09:24
@mergify mergify bot closed this Sep 19, 2024
auto-merge was automatically disabled September 19, 2024 09:24

Pull request was closed

Copy link
Contributor Author

mergify bot commented Sep 19, 2024

@mergify[bot]: Backport conflict, please reslove the conflict and resubmit the pr

@mergify mergify bot deleted the mergify/bp/branch-3.3.4/pr-51147 branch September 19, 2024 09:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant