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

Update JdbcOutput.java for JDBC append #38

Open
wants to merge 2 commits into
base: branch-0.7
Choose a base branch
from

Conversation

GianfrancoCusmano
Copy link

@GianfrancoCusmano GianfrancoCusmano commented Jul 18, 2019

Update JdbcOutput.java to resolve JDBC append issue.

DataFrameWriter defaults to SaveMode.ErrorIfExists, not allowing for appending to an existing table.
Explicitly set SaveMode to Append.

Update JdbcOutput.java to resolve JDBC append issue.

Alternatively, to remain more in line with FileSystemOutput.java and HiveOutput.java, code can similarly be modified as per below snippet:

[...]

for (Tuple2<MutationType, Dataset<Row>> plan : planned) {
      MutationType mutationType = plan._1();
      Dataset<Row> mutation = plan._2();
      DataFrameWriter<Row> writer = mutation.write();
      switch (mutationType) {
        case INSERT:
          writer = writer.mode(SaveMode.Append);
          writer.jdbc(url, tableName, properties);
          break;
        default:
          throw new RuntimeException("JDBC output does not support mutation type: " + mutationType);

[...]
@GianfrancoCusmano
Copy link
Author

Hello @jeremybeard,

I am currently using Envelope for a project I am working on, and came across an issue while trying to append when using JDBC as an output, with an planner type of append. I have provided my solution as per this pull request, any feedback and review on the code change would be greatly appreciated.

Best Regards,
Gianfranco Cusmano

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.

1 participant