delta icon indicating copy to clipboard operation
delta copied to clipboard

invoke Spark catalog plugin API to create tables

Open cloud-fan opened this issue 1 year ago • 7 comments

Which Delta project/connector is this regarding?

  • [x] Spark
  • [ ] Standalone
  • [ ] Flink
  • [ ] Kernel
  • [ ] Other (fill in here)

Description

Today, DeltaCatalog takes care of the Spark CREATE TABLE command and calls CreateDeltaTableCommand#run at the end. Within this command, spark.sessionState.catalog.createTable is called, which bypasses any custom catalog that overwrites spark_catalog. DeltaCatalog always creates tables in the Hive Metastore.

This PR fixes this issue by calling the Spark catalog plugin API to create the table, to respect custom catalog that overwrites spark_catalog, such as Unity Catalog.

How was this patch tested?

Locally tested it with Spark + Unity Catalog.

Does this PR introduce any user-facing changes?

no

cloud-fan avatar Aug 07 '24 13:08 cloud-fan

cc @tdas

cloud-fan avatar Aug 09 '24 03:08 cloud-fan

Option.when is available after Scala 2.13

cloud-fan avatar Aug 16 '24 02:08 cloud-fan

Option.when is available after Scala 2.13

It's also available in 2.12 by importing the compat shim in https://github.com/delta-io/delta/blob/master/spark/src/main/scala/org/apache/spark/sql/util/ScalaExtensions.scala#L36

scovich avatar Aug 19 '24 20:08 scovich

spark master failures seems un related.

tdas avatar Aug 22 '24 22:08 tdas

The master branch failure seems to be caused by the recent Spark refactors for Spark Connect. cc @hvanhovell

cloud-fan avatar Aug 22 '24 23:08 cloud-fan

There seems to be other spark test failures.

tdas avatar Aug 23 '24 03:08 tdas

@cloud-fan can you fix them?

tdas avatar Aug 23 '24 03:08 tdas

merged. can you make a PR for branch 3.2?

tdas avatar Aug 26 '24 00:08 tdas

the 3.2 PR: https://github.com/delta-io/delta/pull/3603

cloud-fan avatar Aug 26 '24 11:08 cloud-fan