1

I am using spark df write to write to oracle table -

When the data is written the underlying oracle table structure is changed by spark

df.write.
                  mode(SaveMode.Overwrite).
                  jdbc(targetJdbcUrl, targetTable, targetProps)

Is there a way to prevent spark from modifying the table structure?

For example -

source_desc varchar(200)

get converted to

source_desc varchar(255)
surajz
  • 3,471
  • 3
  • 32
  • 38

2 Answers2

0

mode(SaveMode.Append) also changing the schema based on dataframe schema , if both dataframe and oracle table schema then only it is not changing.

Murali
  • 289
  • 3
  • 8
-2
 mode(SaveMode.Append)

Did the trick.

surajz
  • 3,471
  • 3
  • 32
  • 38
  • 1
    This does not provide an answer to the question. To critique or request clarification from an author, leave a comment below their post. - [From Review](/review/low-quality-posts/19784837) – Rann Lifshitz May 21 '18 at 03:31
  • That is the correct answer. (Use SaveMode.Append instead of SaveMode.Overwrite to prevent spark from updating jdbc table structure) – surajz May 22 '18 at 04:27
  • My first comment is a deault review comment. Your answer was flagged as a low quality one due to its content and format. Edit it with the additonal explanation you provided in your comment here and I will upvote it. – Rann Lifshitz May 22 '18 at 06:02