AnuragKDwivedi opened a new pull request, #56356:
URL: https://github.com/apache/spark/pull/56356

   **PR Description**
   What changes were proposed in this pull request?
   This PR updates database location validation to reject whitespace-only 
location values during namespace/database creation and location alteration.
   
   Currently Spark rejects only empty string locations:
   `CREATE DATABASE db LOCATION ''`
   with:
   `INVALID_EMPTY_LOCATION`
   
   However, whitespace-only values such as:
   
   ```
   CREATE DATABASE db LOCATION ' '
   CREATE DATABASE db LOCATION '\t'
   CREATE DATABASE db LOCATION '\n'
   ```
   are not rejected by Spark validation.
   
   As a result:
   - In non-HMS catalog paths, databases may be created successfully using 
whitespace-only locations.
   - In HMS-backed catalog paths, the request reaches Hive Metastore and fails 
later with metastore-specific exceptions.
   
   This PR trims the location value before performing the empty-location 
validation so that whitespace-only values are treated consistently as empty 
locations.
   
   The validation is updated in:
   ```
   ResolveSessionCatalog
   DataSourceV2Strategy
   ```
   Additional regression tests are added for:
   ```
   ' '
   '\t'
   '\n'
   ```
   for both:
   ```
   namespace/database creation
   namespace/database location alteration
   ```
   
   By treating whitespace-only values as empty locations, Spark provides:
   - consistent validation behavior
   - consistent error reporting
   - earlier failure during analysis
   - reduced dependence on catalog-specific validation
   
   **Does this PR introduce any user-facing change?**
   Yes.
   
   The following statements will now fail consistently with:
   `INVALID_EMPTY_LOCATION`
   
   **Examples:**
   ```
   CREATE DATABASE db LOCATION ' '
   CREATE DATABASE db LOCATION '\t'
   CREATE DATABASE db LOCATION '\n'
   ```
   
   Jira - https://issues.apache.org/jira/browse/SPARK-57295


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to