FDELIMITEDPARSER
Parses data using a delimiter character to separate values. The fdelimitedparser loads delimited data, storing it in a single-value VMap. You can use this parser to load data into columnar and flex tables.
Note
By default,fdelimitedparser treats empty fields as NULL, rather than as an empty string (''). This behavior makes casting easier. Casting a NULL to an integer (NULL::int) is valid, while casting an empty string to an integer (''::int) is not. If required, use the treat_empty_val_as_null parameter to change the default behavior of fdelimitedparser.
Syntax
FDLIMITEDPARSER ( [parameter-name='value'[,...]] )
Parameters
delimiter |
Single character delimiter. Default: |
record_terminator |
Single-character record terminator. Default: |
trim |
Boolean, specifies whether to trim white space from header names and key values. Default: |
header |
Boolean, specifies that a header column exists. The parser uses Default: |
omit_empty_keys |
Boolean, specifies how the parser handles header keys without values. If Default: |
reject_on_duplicate |
Boolean, specifies whether to ignore duplicate records ( Default: |
reject_on_empty_key |
Boolean, specifies whether to reject any row containing a key without a value. Default: |
reject_on_materialized_type_error |
Boolean, specifies whether to reject any row value for a materialized column that the parser cannot coerce into a compatible data type. See Using flex table parsers. Default: |
treat_empty_val_as_null |
Boolean, specifies that empty fields become Default: |
Examples
-
Create a flex table for delimited data:
t=> CREATE FLEX TABLE delim_flex (); CREATE TABLE -
Use the
fdelimitedparserto load some delimited data fromSTDIN, specifying a comma (,) column delimiter:=> COPY delim_flex FROM STDIN parser fdelimitedparser (delimiter=','); Enter data to be copied followed by a newline. End with a backslash and a period on a line by itself. >> deviceproduct, severity, deviceversion >> ArcSight, High, 2.4.1 >> \.
You can now query virtual columns in the delim_flex flex table:
=> SELECT deviceproduct, severity, deviceversion from delim_flex;
deviceproduct | severity | deviceversion
---------------+----------+---------------
ArcSight | High | 2.4.1
(1 row)