2

I have two almost identical write into db . scala statement ,however one trowing me an error the other not and i don't understand how to fix it ? any ideas ?

this statement is working

df_pm_visits_by_site_trn.write.format("jdbc").option("url", db_url_2).option("dbtable", "pm_visits_by_site_trn").option("user", db_user).option("password", db_pwd).option("truncate","true").mode("overwrite").save()

this one doesn't work and throwing me compiling error

df_trsnss .write.format("jdbc").option("url", db_url_2).option("dbtable", "df_trsnss")               .option("user", db_user).option("password", db_pwd).option("truncate","true").mode("overwrite").save()

_dev.scala:464: value write is not a member of org.apache.spark.sql.DataFrameReader [error] df_trsnss.write.format("jdbc").option("url", db_url_2).option("dbtable", "trsnss").option("user", db_user).option("password", db_pwd).option("truncate","true").mode("overwrite").save()

if i delete my second write statement or just simply comment it out whole code is compiling with no errors.

1 Answer 1

6

Based on the error message, df_trsnss is a DataFrameReader, not a DataFrame. You likely forgot to call load.

val df_trsnss = spark.read.format("csv")

instead of

val df_trsnss = spark.read.format("csv").load("...")

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.