sejal-gupta-ksolves opened a new pull request, #11781: URL: https://github.com/apache/nifi/pull/11781
# Summary [NIFI-15634](https://issues.apache.org/jira/browse/NIFI-15634) ### Description Resolves a regression in `QueryDatabaseTableRecord` where metadata discovery executed a full table query (`SELECT *`) instead of a metadata-safe query (`WHERE 1=0`). When `Database Type` is set to Generic or MySQL, `getDatabaseDialectService()` returns `DatabaseAdapterDatabaseDialectService`. During processor initialization/setup without max-value columns configured, no guard condition was applied during schema inspection, resulting in full table scans that caused high heap usage and JVM memory pressure on production-scale tables. ### Changes Made - **AbstractDatabaseFetchProcessor.java**: Updated `setup()` to execute `getMetadataStatementRequest` with a `WHERE 1=0` guard condition during schema discovery when `Maximum-value Columns` is empty. Added `getMetadataStatementRequest` helper method to construct zero-result requests. Refactored common connection and statement setup to avoid redundant blocks. - **AbstractQueryDatabaseTable.java**: Updated `getQuery()` to construct `whereClauses` before delegating to `DatabaseDialectService`, ensuring filter conditions and max values are properly included in the statement request. # Tracking ### Issue Tracking - [Apache NiFi Jira NIFI-15634](https://issues.apache.org/jira/browse/NIFI-15634) issue created ### Verification - Verified with MySQL `general_log` that schema discovery executes `SELECT * FROM large_table WHERE 1 = 0` prior to data extraction when `Maximum-value Columns` is empty. - Verified that incremental load functionality with `Maximum-value Columns` (e.g., `id`) continues to issue metadata checks with `WHERE 1 = 0` followed by `WHERE id > X` data queries. -- 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]
