Class ToFile
java.lang.Object
dev.frostlake.functions.BuiltInFunction
dev.frostlake.functions.scalar.file.ToFile
TO_FILE(stage_and_path) / TO_FILE(stage, relative_path) / TO_FILE(metadata) —
builds the file-metadata object that is a FILE value.
Live-verified:
- The stage-path form RESOLVES AND VALIDATES:
TO_FILE('@sse/hello.txt')returns the descriptor read from the real file, andTO_FILE('@sse/missing.txt')fails "Remote file '@sse/missing.txt' was not found. …".TRY_TO_FILEreturning NULL there is the ONLY difference between the two functions. - The two-argument form is a plain join:
TO_FILE('@sse', '/hello.txt')fails naming'@sse//hello.txt', andTO_FILE('sse', 'hello.txt')fails naming'sse/hello.txt'— no@is added and no separator is collapsed. - A directory is not a file:
TO_FILE('@sse/sub')andTO_FILE('@sse/')both fail "was not found". - User and table stages resolve too —
TO_FILE('@~/p135/hello.txt')andTO_FILE('@%tstg/hello.txt')both return descriptors. - NULL in, NULL out, for both functions and with no error.
- The metadata-object form validates structure but NOT existence, so it is the one way to build a FILE value for a file that is not there.
The engine registers this twice: once from FunctionRegistry with no locator (so the name
resolves and SHOW FUNCTIONS lists it) and again from QueryExecutor with a locator
that can reach stages — the same two-step GET_DDL uses.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic VariantValueconvert(List<Object> args, StageFileLocator locator, boolean tryMode) The shared body ofTO_FILEandTRY_TO_FILE.Computes the function's result over its already-evaluated argument values.intThe most arguments a call to this function may pass;Integer.MAX_VALUEmarks a variadic function (seeBuiltInFunction.isVariadic()).intThe fewest arguments a call to this function may pass; fewer is an argument-count error.Methods inherited from class dev.frostlake.functions.BuiltInFunction
approximateRejection, binaryRejection, booleanRejection, evaluate, fileRejection, geoRejection, getName, getReturnType, isVariadic, refusesMissingArgumentsByType, semiStructuredRejection, structuredRejection, temporalRejection, temporalRejection, temporalRejection, textRejection, uuidRejection, vectorRejection
-
Constructor Details
-
ToFile
public ToFile() -
ToFile
-
-
Method Details
-
convert
The shared body ofTO_FILEandTRY_TO_FILE.- Parameters:
args- the call arguments (one location/metadata, or a stage and a relative path)locator- resolves a stage reference to a real filetryMode- true forTRY_TO_FILE: every failure becomes NULL- Returns:
- the FILE descriptor, or null
-
evaluate
Description copied from class:BuiltInFunctionComputes the function's result over its already-evaluated argument values. A SQL NULL argument arrives as Javanull, and returningnullmakes the SQL result NULL.- Specified by:
evaluatein classBuiltInFunction- Parameters:
args- the argument values, in call order- Returns:
- the function's value for these arguments, or
nullfor SQL NULL
-
getMinArgCount
public int getMinArgCount()Description copied from class:BuiltInFunctionThe fewest arguments a call to this function may pass; fewer is an argument-count error.- Specified by:
getMinArgCountin classBuiltInFunction- Returns:
- the minimum accepted argument count
-
getMaxArgCount
public int getMaxArgCount()Description copied from class:BuiltInFunctionThe most arguments a call to this function may pass;Integer.MAX_VALUEmarks a variadic function (seeBuiltInFunction.isVariadic()).- Specified by:
getMaxArgCountin classBuiltInFunction- Returns:
- the maximum accepted argument count
-