最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

azure synapse - How can I return an empty result instead of error 13807 when querying a path that might not exist with OPENROWSE

programmeradmin4浏览0评论

I have a Synapse SQL Serverless query as follows

SELECT *
FROM  OPENROWSET
(
    BULK 'mytestpath/*/*',
    DATA_SOURCE = 'LocalDataLake',
    FORMAT = 'Parquet'
)
WITH(
Foo INT,
Bar INT
) X

The underlying Blob path may or may not exist/have contents depending on some external process.

If it does not contain any files the above throws an error

Content of directory on path 'mytestpath/*/*' cannot be listed.

How can I just get it to return an empty result set instead?

I have a Synapse SQL Serverless query as follows

SELECT *
FROM  OPENROWSET
(
    BULK 'mytestpath/*/*',
    DATA_SOURCE = 'LocalDataLake',
    FORMAT = 'Parquet'
)
WITH(
Foo INT,
Bar INT
) X

The underlying Blob path may or may not exist/have contents depending on some external process.

If it does not contain any files the above throws an error

Content of directory on path 'mytestpath/*/*' cannot be listed.

How can I just get it to return an empty result set instead?

Share Improve this question asked Mar 25 at 18:19 Martin SmithMartin Smith 454k96 gold badges773 silver badges875 bronze badges
Add a comment  | 

1 Answer 1

Reset to default 0

This appears to be a side effect of using the syntax described in Read subset of files in folder using multiple file paths

On adding a second dummy path (that you should be sure definitely never exist) as below

SELECT *
FROM  OPENROWSET
(
    BULK ('mydummypaththatwillneverexist/*/*', 
          'mytestpath/*/*'),
    DATA_SOURCE = 'LocalDataLake',
    FORMAT = 'Parquet'
)
WITH(
Foo INT,
Bar INT
) X

the query now no longer throws an error and returns a zero row resultset.

The 13807 messages are now shown as warnings rather than statement aborting errors.

与本文相关的文章

发布评论

评论列表(0)

  1. 暂无评论