Table of contents
TOC
Collapse the table of content
Expand the table of content

FILE.EXISTS (U-SQL)

Michael Rys|Last Updated: 5/15/2018
|
4 Contributors

Checks if a file in the specified location exists at compile time.

Syntax
bool EXISTS(
    stringpath
).                                                                                                       

Parameters

  • path
    A constant-foldable string expression. path can be any supported file path Universal Resource Identifier (URI). If path is not constant-foldable, the error E_CSC_USER_EXPRESSIONNOTCONSTANTFOLDABLE is raised. If path is empty (null or the zero-length string), the error E_CSC_USER_EMPTYFILEPATH is raised. If path contains invalid characters, the error E_CSC_USER_INVALIDFILENAME is raised.

Return Value

bool
True if path exists and the user has access to it. False if path does not exists, refers to a folder or the user has no access to it.

Example

DECLARE @filepath_good = "/Samples/Data/SearchLog.tsv";
DECLARE @filepath_bad = "/Samples/Data/zzz.tsv";

@result =
    SELECT  FILE.EXISTS(@filepath_good) AS exists_good,
            FILE.EXISTS(@filepath_bad) AS exists_bad
    FROM (VALUES (1)) AS T(dummy);

OUTPUT @result
TO "/Output/ReferenceGuide/BuiltInFunctions/SystemFunctions/FileExists.txt"
USING Outputters.Csv();

See Also

© 2018 Microsoft