-
Notifications
You must be signed in to change notification settings - Fork 2.6k
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-6934 In PutDatabaseRecord added Postgres UPSERT support #4350
Conversation
...standard-processors/src/main/java/org/apache/nifi/processors/standard/PutDatabaseRecord.java
Show resolved
Hide resolved
Looking and working good, just some comments on extending the documentation to make things as clear as possible, should be good to go after that |
@@ -101,6 +106,7 @@ | |||
static final String UPDATE_TYPE = "UPDATE"; | |||
static final String INSERT_TYPE = "INSERT"; | |||
static final String DELETE_TYPE = "DELETE"; | |||
static final String UPSERT_TYPE = "UPSERT"; |
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.
Minor: I think this is not a really widely known terminology. It might worth to think about UPDATE_OR_INSERT for better readability. (at least in variable name)
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.
UPSERT
is a fairly widespread expression, although not a standard.
The standard would be MERGE
but many RDBMS - Postgres for one - doesn't support it. (And it's a more than 10 year old standard so I guess we'll just have to live without it.)
Okay, let's got with "UPDATE_OR_INSERT" to describe the concept.
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.
I would vote for the original UPSERT but don't want to veto the change.
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.
I'll keep it as "UPSERT" after all. It's sufficiently understandable (the expression is widely used), simpler and don't want to rename supportsUpsert
to something like supportsInsertOrUpdate
.
.map(__ -> "?") | ||
.collect(Collectors.joining(", ")); | ||
|
||
String updateValues = columnNames.stream() |
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.
Minor: updateColumns?
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.
But these are values for the update.
@@ -0,0 +1,68 @@ | |||
/* |
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.
Could you please add a test like TestMSSQLDatabaseAdapter?
@@ -29,6 +29,8 @@ | |||
import org.apache.nifi.annotation.lifecycle.OnScheduled; |
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.
Could you please extend TestPutDatabaseRecord with relevant case?
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.
Unfortunately we will have to settle for manual testing.
TestPutDatabaseRecord
is not suitable for testing non-standard functionality (it uses derby).
Can you please change the base branch of this PR to |
+1 LGTM, ran contrib-check and tested a few scenarios. @simonbence @turcsanyip Are your reviews complete? If so I can merge to main. Thanks for this improvement! It will also make it easier to do DB-specific things now that we have the Database Type property in there. |
I got answer for my questions, thanks! LGTM |
LGTM too. |
…port for Postgres (9.5+) NIFI-6934 Added more documentation and unit tests. NIFI-6934 Added missing license for new test class. Signed-off-by: Matthew Burgess <mattyb149@apache.org> This closes apache#4350
…port for Postgres (9.5+) NIFI-6934 Added more documentation and unit tests. NIFI-6934 Added missing license for new test class. Signed-off-by: Matthew Burgess <mattyb149@apache.org> This closes apache#4350
…port for Postgres (9.5+) NIFI-6934 Added more documentation and unit tests. NIFI-6934 Added missing license for new test class. Signed-off-by: Matthew Burgess <mattyb149@apache.org> This closes apache#4350
…port for Postgres (9.5+) NIFI-6934 Added more documentation and unit tests. NIFI-6934 Added missing license for new test class. Signed-off-by: Matthew Burgess <mattyb149@apache.org> This closes apache#4350
https://issues.apache.org/jira/browse/NIFI-6934
Implemented using
DatabaseAdapter
For all changes:
Is there a JIRA ticket associated with this PR? Is it referenced
in the commit message?
Does your PR title start with NIFI-XXXX where XXXX is the JIRA number you are trying to resolve? Pay particular attention to the hyphen "-" character.
Has your PR been rebased against the latest commit within the target branch (typically
master
)?Is your initial contribution a single, squashed commit? Additional commits in response to PR reviewer feedback should be made on this branch and pushed to allow change tracking. Do not
squash
or use--force
when pushing to allow for clean monitoring of changes.For code changes:
mvn -Pcontrib-check clean install
at the rootnifi
folder?LICENSE
file, including the mainLICENSE
file undernifi-assembly
?NOTICE
file, including the mainNOTICE
file found undernifi-assembly
?.displayName
in addition to .name (programmatic access) for each of the new properties?For documentation related changes:
Note:
Please ensure that once the PR is submitted, you check GitHub Actions CI for build issues and submit an update to your PR as soon as possible.