Help Center> MapReduce Service> Component Operation Guide (Normal)> Using Spark2x> Common Issues About Spark2x> Why Does the Foreign Table Query Fail When Multiple Foreign Tables Are Created in the Same Directory?
Updated on 2022-09-22 GMT+08:00

Why Does the Foreign Table Query Fail When Multiple Foreign Tables Are Created in the Same Directory?

Question

Assume there is a data file path named /test_data_path. User A creates a foreign table named tableA for the directory, and user B creates a foreign table named tableB for the directory. When user B performs the insert operation on tableB, user A fails to query data using tableA and the error "Permission denied" is displayed.

Answer

After user B performs the insert operation on tableB, a new data file is generated in the foreign table path and the file belongs to user B. When user A queries data using tableA, all files in the foreign table directory are read. In this case, the query fails because user A does not have the read permissions on the file generated by user B.

This problem also occurs in other scenarios. For example, the inset overwrite operation will also duplicate other table files in this directory.

Due to the Spark SQL implementation mechanism, check restrictions in this scenario will lead to inconsistency and performance deterioration. Therefore, no restriction is added in this scenario, and this method is not recommended.