[VL][CI] SparkRuntimeException: [LOCATION_ALREADY_EXISTS] Cannot name the managed table as xxx
- Dominant language
- Scala
- Stars
- 1.6k
- Forks
- 657
- Avg merge
- 2d 14h
- Merged PRs (30d)
- 80
Description
### Description
Just reported from CI job (run-spark-test-spark34), only occasionally produced.
```log
- Gluten - INSERT rows, ALTER TABLE ADD COLUMNS with DEFAULTs, then SELECT them *** FAILED ***
2024-03-26T04:36:45.9079299Z org.apache.spark.SparkRuntimeException: [LOCATION_ALREADY_EXISTS] Cannot name the managed table as `spark_catalog`.`default`.`t`, as its associated location 'file:/__w/incubator-gluten/incubator-gluten/gluten-ut/spark34/target/scala-2.12/test-classes/unit-tests-working-home/spark-warehouse/t' already exists. Please pick a different table name, or remove the existing location first.
2024-03-26T04:36:45.9082121Z at org.apache.spark.sql.errors.QueryExecutionErrors$.locationAlreadyExists(QueryExecutionErrors.scala:2796)
2024-03-26T04:36:45.9083265Z at org.apache.spark.sql.catalyst.catalog.SessionCatalog.validateTableLocation(SessionCatalog.scala:414)
2024-03-26T04:36:45.9084254Z at org.apache.spark.sql.catalyst.catalog.SessionCatalog.createTable(SessionCatalog.scala:400)
2024-03-26T04:36:45.9085244Z at org.apache.spark.sql.execution.command.CreateDataSourceTableCommand.run(createDataSourceTables.scala:120)
2024-03-26T04:36:45.9086319Z at org.apache.spark.sql.execution.command.ExecutedCommandExec.sideEffectResult$lzycompute(commands.scala:75)
2024-03-26T04:36:45.9087368Z at org.apache.spark.sql.execution.command.ExecutedCommandExec.sideEffectResult(commands.scala:73)
2024-03-26T04:36:45.9088332Z at org.apache.spark.sql.execution.command.ExecutedCommandExec.executeCollect(commands.scala:84)
2024-03-26T04:36:45.9089401Z at org.apache.spark.sql.execution.QueryExecution$$anonfun$eagerlyExecuteCommands$1.$anonfun$applyOrElse$1(QueryExecution.scala:98)
2024-03-26T04:36:45.9090437Z at org.apache.spark.sql.execution.SQLExecution$.$anonfun$withNewExecutionId$6(SQLExecution.scala:118)
2024-03-26T04:36:45.9091315Z at org.apache.spark.sql.execution.SQLExecution$.withSQLConfPropagated(SQLExecution.scala:195)
2024-03-26T04:36:45.9091889Z ...
2024-03-26T04:36:45.9140018Z - Gluten - SPARK-39557 INSERT INTO statements with tables with array defaults *** FAILED ***
2024-03-26T04:36:45.9142383Z org.apache.spark.SparkRuntimeException: [LOCATION_ALREADY_EXISTS] Cannot name the managed table as `spark_catalog`.`default`.`t`, as its associated location 'file:/__w/incubator-gluten/incubator-gluten/gluten-ut/spark34/target/scala-2.12/test-classes/unit-tests-working-home/spark-warehouse/t' already exists. Please pick a different table name, or remove the existing location first.
2024-03-26T04:36:45.9144529Z at org.apache.spark.sql.errors.QueryExecutionErrors$.locationAlreadyExists(QueryExecutionErrors.scala:2796)
2024-03-26T04:36:45.9145568Z at org.apache.spark.sql.catalyst.catalog.SessionCatalog.validateTableLocation(SessionCatalog.scala:414)
2024-03-26T04:36:45.9146533Z at org.apache.spark.sql.catalyst.catalog.SessionCatalog.createTable(SessionCatalog.scala:400)
2024-03-26T04:36:45.9147526Z at org.apache.spark.sql.execution.command.CreateDataSourceTableCommand.run(createDataSourceTables.scala:120)
2024-03-26T04:36:45.9148576Z at org.apache.spark.sql.execution.command.ExecutedCommandExec.sideEffectResult$lzycompute(commands.scala:75)
2024-03-26T04:36:45.9149590Z at org.apache.spark.sql.execution.command.ExecutedCommandExec.sideEffectResult(commands.scala:73)
2024-03-26T04:36:45.9150547Z at org.apache.spark.sql.execution.command.ExecutedCommandExec.executeCollect(commands.scala:84)
2024-03-26T04:36:45.9151774Z at org.apache.spark.sql.execution.QueryExecution$$anonfun$eagerlyExecuteCommands$1.$anonfun$applyOrElse$1(QueryExecution.scala:98)
2024-03-26T04:36:45.9153018Z at org.apache.spark.sql.execution.SQLExecution$.$anonfun$withNewExecutionId$6(SQLExecution.scala:118)
2024-03-26T04:36:45.9153900Z at org.apache.spark.sql.execution.SQLExecution$.withSQLConfPropagated(SQLExecution.scala:195)
```
Contributor guide
Research direction
Start by reproducing the failures in the run-spark-test-spark34 CI job, focusing on the tests named “INSERT rows, ALTER TABLE ADD COLUMNS with DEFAULTs, then SELECT them” and “SPARK-39557 INSERT INTO statements with tables with array defaults.” Read the failure stack around Spark's managed-table location validation and determine why the shared spark-warehouse/t location remains; done means these tests no longer intermittently fail in CI.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- scala, spark
- Domain
- ci-cd, testing
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100