hailin0 commented on code in PR #7248:
URL: https://github.com/apache/seatunnel/pull/7248#discussion_r1689177782
##########
seatunnel-connectors-v2/connector-cdc/connector-cdc-oracle/src/main/java/org/apache/seatunnel/connectors/seatunnel/cdc/oracle/utils/OracleUtils.java:
##########
@@ -81,27 +82,42 @@ public static Object[] queryMinMax(JdbcConnection jdbc,
TableId tableId, String
});
}
- public static long queryApproximateRowCnt(JdbcConnection jdbc, TableId
tableId)
+ public static long queryApproximateRowCnt(
+ OracleSourceConfig oracleSourceConfig, JdbcConnection jdbc,
TableId tableId)
throws SQLException {
+ Boolean useSelectCount = oracleSourceConfig.getUseSelectCount();
+ Boolean skipAnalyze = oracleSourceConfig.getSkipAnalyze();
final String analyzeTable =
Review Comment:
move to 104 line
##########
docs/en/connector-v2/source/Oracle-CDC.md:
##########
@@ -270,6 +272,44 @@ source {
}
```
+> Use the select count(*) instead of analysis table for count table rows in
full stage
+>
+> ```conf
+> source {
+> # This is a example source plugin **only for test and demonstrate the
feature source plugin**
+> Oracle-CDC {
+> result_table_name = "customers"
+> use_select_count = true
+> username = "system"
+> password = "oracle"
+> database-names = ["XE"]
+> schema-names = ["DEBEZIUM"]
+> table-names = ["XE.DEBEZIUM.FULL_TYPES"]
+> base-url = "jdbc:oracle:thin:system/oracle@oracle-host:1521:xe"
+> source.reader.close.timeout = 120000
+> }
+> }
+> ```
+>
+> Use the select NUM_ROWS from all_tables for the table rows but skip the
analyze table.
+>
+> ```conf
+> source {
+> # This is a example source plugin **only for test and demonstrate the
feature source plugin**
+> Oracle-CDC {
+> result_table_name = "customers"
+> skip_analyze = true
+> username = "system"
+> password = "oracle"
+> database-names = ["XE"]
+> schema-names = ["DEBEZIUM"]
+> table-names = ["XE.DEBEZIUM.FULL_TYPES"]
+> base-url = "jdbc:oracle:thin:system/oracle@oracle-host:1521:xe"
+> source.reader.close.timeout = 120000
Review Comment:
What's this?
##########
seatunnel-connectors-v2/connector-jdbc/src/main/java/org/apache/seatunnel/connectors/seatunnel/jdbc/internal/dialect/oracle/OracleDialect.java:
##########
@@ -180,20 +180,30 @@ public String tableIdentifier(TablePath tablePath) {
public Long approximateRowCntStatement(Connection connection,
JdbcSourceTable table)
throws SQLException {
- // 1. If no query is configured, use TABLE STATUS.
- // 2. If a query is configured but does not contain a WHERE clause and
tablePath is
+ // 1. Use select count
+ // 2. If no query is configured, use TABLE STATUS.
+ // 3. If a query is configured but does not contain a WHERE clause and
tablePath is
// configured, use TABLE STATUS.
- // 3. If a query is configured with a WHERE clause, or a query
statement is configured but
+ // 4. If a query is configured with a WHERE clause, or a query
statement is configured but
// tablePath is TablePath.DEFAULT, use COUNT(*).
+ String query = table.getQuery();
+
boolean useTableStats =
- StringUtils.isBlank(table.getQuery())
- || (!table.getQuery().toLowerCase().contains("where")
+ StringUtils.isBlank(query)
+ || (!query.toLowerCase().contains("where")
&& table.getTablePath() != null
&& !TablePath.DEFAULT
.getFullName()
.equals(table.getTablePath().getFullName()));
+ if (table.getUseSelectCount()) {
+ useTableStats = false;
+ if (StringUtils.isBlank(query)) {
+ query = "SELECT * FROM " +
tableIdentifier(table.getTablePath());
+ }
+ }
+
if (useTableStats) {
TablePath tablePath = table.getTablePath();
String analyzeTable =
Review Comment:
move to 220 line
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]