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

[Feature] Support multi expression partition table #52407

Merged
merged 1 commit into from
Nov 13, 2024

Conversation

meegoo
Copy link
Contributor

@meegoo meegoo commented Oct 29, 2024

Why I'm doing:

mysql> create table t(k1 int, k2 bigint, v int) PRIMARY KEY(k1, k2) partition by from_unixtime(k2, '%Y-%m-%d'),k1;
Query OK, 0 rows affected (0.02 sec)

mysql> show create table t;
+-------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| Table | Create Table                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                |
+-------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| t     | CREATE TABLE `t` (
  `k1` int(11) NOT NULL COMMENT "",
  `k2` bigint(20) NOT NULL COMMENT "",
  `v` int(11) NULL COMMENT "",
  `__generated_partition_column_0` varchar(1048576) NULL AS from_unixtime(`d`.`t`.`k2`, '%Y-%m-%d') COMMENT ""
) ENGINE=OLAP
PRIMARY KEY(`k1`, `k2`)
PARTITION BY (`__generated_partition_column_0`,`k1`)
DISTRIBUTED BY HASH(`k1`, `k2`)
PROPERTIES (
"compression" = "LZ4",
"enable_persistent_index" = "true",
"fast_schema_evolution" = "true",
"replicated_storage" = "true",
"replication_num" = "3"
); |
+-------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
1 row in set (0.00 sec)

mysql> explain select * from t where k2=UNIX_TIMESTAMP('2007-11-30 10:30:19');
+------------------------------------------------------------------------+
| Explain String                                                         |
+------------------------------------------------------------------------+
| PLAN FRAGMENT 0                                                        |
|  OUTPUT EXPRS:1: k1 | 2: k2 | 3: v | 4: __generated_partition_column_0 |
|   PARTITION: UNPARTITIONED                                             |
|                                                                        |
|   RESULT SINK                                                          |
|                                                                        |
|   1:EXCHANGE                                                           |
|                                                                        |
| PLAN FRAGMENT 1                                                        |
|  OUTPUT EXPRS:                                                         |
|   PARTITION: RANDOM                                                    |
|                                                                        |
|   STREAM DATA SINK                                                     |
|     EXCHANGE ID: 01                                                    |
|     UNPARTITIONED                                                      |
|                                                                        |
|   0:OlapScanNode                                                       |
|      TABLE: t                                                          |
|      PREAGGREGATION: ON                                                |
|      PREDICATES: 2: k2 = 1196389819                                    |
|      partitions=1/3                                                    |
|      rollup: t                                                         |
|      tabletRatio=6/6                                                   |
|      tabletList=24092,24096,24100,24104,24108,24112                    |
|      cardinality=1                                                     |
|      avgRowSize=26.0                                                   |
+------------------------------------------------------------------------+
26 rows in set (0.01 sec)

What I'm doing:

Fixes #52408

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

@meegoo meegoo requested review from a team as code owners October 29, 2024 00:43
@mergify mergify bot assigned meegoo Oct 29, 2024
@meegoo meegoo force-pushed the multi_expr_partition branch 2 times, most recently from 1ccb27d to 3e07d4d Compare October 29, 2024 23:35
@meegoo meegoo force-pushed the multi_expr_partition branch 2 times, most recently from d5f8e93 to df6f34e Compare November 6, 2024 00:46
@meegoo meegoo enabled auto-merge (squash) November 7, 2024 05:50
@meegoo meegoo requested a review from a team as a code owner November 10, 2024 06:47
Copy link

sonarcloud bot commented Nov 11, 2024

Copy link

[Java-Extensions Incremental Coverage Report]

pass : 0 / 0 (0%)

Copy link

[FE Incremental Coverage Report]

pass : 39 / 43 (90.70%)

file detail

path covered_line new_line coverage not_covered_line_detail
🔵 com/starrocks/sql/analyzer/CreateTableAnalyzer.java 9 11 81.82% [483, 484]
🔵 com/starrocks/sql/ast/ListPartitionDesc.java 19 21 90.48% [66, 67]
🔵 com/starrocks/analysis/Expr.java 7 7 100.00% []
🔵 com/starrocks/sql/optimizer/rewrite/ScalarOperatorEvaluator.java 4 4 100.00% []

Copy link

[BE Incremental Coverage Report]

pass : 0 / 0 (0%)

@meegoo meegoo merged commit 93148a9 into StarRocks:main Nov 13, 2024
59 checks passed
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.

Support multi expression partition syntax
3 participants