[Python] Connecting to Suite Analytics JDBC for Netsuite using PySpark. Seeing error...

Discussão em 'Python' iniciado por Stack, Julho 8, 2025.

  1. Stack

    Stack Membro Participativo

    I'm confused why this works for the oa_tables...

    jdbc_url = "jdbc:ns://xxx.connect.api.netsuite.com:1708;ServerDataSource=NetSuite2.com;Encrypted=1;NegotiateSSLClose=false;CustomProperties=(AccountID=xxx;RoleID=xxx)"
    driver = "com.netsuite.jdbc.openaccess.OpenAccessDriver"


    netsuite_query = "SELECT * FROM OA_TABLES"

    output_path = "/tmp/netsuite_all_tables_chained"

    try:
    print(f" query and writing directly to CSV...... {output_path}")


    spark.read \
    .format("jdbc") \
    .option("url", jdbc_url) \
    .option("dbtable", "OA_TABLES") \
    .option("user", "analytx) \
    .option("password", "xxxx") \
    .option("driver", driver) \
    .load() \
    .write \
    .format("csv") \
    .option("header", "true") \
    .mode("overwrite") \
    .save(output_path)

    print(f"SUCCESS {output_path}")

    except Exception as e:
    print(f"ugh doesnt work ")

    raise e


    But when I try with the classification table I see the NullPointer error:

    jdbc_url = "jdbc:ns://xxx.connect.api.netsuite.com:1708;ServerDataSource=NetSuite2.com;Encrypted=1;NegotiateSSLClose=false;CustomProperties=(AccountID=xxx;RoleID=xx)"
    driver = "com.netsuite.jdbc.openaccess.OpenAccessDriver"


    netsuite_table_to_read = '"Fl - Accountant".classification'

    output_path = "/tmp/netsuite_all_tables_chained"

    try:
    print(f" query and writing directly to CSV...... {output_path}")


    spark.read \
    .format("jdbc") \
    .option("url", jdbc_url) \
    .option("dbtable", netsuite_table_to_read ) \
    .option("user", "xxxx") \
    .option("password", "xxx") \
    .option("driver", driver) \
    .load() \
    .write \
    .format("csv") \
    .option("header", "true") \
    .mode("overwrite") \
    .save(output_path)

    print(f"SUCCESS yo{output_path}")

    except Exception as e:
    print(f"ugh doesnt work ")

    raise e


    I see this error for the 2nd block of code:

    SparkException: Job aborted due to stage failure: Task 0 in stage 20.0 failed 4 times, most recent failure:
    Lost task 0.3 in stage 20.0 (TID 68) (10.21.40.196 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 org.apache.spark.util.NextIterator.hasNext(NextIterator.scala:73) at org.apache.spark.InterruptibleIterator.hasNext(InterruptibleIterator.scala:37)
    at org.apache.spark.util.CompletionIterator.hasNext(CompletionIterator.scala:31)
    at org.apache.spark.sql.catalyst.expressions.GeneratedClass$GeneratedIteratorForCodegenStage1.processNext(Unknown Source)
    at org.apache.spark.sql.execution.BufferedRowIterator.hasNext(BufferedRowIterator.java:43)
    at org.apache.spark.sql.execution.WholeStageCodegenEvaluatorFactory$WholeStageCodegenPartitionEvaluator$$anon$1.hasNext(WholeStageCodegenEvaluatorFactory.scala:50)
    at 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 <photon>.HasNext(external/workspace_spark_3_5/photon/jni-wrappers/jni-row-batch-iterator.cc:50)
    at com.databricks.photon.JniApiImpl.hasNext(Native Method)
    at com.databricks.photon.JniApi.hasNext(JniApi.scala)
    at com.databricks.photon.JniExecNode.hasNext(JniExecNode.java:79)
    at com.databricks.photon.BasePh... File <command-7917885491786650>, line 35
    32 except Exception as e:
    33 print(f"fffffff ")
    ---> 35 raise e File <command-7917885491786650>, line 28
    13 print(f" query and writing directly to CSV...... {output_path}")
    15 netsuite_table_to_read = '"Fl - Accountant".classification'
    16 spark.read \
    17 .format("jdbc") \
    18 .option("url", jdbc_url) \
    19 .option("dbtable", netsuite_table_to_read) \
    20 .option("user", "xxxxx") \
    21 .option("password", "[REDACTED]") \
    22 .option("driver", driver) \
    23 .load() \
    24 .write \
    25 .format("csv") \
    26 .option("header", "true") \
    27 .mode("overwrite") \
    ---> 28 .save(output_path)
    30 print(f"SUCCESS yo{output_path}")
    32 except Exception as e:

    Continue reading...

Compartilhe esta Página