Problem
When trying to read data from MongoDB in an all-purpose compute with standard (formerly shared) access mode, you receive an error message.
`org.apache.spark.SparkSecurityException: [INSUFFICIENT_PERMISSIONS] Insufficient privileges: User does not have permission SELECT on any file. SQLSTATE: 42501`.
This issue is specific to the MongoDB connector and does not occur when using a compute with dedicated access mode and the same Databricks Runtime version and package.
Cause
The use of standard access mode compute and the MongoDB connector are not governed by Unity Catalog (UC).
When using Unity Catalog-enabled standard access mode compute or SQL warehouses to access storage paths or data sources not governed by UC, it invokes an evaluation of privileges on the `ANY FILE`
securable.
You do not have privileges on the `ANY FILE`
securable, resulting in the error message.
Solution
Use Lakehouse Federation to access external data sources, which does not require privileges on the `ANY FILE`
securable. For more information, review the What is Lakehouse Federation? (AWS | Azure | GCP) documentation.
If Lakehouse Federation is not an option, use a dedicated access mode compute instead of standard access mode.
To prevent similar issues in the future, ensure that the necessary privileges are granted when using custom data sources or JDBC drivers not included in Lakehouse Federation.