CREATE SERVER "file-override"
FOREIGN DATA WRAPPER file
OPTIONS(
Encoding 'ISO-8859-1', "ExceptionIfFileNotFound" false
);
CREATE SCHEMA file SERVER "file-override";
File translator
The file translator, known by the type name file, exposes stored procedures to leverage file resources.
The translator is typically used with the TEXTTABLE
or XMLTABLE
functions to consume CSV or XML formatted data.
Name | Description | Default |
---|---|---|
Encoding |
The encoding that should be used for CLOBs returned by the getTextFiles procedure. The value should match an encoding known to Teiid Spring Boot. For more information, see TO_CHARS and TO_BYTES in String functions. |
The system default encoding. |
ExceptionIfFileNotFound |
Throw an exception in getFiles or getTextFiles if the specified file/directory does not exist. |
true |
Tip
|
For information about how to set properties, see the following example, and Override execution properties in Translators. |
getFiles(String pathAndPattern) returns
TABLE(file blob, filePath string, lastModified timestamp, created timestamp, size long)
Retrieve all files as BLOBs matching the given path and pattern. The allowable path and pattern is a simplified glob syntax.
call getFiles('path/*.ext')
If the path is a directory, then all files in the directory are returned. If the path matches a single file, the file is returned.
The character is treated as a wildcard to match any number of characters in the path name. Multiple
characters may be used in the path/pattern. To escape a
character, use an additional
-
**
. Note that "globstar" recursive directory searching is not supported as double star means a literal match instead.
If no files exist at the given path/pattern and ExceptionIfFileNotFound
is true, then an exception is raised.
getTextFiles(String pathAndPattern) returns
TABLE(file clob, filePath string, lastModified timestamp, created timestamp, size long)
Note
|
The size reports the number of bytes. |
Retrieve all files as CLOBs matching the given path and pattern.
call getTextFiles('path/*.ext')
Retrieves the same files getFiles
, but with the difference that the results are CLOB values that use the encoding execution property as the character set.
Save the CLOB, BLOB, or XML value to given path
call saveFile('path', value)
Delete the file at the given path
call deleteFile('path')
The path should reference an existing file.
If the file does not exist and ExceptionIfFileNotFound
is true, then an exception will be thrown.
An exception is also thrown if the file cannot be deleted.
Note
|
Native queries
This feature is not applicable for the File translator.
|
Note
|
Direct query procedure
This feature is not applicable for the File translator.
|