简体   繁体   中英

Running query using serverless sql pool (built-in) on CSV file in Azure Data Lake Storage Gen2 failed

I uploaded my CSV file into my Azure Data Lake Storage Gen2 using Azure Synapse portal . Then I tried select Top 100 rows and got an error after running auto-generated SQL.
Auto-generated SQL:

SELECT
    TOP 100 *
FROM
    OPENROWSET(
        BULK 'https://accountname.dfs.core.windows.net/filesystemname/test_file/contract.csv',
        FORMAT = 'CSV',
        PARSER_VERSION='2.0'
    ) AS [result]

Error:

File 'https://accountname.dfs.core.windows.net/filesystemname/test_file/contract.csv'
cannot be opened because it does not exist or it is used by another process. 

This error in Synapse Studio has link (which leads to self-help document) underneath it which explains the error itself.

Do you have rights needed on the storage account?

You must have Storage Blob Data Contributor or Storage Blob Data Reader in order for this query to work.

Summary from the docs:

You need to have a Storage Blob Data Owner/Contributor/Reader role to use your identity to access the data. Even if you are an Owner of a Storage Account, you still need to add yourself into one of the Storage Blob Data roles.

Check out the full documentation for Control Storage account access for serverless SQL pool


If your storage account is protected with firewall rules then take a look at this stack overflow answer .

Reference full docs article .

I just took your code & updated the path to what I have and it worked just worked fine

SELECT
    TOP 100 *
FROM
    OPENROWSET(
        BULK 'https://XXX.dfs.core.windows.net/himanshu/NYCTaxi/PassengerCountStats.csv',
        FORMAT = 'CSV',
        PARSER_VERSION='2.0'
    ) AS [result]

Please check if the path to which you have uploaded the file and the one used in the script is the same. You can do this to check that Navigate to WS -> Data -> ADLS gen2 -> Go to the file -> right click go to the property and copy the Uri from there paste in the script.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM