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. 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. |
VDB XML Override Example
<model name="file">
<source name="file" translator-name="file-override" connection-jndi-name="java:/file"/>
</model>
<translator name="file-override" type="file">
<property name="Encoding" value="ISO-8859-1"/>
<property name="ExceptionIfFileNotFound" value="false"/>
</translator>
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.
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. Zero or matching files will be returned.
If *’ is not used, and if the path doesn’t exist 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.
For configuration information, see File Data Source, the FTP Data Source, the HDFS Data Source, the S3 Data Source, and the Administrator’s Guide in general.
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.
|