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-6934 In PutDatabaseRecord added Postgres UPSERT support #4350

Closed
wants to merge 3 commits into from

Conversation

tpalfy
Copy link
Contributor

@tpalfy tpalfy commented Jun 18, 2020

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:

  • Have you ensured that the full suite of tests is executed via mvn -Pcontrib-check clean install at the root nifi folder?
  • Have you written or updated unit tests to verify your changes?
  • Have you verified that the full build is successful on JDK 8?
  • Have you verified that the full build is successful on JDK 11?
  • If adding new dependencies to the code, are these dependencies licensed in a way that is compatible for inclusion under ASF 2.0?
  • If applicable, have you updated the LICENSE file, including the main LICENSE file under nifi-assembly?
  • If applicable, have you updated the NOTICE file, including the main NOTICE file found under nifi-assembly?
  • If adding new Properties, have you added .displayName in addition to .name (programmatic access) for each of the new properties?

For documentation related changes:

  • Have you ensured that format looks appropriate for the output in which it is rendered?

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.

@mattyb149
Copy link
Contributor

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";
Copy link
Contributor

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)

Copy link
Contributor Author

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.

Copy link
Contributor

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.

Copy link
Contributor Author

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()
Copy link
Contributor

Choose a reason for hiding this comment

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

Minor: updateColumns?

Copy link
Contributor Author

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 @@
/*
Copy link
Contributor

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;
Copy link
Contributor

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?

Copy link
Contributor Author

@tpalfy tpalfy Jun 23, 2020

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).

@mattyb149
Copy link
Contributor

Can you please change the base branch of this PR to main and rebase against the latest main branch? That's the one we'll be using from now on. Thanks in advance!

@mattyb149
Copy link
Contributor

+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.

@simonbence
Copy link
Contributor

I got answer for my questions, thanks! LGTM

@turcsanyip
Copy link
Contributor

LGTM too.
@mattyb149 It can be merged from my side.

@mattyb149 mattyb149 closed this in ad95287 Jul 9, 2020
Wastack pushed a commit to Wastack/nifi that referenced this pull request Jul 20, 2020
…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
ets pushed a commit to ets/nifi that referenced this pull request Oct 2, 2020
…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
driesva pushed a commit to driesva/nifi that referenced this pull request Mar 19, 2021
…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
krisztina-zsihovszki pushed a commit to krisztina-zsihovszki/nifi that referenced this pull request Jun 28, 2022
…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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
4 participants