This is an automated email from the ASF dual-hosted git repository. lijibing pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/doris.git
The following commit(s) were added to refs/heads/master by this push: new 602ad0761fe [improvement](statistics)Support get oracle jdbc row count. (#45214) 602ad0761fe is described below commit 602ad0761fefb021561ce5d2a67b9cee86244f20 Author: James <lijib...@selectdb.com> AuthorDate: Tue Dec 10 12:58:02 2024 +0800 [improvement](statistics)Support get oracle jdbc row count. (#45214) ### What problem does this PR solve? Support get oracle jdbc row count from oracle statistics if exists. Issue Number: close #xxx Related PR: #xxx Problem Summary: ### Release note None ### Check List (For Author) - Test <!-- At least one of them must be included. --> - [x] Regression test - [ ] Unit Test - [ ] Manual test (add detailed scripts or steps below) - [ ] No need to test or manual test. Explain why: - [ ] This is a refactor/code format and no logic has been changed. - [ ] Previous test can cover this change. - [ ] No code files have been changed. - [ ] Other reason <!-- Add your reason? --> - Behavior changed: - [x] No. - [ ] Yes. <!-- Explain the behavior change --> - Does this need documentation? - [x] No. - [ ] Yes. <!-- Add document PR link here. eg: https://github.com/apache/doris-website/pull/1214 --> ### Check List (For Reviewer who merge this PR) - [x] Confirm the release note - [x] Confirm test cases - [x] Confirm document - [x] Add branch pick label <!-- Add branch pick label that this PR should merge into --> --- .../doris/datasource/jdbc/JdbcExternalTable.java | 5 ++++ .../jdbc/test_jdbc_row_count.groovy | 30 ++++++++++++++++++++++ 2 files changed, 35 insertions(+) diff --git a/fe/fe-core/src/main/java/org/apache/doris/datasource/jdbc/JdbcExternalTable.java b/fe/fe-core/src/main/java/org/apache/doris/datasource/jdbc/JdbcExternalTable.java index 9e188a711b0..772c366850b 100644 --- a/fe/fe-core/src/main/java/org/apache/doris/datasource/jdbc/JdbcExternalTable.java +++ b/fe/fe-core/src/main/java/org/apache/doris/datasource/jdbc/JdbcExternalTable.java @@ -63,6 +63,9 @@ public class JdbcExternalTable extends ExternalTable { public static final String SQLSERVER_ROW_COUNT_SQL = "SELECT sum(rows) as rows FROM sys.partitions " + "WHERE object_id = (SELECT object_id('${dbName}.${tblName}')) AND index_id IN (0, 1)"; + public static final String ORACLE_ROW_COUNT_SQL = "SELECT NUM_ROWS as \\\"rows\\\" FROM ALL_TABLES WHERE " + + "OWNER = '${dbName}' and TABLE_NAME = '${tblName}'"; + public static final String FETCH_ROW_COUNT_TEMPLATE = "SELECT * FROM QUERY" + "(\"catalog\"=\"${ctlName}\", \"query\"=\"${sql}\");"; @@ -144,6 +147,8 @@ public class JdbcExternalTable extends ExternalTable { params.put("sql", SQLSERVER_ROW_COUNT_SQL); return getRowCount(params); case JdbcResource.ORACLE: + params.put("sql", ORACLE_ROW_COUNT_SQL); + return getRowCount(params); default: break; } diff --git a/regression-test/suites/external_table_p0/jdbc/test_jdbc_row_count.groovy b/regression-test/suites/external_table_p0/jdbc/test_jdbc_row_count.groovy index 5cb1f6267e3..c8220ce13dd 100644 --- a/regression-test/suites/external_table_p0/jdbc/test_jdbc_row_count.groovy +++ b/regression-test/suites/external_table_p0/jdbc/test_jdbc_row_count.groovy @@ -102,6 +102,36 @@ suite("test_jdbc_row_count", "p0,external,mysql,external_docker,external_docker_ } assertEquals("3", result[0][2]) sql """drop catalog ${catalog_name}""" + + // Test oracle + catalog_name = "test_oracle_jdbc_row_count"; + String oracle_port = context.config.otherConfigs.get("oracle_11_port"); + String SID = "XE"; + driver_url = "https://${bucket}.${s3_endpoint}/regression/jdbc_driver/ojdbc8.jar" + sql """drop catalog if exists ${catalog_name} """ + sql """ + create catalog if not exists ${catalog_name} properties( + "type"="jdbc", + "user"="doris_test", + "password"="123456", + "jdbc_url" = "jdbc:oracle:thin:@${externalEnvIp}:${oracle_port}:${SID}", + "driver_url" = "${driver_url}", + "driver_class" = "oracle.jdbc.driver.OracleDriver" + ); + """ + sql """use ${catalog_name}.DORIS_TEST""" + result = sql """show table stats STUDENT""" + Thread.sleep(1000) + for (int i = 0; i < 30; i++) { + result = sql """show table stats STUDENT"""; + if (result[0][2] != "-1") { + break; + } + logger.info("Table row count not ready yet. Wait 1 second.") + Thread.sleep(1000) + } + assertTrue("4".equals(result[0][2]) || "-1".equals(result[0][2])) + sql """drop catalog ${catalog_name}""" } } --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscr...@doris.apache.org For additional commands, e-mail: commits-h...@doris.apache.org