<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Spark read /write jdbc netsuite TIMESTAMP error NullPointerException in Data Engineering</title>
    <link>https://community.databricks.com/t5/data-engineering/spark-read-write-jdbc-netsuite-timestamp-error/m-p/124771#M47262</link>
    <description>&lt;P&gt;I've connected to Netsuite via Suite Analytics JDBC connection in a Databricks cluster. I'm seeing a NullPointerException because of the lastmodifieddate column in my netsuite classification table (ie. if I do Select * from classification I see the NullPointerException and I've narrowed it down to seeing this issue because of the&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;except Exception as e:&lt;BR /&gt;print("\nERROR: An exception occurred.")&lt;BR /&gt;# The full error will be raised, giving you the complete stack trace.&lt;BR /&gt;raise e&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Error&lt;/P&gt;&lt;P&gt;&lt;SPAN class=""&gt;SparkException: &lt;/SPAN&gt;&lt;SPAN&gt;Job aborted due to stage failure: Task 0 in stage 31.0 failed 4 times, most recent failure: Lost task 0.3 in stage 31.0 (TID 44) (10.21.40.199 executor 0): java.lang.NullPointerException at com.netsuite.jdbc.base.hk.a(oajc:654) at com.netsuite.jdbc.base.dj.c(oajc:494) at com.netsuite.jdbc.base.ax.a(oajc:1926) at com.netsuite.jdbc.base.fv.getTimestamp(oajc:5211) at org.apache.spark.sql.execution.datasources.jdbc.JdbcUtils$.$anonfun$makeGetter$15(JdbcUtils.scala:521) at org.apache.spark.sql.execution.datasources.jdbc.JdbcUtils$.$anonfun$makeGetter$15$adapted(JdbcUtils.scala:520) at org.apache.spark.sql.execution.datasources.jdbc.JdbcUtils$$anon$1.getNext(JdbcUtils.scala:385) at org.apache.spark.sql.execution.datasources.jdbc.JdbcUtils$$anon$1.getNext(JdbcUtils.scala:366) at&amp;nbsp; scala.collection.Iterator$$anon$10.hasNext(Iterator.scala:460) at scala.collection.convert.Wrappers$IteratorWrapper.hasNext(Wrappers.scala:32) at com.google.common.collect.Iterators$PeekingImpl.hasNext(Iterators.java:1139) at com.databricks.photon.NativeRowBatchIterator.hasNext(NativeRowBatchIterator.java:44) at 0xc7c5392 &amp;lt;photon&amp;gt;.HasNext(external/workspace_spark_3_5/photon/jni-wrappers/jni-row-batch-iterator.cc:50)&lt;/SPAN&gt;&lt;/P&gt;&lt;DIV class=""&gt;&lt;SPAN class=""&gt;-&amp;gt; 90&lt;/SPAN&gt; &lt;SPAN class=""&gt;raise&lt;/SPAN&gt; e&lt;/DIV&gt;&lt;DIV class=""&gt;File &lt;SPAN class=""&gt;&amp;nbsp;line 74&lt;/SPAN&gt; &lt;SPAN&gt;66&lt;/SPAN&gt; &lt;SPAN&gt;print&lt;/SPAN&gt;(&lt;SPAN&gt;f&lt;/SPAN&gt;&lt;SPAN&gt;"&lt;/SPAN&gt;&lt;SPAN class=""&gt;\n&lt;/SPAN&gt;&lt;SPAN&gt;Attempting to write data to CSV at: &lt;/SPAN&gt;&lt;SPAN class=""&gt;{&lt;/SPAN&gt;output_path_csv&lt;SPAN class=""&gt;}&lt;/SPAN&gt;&lt;SPAN&gt;"&lt;/SPAN&gt;) &lt;SPAN&gt;67&lt;/SPAN&gt; &lt;SPAN&gt;# df_cleaned = df.na.fill('')&lt;/SPAN&gt; &lt;SPAN&gt;68&lt;/SPAN&gt; &lt;SPAN&gt;# print('cleaned the df')&lt;/SPAN&gt; &lt;SPAN&gt;70&lt;/SPAN&gt; df&lt;SPAN&gt;.&lt;/SPAN&gt;write \ &lt;SPAN&gt;71&lt;/SPAN&gt; &lt;SPAN&gt;.&lt;/SPAN&gt;format(&lt;SPAN&gt;"&lt;/SPAN&gt;&lt;SPAN&gt;csv&lt;/SPAN&gt;&lt;SPAN&gt;"&lt;/SPAN&gt;) \ &lt;SPAN&gt;72&lt;/SPAN&gt; &lt;SPAN&gt;.&lt;/SPAN&gt;option(&lt;SPAN&gt;"&lt;/SPAN&gt;&lt;SPAN&gt;header&lt;/SPAN&gt;&lt;SPAN&gt;"&lt;/SPAN&gt;, &lt;SPAN&gt;"&lt;/SPAN&gt;&lt;SPAN&gt;true&lt;/SPAN&gt;&lt;SPAN&gt;"&lt;/SPAN&gt;) \ &lt;SPAN&gt;73&lt;/SPAN&gt; &lt;SPAN&gt;.&lt;/SPAN&gt;mode(&lt;SPAN&gt;"&lt;/SPAN&gt;&lt;SPAN&gt;overwrite&lt;/SPAN&gt;&lt;SPAN&gt;"&lt;/SPAN&gt;) \ &lt;SPAN class=""&gt;---&amp;gt; 74&lt;/SPAN&gt; &lt;SPAN&gt;.&lt;/SPAN&gt;save(output_path_csv) &lt;SPAN&gt;76&lt;/SPAN&gt; &lt;SPAN&gt;print&lt;/SPAN&gt;(&lt;SPAN&gt;f&lt;/SPAN&gt;&lt;SPAN&gt;"&lt;/SPAN&gt;&lt;SPAN&gt;SUCCESS: Wrote data to CSV.&lt;/SPAN&gt;&lt;SPAN&gt;"&lt;/SPAN&gt;) &lt;SPAN&gt;78&lt;/SPAN&gt; &lt;SPAN&gt;# # --- Write to Delta Table ---&lt;/SPAN&gt; &lt;SPAN&gt;79&lt;/SPAN&gt; &lt;SPAN&gt;# print(f"\nAttempting to write data to Delta table at: {output_path_delta}")&lt;/SPAN&gt; &lt;SPAN&gt;80&lt;/SPAN&gt; &lt;SPAN&gt;# df.write \&lt;/SPAN&gt; &lt;SPAN class=""&gt;(...)&lt;/SPAN&gt; &lt;SPAN&gt;83&lt;/SPAN&gt; &lt;SPAN&gt;# .save(output_path_delta)&lt;/SPAN&gt; &lt;SPAN&gt;84&lt;/SPAN&gt; &lt;SPAN&gt;# print(f"SUCCESS: Wrote data to Delta table.")&lt;/SPAN&gt;&lt;/DIV&gt;</description>
    <pubDate>Thu, 10 Jul 2025 09:06:59 GMT</pubDate>
    <dc:creator>KristiLogos</dc:creator>
    <dc:date>2025-07-10T09:06:59Z</dc:date>
    <item>
      <title>Spark read /write jdbc netsuite TIMESTAMP error NullPointerException</title>
      <link>https://community.databricks.com/t5/data-engineering/spark-read-write-jdbc-netsuite-timestamp-error/m-p/124771#M47262</link>
      <description>&lt;P&gt;I've connected to Netsuite via Suite Analytics JDBC connection in a Databricks cluster. I'm seeing a NullPointerException because of the lastmodifieddate column in my netsuite classification table (ie. if I do Select * from classification I see the NullPointerException and I've narrowed it down to seeing this issue because of the&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;except Exception as e:&lt;BR /&gt;print("\nERROR: An exception occurred.")&lt;BR /&gt;# The full error will be raised, giving you the complete stack trace.&lt;BR /&gt;raise e&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Error&lt;/P&gt;&lt;P&gt;&lt;SPAN class=""&gt;SparkException: &lt;/SPAN&gt;&lt;SPAN&gt;Job aborted due to stage failure: Task 0 in stage 31.0 failed 4 times, most recent failure: Lost task 0.3 in stage 31.0 (TID 44) (10.21.40.199 executor 0): java.lang.NullPointerException at com.netsuite.jdbc.base.hk.a(oajc:654) at com.netsuite.jdbc.base.dj.c(oajc:494) at com.netsuite.jdbc.base.ax.a(oajc:1926) at com.netsuite.jdbc.base.fv.getTimestamp(oajc:5211) at org.apache.spark.sql.execution.datasources.jdbc.JdbcUtils$.$anonfun$makeGetter$15(JdbcUtils.scala:521) at org.apache.spark.sql.execution.datasources.jdbc.JdbcUtils$.$anonfun$makeGetter$15$adapted(JdbcUtils.scala:520) at org.apache.spark.sql.execution.datasources.jdbc.JdbcUtils$$anon$1.getNext(JdbcUtils.scala:385) at org.apache.spark.sql.execution.datasources.jdbc.JdbcUtils$$anon$1.getNext(JdbcUtils.scala:366) at&amp;nbsp; scala.collection.Iterator$$anon$10.hasNext(Iterator.scala:460) at scala.collection.convert.Wrappers$IteratorWrapper.hasNext(Wrappers.scala:32) at com.google.common.collect.Iterators$PeekingImpl.hasNext(Iterators.java:1139) at com.databricks.photon.NativeRowBatchIterator.hasNext(NativeRowBatchIterator.java:44) at 0xc7c5392 &amp;lt;photon&amp;gt;.HasNext(external/workspace_spark_3_5/photon/jni-wrappers/jni-row-batch-iterator.cc:50)&lt;/SPAN&gt;&lt;/P&gt;&lt;DIV class=""&gt;&lt;SPAN class=""&gt;-&amp;gt; 90&lt;/SPAN&gt; &lt;SPAN class=""&gt;raise&lt;/SPAN&gt; e&lt;/DIV&gt;&lt;DIV class=""&gt;File &lt;SPAN class=""&gt;&amp;nbsp;line 74&lt;/SPAN&gt; &lt;SPAN&gt;66&lt;/SPAN&gt; &lt;SPAN&gt;print&lt;/SPAN&gt;(&lt;SPAN&gt;f&lt;/SPAN&gt;&lt;SPAN&gt;"&lt;/SPAN&gt;&lt;SPAN class=""&gt;\n&lt;/SPAN&gt;&lt;SPAN&gt;Attempting to write data to CSV at: &lt;/SPAN&gt;&lt;SPAN class=""&gt;{&lt;/SPAN&gt;output_path_csv&lt;SPAN class=""&gt;}&lt;/SPAN&gt;&lt;SPAN&gt;"&lt;/SPAN&gt;) &lt;SPAN&gt;67&lt;/SPAN&gt; &lt;SPAN&gt;# df_cleaned = df.na.fill('')&lt;/SPAN&gt; &lt;SPAN&gt;68&lt;/SPAN&gt; &lt;SPAN&gt;# print('cleaned the df')&lt;/SPAN&gt; &lt;SPAN&gt;70&lt;/SPAN&gt; df&lt;SPAN&gt;.&lt;/SPAN&gt;write \ &lt;SPAN&gt;71&lt;/SPAN&gt; &lt;SPAN&gt;.&lt;/SPAN&gt;format(&lt;SPAN&gt;"&lt;/SPAN&gt;&lt;SPAN&gt;csv&lt;/SPAN&gt;&lt;SPAN&gt;"&lt;/SPAN&gt;) \ &lt;SPAN&gt;72&lt;/SPAN&gt; &lt;SPAN&gt;.&lt;/SPAN&gt;option(&lt;SPAN&gt;"&lt;/SPAN&gt;&lt;SPAN&gt;header&lt;/SPAN&gt;&lt;SPAN&gt;"&lt;/SPAN&gt;, &lt;SPAN&gt;"&lt;/SPAN&gt;&lt;SPAN&gt;true&lt;/SPAN&gt;&lt;SPAN&gt;"&lt;/SPAN&gt;) \ &lt;SPAN&gt;73&lt;/SPAN&gt; &lt;SPAN&gt;.&lt;/SPAN&gt;mode(&lt;SPAN&gt;"&lt;/SPAN&gt;&lt;SPAN&gt;overwrite&lt;/SPAN&gt;&lt;SPAN&gt;"&lt;/SPAN&gt;) \ &lt;SPAN class=""&gt;---&amp;gt; 74&lt;/SPAN&gt; &lt;SPAN&gt;.&lt;/SPAN&gt;save(output_path_csv) &lt;SPAN&gt;76&lt;/SPAN&gt; &lt;SPAN&gt;print&lt;/SPAN&gt;(&lt;SPAN&gt;f&lt;/SPAN&gt;&lt;SPAN&gt;"&lt;/SPAN&gt;&lt;SPAN&gt;SUCCESS: Wrote data to CSV.&lt;/SPAN&gt;&lt;SPAN&gt;"&lt;/SPAN&gt;) &lt;SPAN&gt;78&lt;/SPAN&gt; &lt;SPAN&gt;# # --- Write to Delta Table ---&lt;/SPAN&gt; &lt;SPAN&gt;79&lt;/SPAN&gt; &lt;SPAN&gt;# print(f"\nAttempting to write data to Delta table at: {output_path_delta}")&lt;/SPAN&gt; &lt;SPAN&gt;80&lt;/SPAN&gt; &lt;SPAN&gt;# df.write \&lt;/SPAN&gt; &lt;SPAN class=""&gt;(...)&lt;/SPAN&gt; &lt;SPAN&gt;83&lt;/SPAN&gt; &lt;SPAN&gt;# .save(output_path_delta)&lt;/SPAN&gt; &lt;SPAN&gt;84&lt;/SPAN&gt; &lt;SPAN&gt;# print(f"SUCCESS: Wrote data to Delta table.")&lt;/SPAN&gt;&lt;/DIV&gt;</description>
      <pubDate>Thu, 10 Jul 2025 09:06:59 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/spark-read-write-jdbc-netsuite-timestamp-error/m-p/124771#M47262</guid>
      <dc:creator>KristiLogos</dc:creator>
      <dc:date>2025-07-10T09:06:59Z</dc:date>
    </item>
    <item>
      <title>Re: Spark read /write jdbc netsuite TIMESTAMP error NullPointerException</title>
      <link>https://community.databricks.com/t5/data-engineering/spark-read-write-jdbc-netsuite-timestamp-error/m-p/124776#M47263</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.databricks.com/t5/user/viewprofilepage/user-id/122107"&gt;@KristiLogos&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;&lt;P&gt;Could you check if you have null values in&amp;nbsp;lastmodifieddate? If so, try to replace null values with some fallback value:&lt;/P&gt;&lt;LI-CODE lang="python"&gt;COALESCE(lastmodifieddate, '1900-01-01 00:00:00') as lastmodifieddate&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 10 Jul 2025 10:21:16 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/spark-read-write-jdbc-netsuite-timestamp-error/m-p/124776#M47263</guid>
      <dc:creator>szymon_dybczak</dc:creator>
      <dc:date>2025-07-10T10:21:16Z</dc:date>
    </item>
    <item>
      <title>Re: Spark read /write jdbc netsuite TIMESTAMP error NullPointerException</title>
      <link>https://community.databricks.com/t5/data-engineering/spark-read-write-jdbc-netsuite-timestamp-error/m-p/124793#M47267</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.databricks.com/t5/user/viewprofilepage/user-id/110502"&gt;@szymon_dybczak&lt;/a&gt;&lt;/P&gt;&lt;P&gt;I'm not sure why my question looks like this, I thought I fixed it.&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;I've connected to Netsuite via Suite Analytics JDBC connection in a Databricks cluster. I'm seeing a NullPointerException because of the lastmodifieddate column in my netsuite classification table (ie. if I do Select * from classification I see the NullPointerException and I've narrowed it down to seeing this issue because of the lastmodifieddate TIMESTAMP column), I noticed the error was occuring at this column after writing out each column in the select statement.&lt;BR /&gt;I"ve tested with other tables as well (entity, department…), and this seems to be happening with all TIMESTAMP columns not just lastmodifieddate.&lt;/P&gt;&lt;P&gt;Also , that when I query the classification table in dbeaver I see NO null rows and I see no errors when using the below test queries. If I add coalesce or cast or etc. to lastmodifieddate field I see the "failed to retrieve data" error below:&lt;/P&gt;&lt;P&gt;(Note I have some test code commented out )&lt;/P&gt;&lt;P&gt;This is my code:&lt;/P&gt;&lt;P&gt;jdbc_url = "jdbc:ns://x.connect.api.netsuite.com:1708;ServerDataSource=NetSuite2.com;Encrypted=1;NegotiateSSLClose=false;CustomProperties=(AccountID=x;RoleID=1030)"&lt;BR /&gt;driver = "com.netsuite.jdbc.openaccess.OpenAccessDriver"&lt;/P&gt;&lt;P&gt;secret_scope = "fl-da-kv-app-scope"&lt;BR /&gt;secret_key_password = "netsuite-password"&lt;/P&gt;&lt;P&gt;user = "user"&lt;BR /&gt;password = dbutils.secrets.get(scope=secret_scope, key=secret_key_password)&lt;/P&gt;&lt;P&gt;netsuite_query = """&lt;BR /&gt;SELECT&lt;BR /&gt;lastmodifieddate&lt;BR /&gt;# CAST(lastmodifieddate AS VARCHAR(255)) AS lastmodifieddate_str&lt;BR /&gt;# COALESCE(lastmodifieddate, TO_DATE('1900-01-01 00:00:00', 'YYYY-MM-DD HH24:MI:SS')) AS lastmodifieddate&lt;BR /&gt;FROM "Fl - Accountant".classification&lt;BR /&gt;"""&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;# netsuite_query = """&lt;BR /&gt;# SELECT&lt;BR /&gt;# custrecord_nspbcs_class_planning_cat,&lt;BR /&gt;# custrecord_lmry_class_code,&lt;BR /&gt;# externalid,&lt;BR /&gt;# fullname,&lt;BR /&gt;# id,&lt;BR /&gt;# includechildren,&lt;BR /&gt;# isinactive,&lt;BR /&gt;# name,&lt;BR /&gt;# parent,&lt;BR /&gt;# subsidiary&lt;BR /&gt;# FROM "Fl - Accountant".classification&lt;BR /&gt;# """&lt;/P&gt;&lt;P&gt;# netsuite_query = """SELECT custrecord_lmry_class_code FROM "Fl- Accountant".classification"""&lt;BR /&gt;# netsuite_query = """&lt;BR /&gt;# SELECT&lt;BR /&gt;# COALESCE(custrecord_lmry_class_code, 'a') AS custrecord_lmry_class_code,&lt;BR /&gt;# COALESCE(custrecord_nspbcs_class_planning_cat, 0) AS custrecord_nspbcs_class_planning_cat,&lt;/P&gt;&lt;P&gt;# id as id&lt;/P&gt;&lt;P&gt;# FROM "Fl - Accountant".classification&lt;BR /&gt;# """&lt;/P&gt;&lt;P&gt;output_path_csv = "/tmp/netsuite_classification_full1.csv"&lt;/P&gt;&lt;P&gt;# output_path_delta = "/tmp/delta/netsuite_classification"&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;try:&lt;BR /&gt;print("Attempting to read full table from NetSuite...")&lt;BR /&gt;print(f"Executing query: {netsuite_query}")&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;df = spark.read \&lt;BR /&gt;.format("jdbc") \&lt;BR /&gt;.option("url", jdbc_url) \&lt;BR /&gt;.option("query", netsuite_query) \&lt;BR /&gt;.option("user", user) \&lt;BR /&gt;.option("password", password) \&lt;BR /&gt;.option("driver", driver) \&lt;BR /&gt;.load()&lt;/P&gt;&lt;P&gt;print("\nSUCCESS: Read data from NetSuite into a DataFrame.")&lt;/P&gt;&lt;P&gt;# if theres an error w. the count that means the query is wrong.&lt;BR /&gt;row_count = df.count()&lt;BR /&gt;print(f"SUCCESS: Read {row_count} rows from NetSuite... ")&lt;BR /&gt;# df.show(5)&lt;/P&gt;&lt;P&gt;print(f"\nAttempting to write data to CSV at: {output_path_csv}")&lt;BR /&gt;# df_cleaned = df.na.fill('')&lt;BR /&gt;# print('cleaned the df')&lt;/P&gt;&lt;P&gt;df.write \&lt;BR /&gt;.format("csv") \&lt;BR /&gt;.option("header", "true") \&lt;BR /&gt;.mode("overwrite") \&lt;BR /&gt;.save(output_path_csv)&lt;/P&gt;&lt;P&gt;print(f"SUCCESS: Wrote data to CSV.")&lt;/P&gt;&lt;P&gt;# # --- Write to Delta Table ---&lt;BR /&gt;# print(f"\nAttempting to write data to Delta table at: {output_path_delta}")&lt;BR /&gt;# df.write \&lt;BR /&gt;# .format("delta") \&lt;BR /&gt;# .mode("overwrite") \&lt;BR /&gt;# .save(output_path_delta)&lt;BR /&gt;# print(f"SUCCESS: Wrote data to Delta table.")&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;except Exception as e:&lt;BR /&gt;print("\nERROR: An exception occurred.")&lt;BR /&gt;# The full error will be raised, giving you the complete stack trace.&lt;BR /&gt;raise e&lt;/P&gt;</description>
      <pubDate>Thu, 10 Jul 2025 13:39:39 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/spark-read-write-jdbc-netsuite-timestamp-error/m-p/124793#M47267</guid>
      <dc:creator>KristiLogos</dc:creator>
      <dc:date>2025-07-10T13:39:39Z</dc:date>
    </item>
    <item>
      <title>Re: Spark read /write jdbc netsuite TIMESTAMP error NullPointerException</title>
      <link>https://community.databricks.com/t5/data-engineering/spark-read-write-jdbc-netsuite-timestamp-error/m-p/124809#M47269</link>
      <description>&lt;P&gt;Also, the TLDR of my last comment that I wrote to you includes the code I was noticing the error. I had also previously tested with coalesce and to_char() :&lt;BR /&gt;&lt;BR /&gt;COALESCE(lastmodifieddate, '1900-01-01 00:00:00') as lastmodifieddate&lt;/P&gt;&lt;P&gt;I see the error:&lt;/P&gt;&lt;P class=""&gt;java.sql.SQLException: [NetSuite][OpenAccess SDK JDBC Driver][OpenAccess SDK SQL Engine]&lt;/P&gt;&lt;P class=""&gt;Failed to retrieve data. Error ticket# mcwb7tcx1eia537oa41ma&lt;/P&gt;</description>
      <pubDate>Thu, 10 Jul 2025 15:13:32 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/spark-read-write-jdbc-netsuite-timestamp-error/m-p/124809#M47269</guid>
      <dc:creator>KristiLogos</dc:creator>
      <dc:date>2025-07-10T15:13:32Z</dc:date>
    </item>
  </channel>
</rss>

