Search code examples
apache-sparkamazon-emraws-glue

Tables not found in Spark SQL after migrating from EMR to AWS Glue


I have Spark jobs on EMR, and EMR is configured to use the Glue catalog for Hive and Spark metadata.

I create Hive external tables, and they appear in the Glue catalog, and my Spark jobs can reference them in Spark SQL like spark.sql("select * from hive_table ...")

Now, when I try to run the same code in a Glue job, it fails with "table not found" error. It looks like Glue jobs are not using the Glue catalog for Spark SQL the same way that Spark SQL would running in EMR.

I can work around this by using Glue APIs and registering dataframes as temp views:

create_dynamic_frame_from_catalog(...).toDF().createOrReplaceTempView(...)

but is there a way to do this automatically?


Solution

  • This was a much awaited feature request (to use Glue Data Catalog with Glue ETL jobs) which has been release recently. When you create a new job, you'll find the following option

    Use Glue data catalog as the Hive metastore

    You may also enable it for an existing job by editing the job and adding --enable-glue-datacatalog in the job parameters providing no value