-
Notifications
You must be signed in to change notification settings - Fork 3.7k
[Enhancement] support information_schema.partitions #40153
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
|
Thank you for your contribution to Apache Doris. Since 2024-03-18, the Document has been moved to doris-website. |
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.
clang-tidy made some suggestions
a07cd26 to
4f87edf
Compare
|
This will resolve a very common need. Thanks for your work. |
|
run buildall |
fe/fe-core/src/main/java/org/apache/doris/tablefunction/MetadataGenerator.java
Outdated
Show resolved
Hide resolved
fe/fe-core/src/main/java/org/apache/doris/tablefunction/MetadataGenerator.java
Outdated
Show resolved
Hide resolved
| ArrayList<Expr> expr = olapTable.getPartitionInfo().getPartitionExprs(); | ||
| String partExpr = (expr != null) ? olapTable.getPartitionInfo().getPartitionExprs().toString() : ""; | ||
|
|
||
| trow.addToColumnValue(new TCell().setStringVal(partExpr)); // PARTITION_EXPRESSION (not available) |
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.
| trow.addToColumnValue(new TCell().setStringVal(partExpr)); // PARTITION_EXPRESSION (not available) | |
| trow.addToColumnValue(new TCell().setStringVal(partExpr)); // PARTITION_EXPRESSION |
| trow.addToColumnValue(new TCell().setStringVal(partExpr)); // PARTITION_EXPRESSION (not available) | ||
| trow.addToColumnValue(new TCell().setStringVal("")); // SUBPARTITION_EXPRESSION (not available) | ||
| trow.addToColumnValue(new TCell().setStringVal( | ||
| olapTable.getPartitionInfo().getPartitionRangeString(partition.getId()))); |
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.
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.
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.
description is similar to mysql but since we support multiple partition column, still will come as a expression in the patition description. eg: [('4'), ('6'))
fe/fe-core/src/main/java/org/apache/doris/tablefunction/MetadataGenerator.java
Outdated
Show resolved
Hide resolved
fe/fe-core/src/main/java/org/apache/doris/tablefunction/MetadataGenerator.java
Outdated
Show resolved
Hide resolved
fe/fe-core/src/main/java/org/apache/doris/tablefunction/MetadataGenerator.java
Outdated
Show resolved
Hide resolved
c808849 to
6a406aa
Compare
b011929 to
77dfc5a
Compare
|
run buildall |
| } else { | ||
| if (nullptr != _param->common_param->user) { | ||
| db_params.__set_user(*(_param->common_param->user)); | ||
| } |
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.
why remove these logic
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.
user and user_ip params are deprecated in TGetDbsParams so removed it.
gensrc/thrift/FrontendService.thrift
Outdated
| TABLE_OPTIONS = 6, | ||
| WORKLOAD_GROUP_PRIVILEGES = 7, | ||
| TABLE_PROPERTIES = 8, | ||
| PARTITIONS, |
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.
using PARTITIONS=9
a79fb02 to
7e9b348
Compare
morningman
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
ee2f814 to
9d75e3e
Compare
|
run buildall |
9d75e3e to
0672fe9
Compare
|
run buildall |
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.
clang-tidy made some suggestions
|
|
||
| #ifndef _SCHEMA_SCANNER_HELPER_H_ | ||
|
|
||
| #include <stdint.h> |
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.
warning: inclusion of deprecated C++ header 'stdint.h'; consider using 'cstdint' instead [modernize-deprecated-headers]
| #include <stdint.h> | |
| #include <cstdint> |
|
TeamCity be ut coverage result: |
TPC-H: Total hot run time: 38823 ms |
TPC-DS: Total hot run time: 194507 ms |
1f42392 to
be402f4
Compare
|
run buildall |
|
TeamCity be ut coverage result: |
TPC-H: Total hot run time: 38276 ms |
TPC-DS: Total hot run time: 193427 ms |
ClickBench: Total hot run time: 32.14 s |
morningman
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
|
PR approved by at least one committer and no changes requested. |
## Proposed changes Issue Number: close #xxx refactor code to avoid wrong usage Followup #40153 #40553 Test result: mysql> select * from routines; +---------------------+-----------------+----------------+---------------------+--------------+----------------+-----------------------------------------------------------------------------------------+--------------------+---------------+-------------------+-----------------+------------------+-----------------+----------+---------------+---------------------+---------------------+----------+-----------------+---------+----------------------+----------------------+--------------------+ | SPECIFIC_NAME | ROUTINE_CATALOG | ROUTINE_SCHEMA | ROUTINE_NAME | ROUTINE_TYPE | DTD_IDENTIFIER | ROUTINE_BODY | ROUTINE_DEFINITION | EXTERNAL_NAME | EXTERNAL_LANGUAGE | PARAMETER_STYLE | IS_DETERMINISTIC | SQL_DATA_ACCESS | SQL_PATH | SECURITY_TYPE | CREATED | LAST_ALTERED | SQL_MODE | ROUTINE_COMMENT | DEFINER | CHARACTER_SET_CLIENT | COLLATION_CONNECTION | DATABASE_COLLATION | +---------------------+-----------------+----------------+---------------------+--------------+----------------+-----------------------------------------------------------------------------------------+--------------------+---------------+-------------------+-----------------+------------------+-----------------+----------+---------------+---------------------+---------------------+----------+-----------------+---------+----------------------+----------------------+--------------------+ | TEST_PLSQL_ROUTINE2 | 0 | plsql_routine | TEST_PLSQL_ROUTINE2 | PROCEDURE | | CREATE OR REPLACE PROCEDURE test_plsql_routine2() BEGIN DECLARE a int = 1; print a; END | | NULL | | SQL | | | NULL | DEFINER | 2024-09-09 13:54:47 | 2024-09-09 13:54:47 | | | root | | | | | TEST_PLSQL_ROUTINE3 | 0 | plsql_routine | TEST_PLSQL_ROUTINE3 | PROCEDURE | | CREATE OR REPLACE PROCEDURE test_plsql_routine3() BEGIN DECLARE a int = 1; print a; END | | NULL | | SQL | | | NULL | DEFINER | 2024-09-09 13:54:47 | 2024-09-09 13:54:47 | | | root | | | | | TEST_PLSQL_ROUTINE4 | 0 | plsql_routine | TEST_PLSQL_ROUTINE4 | PROCEDURE | | CREATE OR REPLACE PROCEDURE test_plsql_routine4() BEGIN DECLARE a int = 1; print a; END | | NULL | | SQL | | | NULL | DEFINER | 2024-09-09 13:54:47 | 2024-09-09 13:54:47 | | | root | | | | | TEST_PLSQL_ROUTINE5 | 0 | plsql_routine | TEST_PLSQL_ROUTINE5 | PROCEDURE | | CREATE OR REPLACE PROCEDURE test_plsql_routine5() BEGIN DECLARE a int = 1; print a; END | | NULL | | SQL | | | NULL | DEFINER | 2024-09-09 13:54:47 | 2024-09-09 13:54:47 | | | root | | | | | TEST_PLSQL_ROUTINE1 | 0 | plsql_routine | TEST_PLSQL_ROUTINE1 | PROCEDURE | | CREATE OR REPLACE PROCEDURE test_plsql_routine1() BEGIN DECLARE a int = 1; print a; END | | NULL | | SQL | | | NULL | DEFINER | 2024-09-09 13:54:48 | 2024-09-09 13:54:48 | | | root | | | | +---------------------+-----------------+----------------+---------------------+--------------+----------------+-----------------------------------------------------------------------------------------+--------------------+---------------+-------------------+-----------------+------------------+------- mysql> select UPDATE_TIME from partitions; +---------------------+ | UPDATE_TIME | +---------------------+ | 2024-09-05 05:54:25 | | 2024-09-05 05:54:25 | | 2024-09-05 05:54:25 | | 2024-09-09 13:27:46 | | 2024-09-09 13:26:20 | | 2024-09-09 13:26:20 | | 2024-09-09 13:26:20 | | 2024-09-09 13:26:20 | | 2024-09-09 13:26:20 | | 2024-09-09 13:26:20 | | 2024-09-09 13:26:20 | | 2024-09-09 13:27:46 | | 2024-09-09 13:27:46 | mysql> select * from active_queries; +-----------------------------------+---------------------+---------------+-------------------+--------------------+-------------------+------------------+----------------+--------------+------------------------------+ | QUERY_ID | QUERY_START_TIME | QUERY_TIME_MS | WORKLOAD_GROUP_ID | DATABASE | FRONTEND_INSTANCE | QUEUE_START_TIME | QUEUE_END_TIME | QUERY_STATUS | SQL | +-----------------------------------+---------------------+---------------+-------------------+--------------------+-------------------+------------------+----------------+--------------+------------------------------+ | 8c51705601bf4403-929f1b15051af48e | 2024-09-09 14:06:15 | 19 | 1 | information_schema | 172.20.80.1 | | | | select * from active_queries | +-----------------------------------+---------------------+---------------+-------------------+--------------------+-------------------+------------------+----------------+--------------+------------------------------+
…#40153) (#40636) ## Proposed changes #40568 #40455 #40456 #40153 Test: 2024-09-10 14:46:14.206 INFO [suite-thread-1] (SuiteContext.groovy:299) - Create new connection for user 'partitions_user' 2024-09-10 14:46:14.214 INFO [suite-thread-1] (Suite.groovy:1162) - Execute tag: select_check_5, sql: select TABLE_CATALOG,TABLE_SCHEMA,TABLE_NAME,PARTITION_NAME,SUBPARTITION_NAME,PARTITION_ORDINAL_POSITION,SUBPARTITION_ORDINAL_POSITION,PARTITION_METHOD,SUBPARTITION_METHOD,PARTITION_EXPRESSION,SUBPARTITION_EXPRESSION,PARTITION_DESCRIPTION,TABLE_ROWS,AVG_ROW_LENGTH,DATA_LENGTH,MAX_DATA_LENGTH,INDEX_LENGTH,DATA_FREE,CHECKSUM,PARTITION_COMMENT,NODEGROUP,TABLESPACE_NAME from information_schema.partitions where table_schema="test_partitions_schema_db" order by TABLE_CATALOG,TABLE_SCHEMA,TABLE_NAME,PARTITION_NAME,SUBPARTITION_NAME,PARTITION_ORDINAL_POSITION,SUBPARTITION_ORDINAL_POSITION,PARTITION_METHOD,SUBPARTITION_METHOD,PARTITION_EXPRESSION,SUBPARTITION_EXPRESSION,PARTITION_DESCRIPTION,TABLE_ROWS,AVG_ROW_LENGTH,DATA_LENGTH,MAX_DATA_LENGTH,INDEX_LENGTH,DATA_FREE,CHECKSUM,PARTITION_COMMENT,NODEGROUP,TABLESPACE_NAME 2024-09-10 14:46:14.245 INFO [suite-thread-1] (SuiteContext.groovy:309) - Recover original connection 2024-09-10 14:46:14.246 INFO [suite-thread-1] (ScriptContext.groovy:120) - Run test_partitions_schema in /root/doris/workspace/doris/regression-test/suites/query_p0/system/test_partitions_schema.groovy succeed 2024-09-10 14:46:14.252 INFO [main] (RegressionTest.groovy:259) - Start to run single scripts 2024-09-10 14:47:03.655 INFO [main] (RegressionTest.groovy:380) - Success suites: /root/doris/workspace/doris/regression-test/suites/query_p0/system/test_partitions_schema.groovy: group=default,p0, name=test_partitions_schema 2024-09-10 14:47:03.656 INFO [main] (RegressionTest.groovy:459) - All suites success. ____ _ ____ ____ _____ ____ | _ \ / \ / ___/ ___|| ____| _ \ | |_) / _ \ \___ \___ \| _| | | | | | __/ ___ \ ___) |__) | |___| |_| | |_| /_/ \_\____/____/|_____|____/ 2024-09-10 14:47:03.656 INFO [main] (RegressionTest.groovy:410) - Test 1 suites, failed 0 suites, fatal 0 scripts, skipped 0 scripts 2024-09-10 14:49:48.239 INFO [suite-thread-2] (Suite.groovy:1162) - Execute tag: sql, sql: select * from triggers 2024-09-10 14:49:48.261 INFO [suite-thread-2] (Suite.groovy:1162) - Execute tag: sql, sql: select * from parameters 2024-09-10 14:49:48.280 INFO [suite-thread-2] (Suite.groovy:1162) - Execute tag: sql, sql: select * from profiling 2024-09-10 14:49:48.294 INFO [suite-thread-2] (ScriptContext.groovy:120) - Run test_query_sys_tables in /root/doris/workspace/doris/regression-test/suites/query_p0/system/test_query_sys_tables.groovy succeed 2024-09-10 14:49:58.800 INFO [main] (RegressionTest.groovy:259) - Start to run single scripts 2024-09-10 14:50:48.173 INFO [main] (RegressionTest.groovy:380) - Success suites: /root/doris/workspace/doris/regression-test/suites/nereids_p0/system/test_query_sys_tables.groovy: group=query,p0, name=test_query_sys_tables /root/doris/workspace/doris/regression-test/suites/query_p0/system/test_query_sys_tables.groovy: group=query,p0, name=test_query_sys_tables 2024-09-10 14:50:48.174 INFO [main] (RegressionTest.groovy:459) - All suites success. ____ _ ____ ____ _____ ____ | _ \ / \ / ___/ ___|| ____| _ \ | |_) / _ \ \___ \___ \| _| | | | | | __/ ___ \ ___) |__) | |___| |_| | |_| /_/ \_\____/____/|_____|____/ 2024-09-10 14:50:48.175 INFO [main] (RegressionTest.groovy:410) - Test 2 suites, failed 0 suites, fatal 0 scripts, skipped 0 scripts 2024-09-10 14:50:48.175 INFO [main] (RegressionTest.groovy:119) - Test finished --------- Co-authored-by: Mingyu Chen <morningman.cmy@gmail.com>
#40687) backport #40568 #40455 #40456 #40153 #34384 Test result: 2024-09-11 11:00:45.618 INFO [suite-thread-1] (SuiteContext.groovy:309) - Recover original connection 2024-09-11 11:00:45.619 INFO [suite-thread-1] (Suite.groovy:359) - Execute sql: REVOKE SELECT_PRIV ON test_partitions_schema_db.duplicate_table FROM partitions_user 2024-09-11 11:00:45.625 INFO [suite-thread-1] (SuiteContext.groovy:299) - Create new connection for user 'partitions_user' 2024-09-11 11:00:45.632 INFO [suite-thread-1] (Suite.groovy:1162) - Execute tag: select_check_5, sql: select TABLE_CATALOG,TABLE_SCHEMA,TABLE_NAME,PARTITION_NAME,SUBPARTITION_NAME,PARTITION_ORDINAL_POSITION,SUBPARTITION_ORDINAL_POSITION,PARTITION_METHOD,SUBPARTITION_METHOD,PARTITION_EXPRESSION,SUBPARTITION_EXPRESSION,PARTITION_DESCRIPTION,TABLE_ROWS,AVG_ROW_LENGTH,DATA_LENGTH,MAX_DATA_LENGTH,INDEX_LENGTH,DATA_FREE,CHECKSUM,PARTITION_COMMENT,NODEGROUP,TABLESPACE_NAME from information_schema.partitions where table_schema="test_partitions_schema_db" order by TABLE_CATALOG,TABLE_SCHEMA,TABLE_NAME,PARTITION_NAME,SUBPARTITION_NAME,PARTITION_ORDINAL_POSITION,SUBPARTITION_ORDINAL_POSITION,PARTITION_METHOD,SUBPARTITION_METHOD,PARTITION_EXPRESSION,SUBPARTITION_EXPRESSION,PARTITION_DESCRIPTION,TABLE_ROWS,AVG_ROW_LENGTH,DATA_LENGTH,MAX_DATA_LENGTH,INDEX_LENGTH,DATA_FREE,CHECKSUM,PARTITION_COMMENT,NODEGROUP,TABLESPACE_NAME 2024-09-11 11:00:45.644 INFO [suite-thread-1] (SuiteContext.groovy:309) - Recover original connection 2024-09-11 11:00:45.645 INFO [suite-thread-1] (ScriptContext.groovy:120) - Run test_partitions_schema in /root/doris/workspace/doris/regression-test/suites/query_p0/system/test_partitions_schema.groovy succeed 2024-09-11 11:00:45.652 INFO [main] (RegressionTest.groovy:259) - Start to run single scripts 2024-09-11 11:01:10.321 INFO [main] (RegressionTest.groovy:380) - Success suites: /root/doris/workspace/doris/regression-test/suites/query_p0/system/test_partitions_schema.groovy: group=default,p0, name=test_partitions_schema 2024-09-11 11:01:10.322 INFO [main] (RegressionTest.groovy:459) - All suites success. ____ _ ____ ____ _____ ____ | _ \ / \ / ___/ ___|| ____| _ \ | |_) / _ \ \___ \___ \| _| | | | | | __/ ___ \ ___) |__) | |___| |_| | |_| /_/ \_\____/____/|_____|____/ 2024-09-11 11:01:10.322 INFO [main] (RegressionTest.groovy:410) - Test 1 suites, failed 0 suites, fatal 0 scripts, skipped 0 scripts 2024-09-11 11:01:10.322 INFO [main] (RegressionTest.groovy:119) - Test finished 2024-09-11 11:03:00.712 INFO [suite-thread-1] (Suite.groovy:1162) - Execute tag: select_check_5, sql: select * from information_schema.table_options ORDER BY TABLE_CATALOG,TABLE_SCHEMA,TABLE_NAME,TABLE_MODEL,TABLE_MODEL_KEY,DISTRIBUTE_KEY,DISTRIBUTE_TYPE,BUCKETS_NUM,PARTITION_NUM; 2024-09-11 11:03:00.729 INFO [suite-thread-1] (SuiteContext.groovy:309) - Recover original connection 2024-09-11 11:03:00.731 INFO [suite-thread-1] (ScriptContext.groovy:120) - Run test_table_options in /root/doris/workspace/doris/regression-test/suites/query_p0/system/test_table_options.groovy succeed 2024-09-11 11:03:04.817 INFO [main] (RegressionTest.groovy:259) - Start to run single scripts 2024-09-11 11:03:28.741 INFO [main] (RegressionTest.groovy:380) - Success suites: /root/doris/workspace/doris/regression-test/suites/query_p0/system/test_table_options.groovy: group=default,p0, name=test_table_options 2024-09-11 11:03:28.742 INFO [main] (RegressionTest.groovy:459) - All suites success. ____ _ ____ ____ _____ ____ | _ \ / \ / ___/ ___|| ____| _ \ | |_) / _ \ \___ \___ \| _| | | | | | __/ ___ \ ___) |__) | |___| |_| | |_| /_/ \_\____/____/|_____|____/ 2024-09-11 11:03:28.742 INFO [main] (RegressionTest.groovy:410) - Test 1 suites, failed 0 suites, fatal 0 scripts, skipped 0 scripts 2024-09-11 11:03:28.742 INFO [main] (RegressionTest.groovy:119) - Test finished *************************** 7. row *************************** PartitionId: 18035 PartitionName: p100 VisibleVersion: 2 VisibleVersionTime: 2024-09-11 10:59:28 State: NORMAL PartitionKey: col_1 Range: [types: [INT]; keys: [83647]; ..types: [INT]; keys: [2147483647]; ) DistributionKey: pk Buckets: 10 ReplicationNum: 1 StorageMedium: HDD CooldownTime: 9999-12-31 15:59:59 RemoteStoragePolicy: LastConsistencyCheckTime: NULL DataSize: 2.872 KB IsInMemory: false ReplicaAllocation: tag.location.default: 1 IsMutable: true SyncWithBaseTables: true UnsyncTables: NULL CommittedVersion: 2 RowCount: 4 7 rows in set (0.01 sec) --------- Co-authored-by: Mingyu Chen <morningman.cmy@gmail.com>
|
Hi, I added document of this PR here. could u please review it? thx~ |


Proposed changes
Issue Number: close #xxx
select * from information_schema.partitions ; return empty.
this PR will fill the information based on partitions information available.
first only supported for olaptables.