- in KiFS
- on a remote system, accessible via a data source
Parameters
OR REPLACE
OR REPLACE
REPLICATED
REPLICATED
TEMP
TEMP
LOGICAL
LOGICAL
MATERIALIZED
MATERIALIZED
<schema name>
<schema name>
<table name>
<table name>
<table definition clause>
<table definition clause>
REMOTE QUERY
REMOTE QUERY
<source data query> is a SQL query selecting the data
which will be loaded.FILE PATHS clause, and is only
applicable to JDBC data sources.- Any column expression used is given a column alias.
- The first column is not a
WKTor unlimited lengthVARCHARtype. - The columns and expressions queried should match the intended order, number, & type of the columns in the target table.
- If
REMOTE_QUERY_NO_SPLITisTRUE, the query will not be distributed. - If a valid
REMOTE_QUERY_PARTITION_COLUMNis specified, the query will be distributed by partitioning on the given column’s values - If a valid
REMOTE_QUERY_ORDER_BYis specified, the query will be distributed by ordering the data accordingly and then partitioning into sequential blocks from the first record - If a non-null numeric/date/time column exists, the query will be distributed by partitioning on the first such column’s values
- The query will be distributed by sorting the data on the first column and then partitioning into sequential blocks from the first record
FILE PATHS
FILE PATHS
<file paths> is a comma-separated list of
single-quoted file paths from which data will be loaded; all files specified are presumed to have
the same format and data types.REMOTE QUERY clause, and is not
applicable to JDBC data sources.-
Data Source: If a data source is specified in the load options, these file paths must resolve
to accessible files at that data source location. A “path prefix” can be specified instead,
which will cause all files whose path begins with the given prefix to be included.
For example, a “path prefix” of
/data/gefor<file paths>would match all of the following:/data/geo.csv/data/geo/flights.csv/data/geo/2021/airline.csv
-
KiFS: The path must resolve to an accessible file path within KiFS.
A “path prefix” can be specified instead, which will cause all files whose path begins with the
given prefix to be included.
For example, a “path prefix” of
kifs://data/gewould match all of the following files under the KiFSdatadirectory:kifs://data/geo.csvkifs://data/geo/flights.csvkifs://data/geo/2021/airline.csv
FORMAT
FORMAT
| Keyword | Description |
|---|---|
[DELIMITED] TEXT | Any text-based, delimited field data file (CSV, PSV, TSV, etc.); a comma-delimited list of options can be given to specify the way in which the data file(s) should be parsed, including the delimiter used, whether headers are present, etc. Records spanning multiple lines are not supported. See Delimited Text Options for the complete list of <delimited text options>. |
AVRO | Apache Avro data file |
JSON | Either a JSON or GeoJSON data file See JSON/GeoJSON Limitations for the supported data types. |
PARQUET | Apache Parquet data file See Parquet Limitations for the supported data types. |
SHAPEFILE | ArcGIS shapefile |
WITH OPTIONS
WITH OPTIONS
<partition clause>
<partition clause>
<tier strategy clause>
<tier strategy clause>
<index clause>
<index clause>
<table property clause>
<table property clause>
Delimited Text Options
The following options can be specified when loading data from delimited text files. When reading from multiple files, options specific to the source file will be applied to each file being read.COMMENT = '<string>'
COMMENT = '<string>'
DELIMITER = '<char>'
DELIMITER = '<char>'
char as the source file field delimiter.The default delimiter is a comma, unless a source file has one of these extensions:.psv- will cause|to be the delimiter.tsv- will cause the tab character to be the delimiter
ESCAPE = '<char>'
ESCAPE = '<char>'
char as the source file data escape character. The escape character preceding any
other character, in the source data, will be converted into that other character, except
in the following special cases:| Source Data String | Representation when Loaded into the Database |
|---|---|
<char>a | ASCII bell |
<char>b | ASCII backspace |
<char>f | ASCII form feed |
<char>n | ASCII line feed |
<char>r | ASCII carriage return |
<char>t | ASCII horizontal tab |
<char>v | ASCII vertical tab |
\, a \t encountered in
the data will be converted to a tab character when stored in the database.The escape character can be used to escape the quoting character, and will be treated as
an escape character whether it is within a quoted field value or not.There is no default escape character.HEADER DELIMITER = '<char>'
HEADER DELIMITER = '<char>'
char as the source file header field name/property delimiter, when the source file
header contains both names and properties. This is largely specific to the Kinetica
export to delimited text feature, which will, within each field’s header, contain the
field name and any associated properties, delimited by the pipe | character.An example Kinetica header in a CSV file:| (pipe) character. See
Delimited Text Option Characters for allowed characters.DELIMITER character will still be used to separate
field name/property sets from each other in the header rowINCLUDES HEADER = <TRUE|FALSE>
INCLUDES HEADER = <TRUE|FALSE>
TRUE.NULL = '<string>'
NULL = '<string>'
string as the indicator of a null source field value.The default is the empty string.QUOTE = '<char>'
QUOTE = '<char>'
char as the source file data quoting character, for enclosing field values.
Usually used to wrap field values that contain embedded delimiter characters, though any
field may be enclosed in quote characters (for clarity, for instance). The quote
character must appear as the first and last character of a field value in order to be
interpreted as quoting the value. Within a quoted value, embedded quote characters may be
escaped by preceding them with another quote character or the escape character specified
by ESCAPE, if given.The default is the " (double-quote) character. See
Delimited Text Option Characters for allowed characters.Delimited Text Option Characters
ForDELIMITER, HEADER DELIMITER, ESCAPE, & QUOTE, any single
character can be used, or any one of the following escaped characters:
'') are specified for a QUOTE
character, the parser will interpret single quotes in the source file as
quoting characters; specifying \t for DELIMITER will cause the parser
to interpret ASCII horizontal tab characters in the source file as delimiter
characters.
Load Options
The following options can be specified to modify the way data is loaded (or not loaded) into the target table.BAD RECORD TABLE
BAD RECORD TABLE
| Column Name | Source Data Format Codes |
|---|---|
line_number | Number of the line in the input file containing the failed record |
char_number | Position of character within a failed record that is assessed as the beginning of the portion of the record that failed to process |
filename | Name of file that contained the failed record |
line_rejected | Text of the record that failed to process |
error_msg | Error message associated with the record processing failure |
ON ERROR mode of ABORT. In that
mode, processing stops at the first error and that error is returned to the user.BATCH SIZE
BATCH SIZE
COLUMN FORMATS
COLUMN FORMATS
- date
- time
- datetime
| Code | Description |
|---|---|
YYYY | 4-digit year |
MM | 2-digit month, where January is 01 |
DD | 2-digit day of the month, where the 1st of each month is 01 |
2010.10.30 into date column d and times of
the 24-hour format 18:36:54.789 into time column t:DATA SOURCE
DATA SOURCE
DEFAULT COLUMN FORMATS
DEFAULT COLUMN FORMATS
COLUMN FORMATS option.For example, to make the default format for loading source data dates like 2010.10.30
and 24-hour times like 18:36:54.789:FIELDS IGNORED BY
FIELDS IGNORED BY
POSITION or NAME. If ignoring by NAME, the
specified names must match the source file field names exactly.-
Identifying by Name:
-
Identifying by Position:
- When ignoring source data file fields, the set of fields that are not ignored must align, in type & number in their order in the source file, with the external table columns into which the data will be loaded.
- Ignoring fields by
POSITIONis only supported for delimited text files.
FIELDS MAPPED BY
FIELDS MAPPED BY
POSITION or NAME. If mapping by NAME, the
specified names must match the source file field names exactly.-
Identifying by Name:
-
Identifying by Position:
- When mapping source data file fields, the set of fields that are identified must align, in type & number in the specified order, with the external table columns into which data will be loaded.
- Mapping fields by
POSITIONis only supported for delimited text files.
FLATTEN_COLUMNS
FLATTEN_COLUMNS
FALSE.| Value | Description |
|---|---|
TRUE | Break up nested columns into multiple columns. |
FALSE | Treat nested columns as JSON columns instead of flattening. |
IGNORE_EXISTING_PK
IGNORE_EXISTING_PK
UPDATE_ON_EXISTING_PK option is used, then this options has no effect.The default is FALSE.| Value | Description |
|---|---|
TRUE | Suppress errors when inserted records and existing records’ PKs match. |
FALSE | Return errors when inserted records and existing records’ PKs match. |
INGESTION MODE
INGESTION MODE
FULL.| Value | Description |
|---|---|
DRY RUN | No data will be inserted, but the file will be read with the applied ON ERROR mode and the number of valid records that would normally be inserted is returned. |
FULL | Data is fully ingested according to the active ON ERROR mode. |
TYPE INFERENCE | Infer the type of the source data and return, without ingesting any data. The inferred type is returned in the response, as the output of a SHOW TABLE command. |
JDBC_FETCH_SIZE
JDBC_FETCH_SIZE
NUM_SPLITS_PER_RANK
NUM_SPLITS_PER_RANK
NUM_TASKS_PER_RANK
NUM_TASKS_PER_RANK
JDBC_SESSION_INIT_STATEMENT
JDBC_SESSION_INIT_STATEMENT
REFRESH ON START or SUBSCRIBE is TRUE.For example, to set the time zone to UTC before running each load, use:ON ERROR
ON ERROR
ABORT.| Value | Description |
|---|---|
SKIP | If an error is encountered parsing a source record, skip the record. |
ABORT | If an error is encountered parsing a source record, stop the data load process. Primary key collisions are considered abortable errors in this mode. |
POLL_INTERVAL
POLL_INTERVAL
SUBSCRIBE is
TRUE.REFRESH ON START
REFRESH ON START
FALSE. This option is ignored if SUBSCRIBE is TRUE.| Value | Description |
|---|---|
TRUE | Refresh the external table’s data when the database is restarted. |
FALSE | Do not refresh the external table’s data when the database is restarted. |
REMOTE_QUERY_INCREASING_COLUMN
REMOTE_QUERY_INCREASING_COLUMN
SUBSCRIBE is TRUE.REMOTE_QUERY_NO_SPLIT
REMOTE_QUERY_NO_SPLIT
FALSE.| Value | Description |
|---|---|
TRUE | Issue the remote data retrieval as a single query. |
FALSE | Distribute and parallelize the remote data retrieval in queries for blocks of data at a time. |
REMOTE_QUERY_ORDER_BY
REMOTE_QUERY_ORDER_BY
REMOTE_QUERY_PARTITION_COLUMN.If REMOTE_QUERY_NO_SPLIT is TRUE, a valid REMOTE_QUERY_PARTITION_COLUMN is specified, or the column given is
invalid, this option is ignored.REMOTE_QUERY_PARTITION_COLUMN
REMOTE_QUERY_PARTITION_COLUMN
REMOTE_QUERY_NO_SPLIT is TRUE or the column given is invalid, this option is ignored.SUBSCRIBE
SUBSCRIBE
DATA SOURCE option. Only relevant for materialized external tables using
data sources configured to allow streaming.The default is FALSE. If TRUE, the REFRESH ON START option is ignored.| Value | Description |
|---|---|
TRUE | Subscribe to the specified streaming data source. |
FALSE | Do not subscribe to the specified data source. |
TRUNCATE_STRINGS
TRUNCATE_STRINGS
VARCHAR columns that are
not large enough to hold the entire text value.The default is FALSE.| Value | Description |
|---|---|
TRUE | Truncate any inserted string value at the maximum size for its column. |
FALSE | Reject any record with a string value that is too long for its column. |
TYPE_INFERENCE_MODE
TYPE_INFERENCE_MODE
SPEED.| Value | Description |
|---|---|
ACCURACY | Scan all available data to arrive at column types that are the narrowest possible that can still hold all the data. |
SPEED | Pick the widest possible column types from the minimum data scanned in order to quickly arrive at column types that should fit all data values. |
UPDATE_ON_EXISTING_PK
UPDATE_ON_EXISTING_PK
FALSE.| Value | Description |
|---|---|
TRUE | Update existing records with records being inserted, when PKs match. |
FALSE | Discard records being inserted when existing records’ PKs match. |
Table Definition Clause
The table definition clause allows for an explicit local table structure to be defined, irrespective of the source data type. This specification mirrors that of CREATE TABLE.Partition Clause
An external table can be further segmented into partitions. The supported Partition Clause syntax & features are the same as those in the CREATE TABLE Partition Clause.Tier Strategy Clause
An external table can have a tier strategy specified at creation time. If not assigned a tier strategy upon creation, a default tier strategy will be assigned. The supported Tier Strategy Clause syntax & features are the same as those in the CREATE TABLE Tier Strategy Clause.Index Clause
An external table can have any number of indexes applied to any of its columns at creation time. The supported Index Clause syntax & features are the same as those in the CREATE TABLE Index Clause.Table Property Clause
A subset of table properties can be applied to the external table associated with the external data at creation time. The supported Table Property Clause syntax & features are the same as those in the CREATE TABLE Table Property Clause.Examples
To create a logical external table with the following features, using a query as the source of data:- External table named
ext_employee_dept2in theexampleschema - Source is
department2 employees from theexample.employeetable, queried through the example.jdbc_ds data source - Data is re-queried from the source each time the external table is queried
- External table named
ext_productin theexampleschema - External source is a KiFS file named
product.csvlocated in thedatadirectory - Data is not refreshed on database startup
- External table named
ext_employeein theexampleschema - External source is a Parquet file named
employee.parquetlocated in the KiFS directorydata - External table has a primary key on the
idcolumn - Data is not refreshed on database startup
- External table named
ext_employeein theexampleschema - External source is a file named
employee.csvlocated in the KiFS directorydata - Apply a date format to the
hire_datecolumn
- External table named
ext_productin theexampleschema - External source is a data source named
product_dsin theexampleschema - Source is a file named
products.csv - Data is refreshed on database startup
- External table named
ext_productin theexampleschema - External source is a data source named
product_dsin theexampleschema - Source is a file named
products.csv - Data updates are streamed continuously
- External table named
ext_employee_dept2in theexampleschema - External source is a data source named
jdbc_dsin theexampleschema - Source data is a remote query of employees in department 2 from that
database’s
example.ext_employeetable - Data is refreshed on database startup
Data Sources
File-Based
To create an external table that loads a CSV file, products.csv, from the data source example.product_ds, into a table namedexample.ext_product:
Query-Based
To create an external table that is the result of a remote query of employees in department 2 from the JDBC data source example.jdbc_ds, into a local table namedexample.ext_employee_dept2:
Change Data Capture
File-Based
To create an external table loaded by a set of order data in a change data capture scheme with the following conditions:- data pulled through a data source, example.order_ds
- data files contained with an orders directory
- initially, all files in the directory will be loaded; subsequently, only those files that have been updated since the last check will be reloaded
- files will be polled for updates every 60 seconds
- target table named
example.ext_order
Query-Based
To create an external table loaded from a remote query of orders in a change data capture scheme with the following conditions:- data pulled through a data source, example.jdbc_ds
- data contained with an
example.orderstable, where only orders for product with ID 42 will be loaded into the target table - initially, all orders will be loaded; subsequently, only those orders with an
order_idcolumn value higher than the highest one on the previous poll cycle will be loaded - remote table will be polled for updates every 60 seconds
- target table named
example.ext_order_product42
stringas comments and skip.The default comment marker is#.