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

NIFI-14129 Add Database Dialect Service #9640

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

exceptionfactory
Copy link
Contributor

Summary

NIFI-14129 Adds a DatabaseDialectService Controller Service interface in a new nifi-database-dialect-service-api as a migration path the existing internal DatabaseAdapter interface and associated implementations.

The new nifi-database-dialect-service-nar includes a StandardDatabaseDialectService implementation that provides a generic implementation for the minimum Statement Types of ALTER, CREATE, and SELECT.

The introduction of the DatabaseDialectService applies to the following Processors:

  • PutDatabaseRecord
  • GenerateTableFetch
  • QueryDatabaseTable
  • QueryDatabaseTableRecord
  • UpdateDatabaseTable

The service also applies to the DatabaseParameterProvider.

This pull request provides an interim transitional strategy for moving away from the DatabaseAdapter to the new DatabaseDialectService. The initial set of changes preserve existing Database Type properties that use DatabaseAdapter implementations and wraps interacts with the DatabaseAdapter in a new DatabaseAdapterDatabaseDialectService.

Existing Database Type properties include a new value named Database Dialect Service that enables the dependent Database Dialect Service property for Controller Service implementations.

This wrapping approach avoids the need to convert existing DatabaseAdapter implementations as part of this change, allowing existing Processor configurations to work without changes, while also support incremental migration of DatabaseAdapter implementations to new DatabaseDialectService implementations.

The DatabaseDialectService interface has a simplified contract method named getStatement() which takes a StatementRequest and returns a StatementResponse containing rendered SQL. The StatementRequest interface has standard implementations, and a QueryStatementRequest extended interface for describing queries. The getSupportedStatementTypes() provides a concise method for implementations to indicate supported statements.

Changes include modifications to existing unit tests that involved direct access to Processor methods using the DatabaseAdapter. Existing unit and integration tests against public methods and behaviors remain in place to validate implementation changes.

Tracking

Please complete the following tracking steps prior to pull request creation.

Issue Tracking

Pull Request Tracking

  • Pull Request title starts with Apache NiFi Jira issue number, such as NIFI-00000
  • Pull Request commit message starts with Apache NiFi Jira issue number, as such NIFI-00000

Pull Request Formatting

  • Pull Request based on current revision of the main branch
  • Pull Request refers to a feature branch with one commit containing changes

Verification

Please indicate the verification steps performed prior to pull request creation.

Build

  • Build completed using mvn clean install -P contrib-check
    • JDK 21

Licensing

  • New dependencies are compatible with the Apache License 2.0 according to the License Policy
  • New dependencies are documented in applicable LICENSE and NOTICE files

Documentation

  • Documentation formatting appears as expected in rendered files

- Added database-dialect-service-api
- Added Standard Database Dialect Service implementation
- Added Database Adapter implementation
- Added Database Dialect Service property descriptor to Database Processors
- Refactored Database Processors with optional Database Dialect Service
Copy link
Contributor

@pvillard31 pvillard31 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Huge PR, thanks @exceptionfactory !

I have been through extensive testing all day using Postgres and MySQL databases. I have tested many cases before and after this PR (INSERTs, UPDATEs, UPSERTs, DELETEs). Everything is working as expected and I didn't catch any regression / breaking change.

I also tried the new Standard Database Dialect controller service with basic statements and it worked well. I believe this new interface is covering all of the needs we may have in the future while still being very generic.

The approach you used to keep the "old" way and the "new" way is really cool and it is a great addition! Given the size of the PR, I'll wait until some day next week before merging in case someone else in the community wants to give it a try / to provide feedback. I'm a +1 as far as I'm concerned.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants