Skip to content

Update JdbcOutput.java for JDBC append#38

Open
GianfrancoCusmano wants to merge 2 commits intocloudera-labs:branch-0.7from
GianfrancoCusmano:patch-1
Open

Update JdbcOutput.java for JDBC append#38
GianfrancoCusmano wants to merge 2 commits intocloudera-labs:branch-0.7from
GianfrancoCusmano:patch-1

Conversation

@GianfrancoCusmano
Copy link
Copy Markdown

@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
Copy Markdown
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