Python Forum
pyspark database exception handling
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
pyspark database exception handling
#1
We are replacing our datastage ETL tool with PySpark code.We want to mimic the error handling code in our Python script. Our ETL program fetches rows from source databases(Oracle) and then inserts the final transformed dataset to Oracle database. We are using dataframes and temporary tables in spark for enriching the data. When we insert/update rows to Oracle table we want to log the bad records(rows which failed due to database exceptions) to a text file and continue processing the remaining records. I am looking for some code examples which will help me to achieve this functionality .
Reply
#2
This seems too straightforward for an "example". Literally just wrap the line(s) in a try/except, and either print to the file or use the logging module.
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  PySpark Coding Challenge cpatte7372 4 6,114 Jun-25-2023, 12:56 PM
Last Post: prajwal_0078
  Pyspark dataframe siddhi1919 3 1,235 Apr-25-2023, 12:39 PM
Last Post: snippsat
  pyspark help lokesh 0 766 Jan-03-2023, 04:34 PM
Last Post: lokesh
Star python exception handling handling .... with traceback mg24 3 1,289 Nov-09-2022, 07:29 PM
Last Post: Gribouillis
  How to iterate Groupby in Python/PySpark DrData82 2 2,849 Feb-05-2022, 09:59 PM
Last Post: DrData82
  PySpark Equivalent Code cpatte7372 0 1,271 Jan-14-2022, 08:59 PM
Last Post: cpatte7372
  Pyspark - my code works but I want to make it better Kevin 1 1,798 Dec-01-2021, 05:04 AM
Last Post: Kevin
  TicTacToe Game Add Exception Handling and Warning Function ShaikhShaikh 5 2,431 Nov-03-2021, 05:02 PM
Last Post: deanhystad
  pyspark parallel write operation not working aliyesami 1 1,707 Oct-16-2021, 05:18 PM
Last Post: aliyesami
  pyspark creating temp files in /tmp folder aliyesami 1 5,027 Oct-16-2021, 05:15 PM
Last Post: aliyesami

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020