Consuming data from databricks[Hive metastore] sql endpoint using pyspark
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-25-2023 02:57 AM
I was trying to read some delta data from databricks[Hive metastore] sql endpoint using pyspark, but while doing so I encountered that all the values of the table after fetching are same as the column name.
Even when I try to just show the data it gives me error if the column type is not string.
Error :
org.apache.spark.SparkException: Job aborted due to stage failure: Task 0 in stage 13.0 failed 4 times, most recent failure: Lost task 0.3 in stage 13.0 (TID 34) (10.139.64.4 executor driver): java.sql.SQLDataException: [Databricks][JDBC](10140) Error converting value to BigDecimal.
jdbc_url = "jdbc:databricks://XXXX:443/default;transportMode=http;ssl=1;httpPath=xxxx;password=<pat token>"
table_name = "xxxx"
df = spark.read.format("jdbc") \
.option("url", jdbc_url) \
.option("dbtable", table_name) \
.option("driver", "com.databricks.client.jdbc.Driver") \
.load()
df.printSchema()
>>>>>> Output>>>>>>
root
|-- Description: string (nullable = true)
|-- Volume: double (nullable = true)
df.show()
>>>>>> Output>>>>>>
org.apache.spark.SparkException: Job aborted due to stage failure: Task 0 in stage 0.0 failed 4 times, most recent failure: Lost task 0.3 in stage 0.0 (TID 3) (10.139.64.4 executor driver): java.sql.SQLDataException: [Databricks][JDBC](10140) Error converting value to double.
df.select('Description').show(10, False)
>>>>>> Output>>>>>>
+-----------+
|Description|
+-----------+
|Description|
|Description|
|Description|
|Description|
|Description|
|Description|
|Description|
|Description|
|Description|
|Description|
+-----------+
only showing top 10 rows
Note: Everythin works file if i use "sql.connect" and consume the data using "cursor".
But while trying with spark JDBC conn, i am facing this issue. Can someone help me here?
- Labels:
-
Data
-
SQL
-
SQL Endpoint