Sudhanva Huruli created SPARK-62202:
---------------------------------------
Summary: spark-pipelines fails with PARSE_EMPTY_STATEMENT when the
spec has no database and the catalog has no current database
Key: SPARK-62202
URL: https://issues.apache.org/jira/browse/SPARK-62202
Project: Spark
Issue Type: Bug
Components: Declarative Pipelines
Affects Versions: 4.2.1
Reporter: Sudhanva Huruli
When a pipeline spec does not set `database`, the Connect server falls back to
the session's current database (PipelinesHandler.createDataflowGraph). If the
current catalog has no current database, the fallback is an empty string, and
Catalog.setCurrentDatabase("") fails while parsing it. The user sees a parse
error that names neither the catalog nor the spec field to set:
pyspark.errors.exceptions.connect.ParseException: [PARSE_EMPTY_STATEMENT]
Syntax error, unexpected empty statement. SQLSTATE: 42617 (line 1, pos 0)
A catalog has no current database when it is a v2 catalog that keeps the
default CatalogPlugin.defaultNamespace(), which is empty, and the session has
not selected a namespace. This is the state of a new session when such a
catalog is spark.sql.defaultCatalog. The session catalog always has a current
database, so it is not affected.
Steps (master; InMemoryCatalog is the test catalog in sql/catalyst and stands
in for any connector that does not override defaultNamespace):
sbin/start-connect-server.sh --driver-class-path
sql/catalyst/target/scala-2.13/test-classes --conf
spark.sql.catalog.testcat=org.apache.spark.sql.connector.catalog.InMemoryCatalog
--conf spark.sql.defaultCatalog=testcat
spark-pipelines init --name p1
cd p1
spark-pipelines dry-run --remote sc://localhost:15002
Expected: the run resolves a default database, or fails with an error that
names the catalog and says to set `database` in the pipeline spec. Actual:
PARSE_EMPTY_STATEMENT, as above. Adding `database: <name>` to
spark-pipeline.yml works around it.
Two related points in the same function:
- The current database is read before the session switches to the spec's
`catalog`. A spec that sets `catalog` and not `database` therefore looks up the
previous catalog's current database in the new catalog, which usually fails
with SCHEMA_NOT_FOUND.
- An explicitly empty default database in the command reaches the same
setCurrentDatabase("") call.
Not covered by this report, and possible follow-ups: Catalog.currentDatabase
returns the quoted namespace, and the handler passes that string back to
setCurrentDatabase, so a database whose name needs quoting does not round-trip;
and when a command fails after setting a database on a catalog that had none,
the session keeps that database.
--
This message was sent by Atlassian Jira
(v10.3.26#10030026)
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]