aws-glue-data-catalog-client-for-apache-hive-metastore: Not able to query glue/Athena views ['java.lang.IllegalArgumentException: Can not create a Path from an empty string;']
I’m running EMR cluster with the ‘AWS Glue Data Catalog as the Metastore for Hive’ option enable. Connecting through a Spark Notebook working fine e.g
spark.sql("show databases")
spark.catalog.setCurrentDatabase(<databasename>)
spark.sql("""select * from <table> limit 10""").show()
All working as expected but when querying a view got the following error:
spark.sql("""select * from <view> limit 10""").show()
An error was encountered:
'java.lang.IllegalArgumentException: Can not create a Path from an empty string;'
Traceback (most recent call last):
File "/usr/lib/spark/python/lib/pyspark.zip/pyspark/sql/session.py", line 767, in sql
return DataFrame(self._jsparkSession.sql(sqlQuery), self._wrapped)
File "/usr/lib/spark/python/lib/py4j-0.10.7-src.zip/py4j/java_gateway.py", line 1257, in __call__
answer, self.gateway_client, self.target_id, self.name)
File "/usr/lib/spark/python/lib/pyspark.zip/pyspark/sql/utils.py", line 69, in deco
raise AnalysisException(s.split(': ', 1)[1], stackTrace)
pyspark.sql.utils.AnalysisException: 'java.lang.IllegalArgumentException: Can not create a Path from an empty string;'
I guess since views are not stored I somewhere have to specify a temp path but cannot find out how?
About this issue
- Original URL
- State: open
- Created 4 years ago
- Reactions: 6
- Comments: 19
So here is my generic workaround. Keep in mind that the query has to be Both Spark and Presto compatible. I suggest to keep the SQL query of the Views as simple as possible. How it works:
I found a solution for this problem! Is possible to query Athena views by using jdbc connection thorugh spark_read_jdbc with appropriate options and configurations
For me the same issue happened, when I created a View in Athena, then tried to query it in a Glue Job via Spark. The Issue I think is that Glue Catalog is handling views in a special way. They are Table, just without PATH to a real location (on s3 or alternatives). I couldn’t find a workaround so far.
Hi @kironp, sorry for not replying sooner. Our delta table use is not a workaround, it’s our main approach for working with tables.
Our method is similar to what you said you already tried. We don’t consume Athena views from spark at all. We use the same glue catalog and create 2 table definitions and views - one for delta ( https://github.com/delta-io/delta ) and one for Athena.
Both definitions are configured to use the same path by generating an Athena table from the delta manifest ( https://docs.delta.io/0.7.0/presto-integration.html )
I may be late to the party, but I hope this may help someone who runs into one of those cryptic errors ( we encountered this during table creation when location was not defined properly in the catalog )
https://docs.databricks.com/data/metastores/aws-glue-metastore.html#troubleshooting
Personally we create a delta table over the same path for spark/spark sql and use Athena for generic querying to circumvent this.