Requirements
The driver requires Kinetica 7.2.3.24 or later, the first version to return query results as Arrow. A connection to an older server is refused when it opens, with an error naming the version found and the version needed. The driver’s version follows Kinetica’s: the7.2.<X> releases are for
Kinetica 7.2, with <X> counting the driver’s own releases.
Installation
Python
The driver is available on PyPI as a package that bundles the driver for the local platform with the ADBC driver manager:fetch_df:
There is no Windows ARM64 wheel, as
pyarrow publishes none; on
that platform, use the x86-64 wheel under an x86-64 Python, or
install the driver with dbc, below.Other Languages
The driver is built & distributed by the ADBC Driver Foundry for Linux, Mac, & Windows, and can be installed for every language at once with dbc:kinetica. The driver can
also be loaded directly from its shared library:
- Library:
libadbc_driver_kinetica.so(Linux),libadbc_driver_kinetica.dylib(Mac), oradbc_driver_kinetica.dll(Windows) - Entrypoint:
AdbcDriverKineticaInit
Rust
Rust applications can use the driver’s native API directly, as agit
dependency on the driver repository:
Dependency
driver_exporter feature, on by default, also builds the C ABI
that the ADBC driver manager loads; Rust-only consumers can turn it off with
--no-default-features.
Connecting
ADBC Applications
A connection takes the URL of the Kinetica database server as itsuri,
with a username & password. Every other setting is an option named
kinetica.<option>; see ADBC Configuration.
To create a connection from Python, using the bundled driver:
adbc-driver-manager 1.8 or later, which
finds a driver by name):
Driver Manager
Rust
The driver must not be called from inside an asynchronous Tokio
context; a Rust application running under Tokio calls it from a
blocking task.
Connection URI
Theuri may also be a kinetica:// URI, by which a driver manager given
only the URI knows to load this driver. The URI connects over HTTPS unless it
says tls=false, and every other query parameter is a driver option under
its own name; an option set directly takes precedence over the URI’s.
Connection URI
Secure Connections
When connecting to a Kinetica instance over HTTPS, theuri should
reference the database’s secure address, and the driver validates the server’s
certificate against the system’s trusted certificates.
To validate against a custom trust store instead, set
kinetica.trust_store_path (and kinetica.trust_store_password, if the
store has one). To accept the server’s certificate without checking it, set
kinetica.bypass_ssl_cert_check to true; prefer a trust store wherever
the certificate can be trusted.
Failover Connections
When connecting to a Kinetica instance with one or more failover clusters, theuri should be updated to contain a comma-delimited list of head node
addresses for all clusters. The URL of the primary cluster can also be
specified.
List all cluster head node addresses in the uri and add a
kinetica.primary_url option designating the cluster that should be tried
first.
Other ADBC Clients
Any tool that loads ADBC drivers can use the Kinetica driver, once it is installed with dbc or the shared library is placed where the tool can find it. The following is the general driver and connection information that should be used when configuring a client.- Driver:
kinetica, or the path to the downloaded shared library - Entrypoint:
AdbcDriverKineticaInit - Connection URI:
Using the Driver
The following examples use the Python package; the same operations are available through every ADBC driver manager.Querying Data
A cursor executes any Kinetica SQL and returns the result as Arrow. Rows can be fetched one at a time, but for a large result, take the Arrow table or data frame directly:Query
? placeholders and are bound as Arrow values:
Parameters
kinetica.query.batch_size
sets the rows requested per page and kinetica.query.max_rows caps the rows
returned; see Query Options.
After
execute() of an INSERT, UPDATE, or DELETE, the
cursor’s rowcount is -1, as the driver cannot return a count
alongside a result stream; executemany() reports it correctly.
The count is also available from the statement as
kinetica.count_affected; see Statement Results.Loading Data
Data can be inserted with SQL, as with any other client:Insert
Bulk Load
mode is one of:
append= Add the rows to an existing tablecreate= Create the table from the Arrow schema, failing if it existscreate_append= Create the table if it does not exist, then add the rowsreplace= Drop any existing table and create it from the Arrow schema
INSERT INTO ... VALUES (?, ...) with bound rows also goes directly
to the worker ranks; an INSERT with expressions, a SELECT source, or an
ON CONFLICT clause is executed by the server.
A local file can be loaded with
INSERT INTO … SELECT … FROM FILE,
which the driver reads on the client and sends to the worker ranks; the file
options are listed under Ingest Options:
Load File
A load is not transactional: when a load fails part-way, the rows
already sent remain in the table, and the error reports how many
rows were loaded.
Reading the Catalog
The standard ADBC metadata calls return the catalog as Arrow, including primary & foreign keys, with the table & columns each foreign key points at:Catalog
LIKE patterns. Kinetica has a single, unnamed catalog.
Transactions
Kinetica has no multi-statement transactions. Autocommit is always on, and a statement has taken effect by the time it returns. By default,commit() &
rollback() are refused, and the Python driver manager warns once:
kinetica.fake_transactions to true.
Sessions & Temp Tables
A connection is a server session, and the session temp tables it creates belong to that session alone; closing the connection drops them.Temp Table
kinetica.session_id on each to
the same ID; every connection given the same ID sees the same tables. A
session named this way is left in place when a connection closes, for its owner
to drop.
The SQL session statements SET USER,
EXECUTE AS USER,
REVERT,
SET SCHEMA, & SET CATALOG are also
available, for tools that can only send SQL.
Data Types
The Arrow type of each result column is chosen by the server, so a table read through the driver and written back arrives as it left. Every result column also carries the Kinetica type as its SQL writes it (e.g.,VARCHAR(16) or
DECIMAL(10,2)) under the field metadata key KINETICA:type, with the
column’s properties & nullability under KINETICA:properties &
KINETICA:nullable.
When loading data, the mapping runs in reverse: an Arrow
timestamp of any
unit is stored as milliseconds; a timestamp with a time zone becomes a
TIMESTAMP and one without becomes a DATETIME; decimal256 is stored
as DECIMAL; and the extension types above map back to their Kinetica
types. A table the driver creates from an Arrow schema uses the same mapping
for its column types.
ADBC Configuration
Configuration parameters are passed as options when the database handle is created (db_kwargs in Python), or as query parameters of a
kinetica:// connection URI; an option set
directly takes precedence over the URI’s. A boolean option takes true or
false. Each option is set on the database unless noted otherwise; an
option set on the database is inherited by its connections.
Some settings of note follow.
Connection Options
Authentication Options
Password authentication is the default. For OAuth, either hand over a token the caller acquired itself, or name a grant and let the driver acquire one. See HTTPS Connections with OIDC/OAuth Authentication for the server-side setup.
An acquired token is held for the process and renewed before it expires;
concurrent connections wanting the same token sign in once between them. The
token is settled when the connection is opened and not revisited, so a
connection held open longer than its token’s lifetime will start failing; open
a new one rather than expecting it to recover.
Client Credentials
Query Options
The following are optional parameters that could be used to override the
default settings, which are set by the server. See the
Configuration Reference for more
information on configuring the SQL Engine server-side. Each is sent with
every statement, but only when set, so an unset one leaves the server’s own
default in place. Each can be set on the database or a connection.
Ingest Options
The following govern bulk loads viaadbc_ingest, a bound
INSERT INTO ... VALUES, and INSERT INTO ... SELECT ... FROM FILE. Each
can be set on the database or a connection.
The following options read a local file loaded by
INSERT INTO ... SELECT ... FROM FILE. A statement can also give each in
its own WITH OPTIONS (...) clause, as file read followed by the
option’s last part (e.g., file read limit = 100), which takes precedence
over the connection’s.
Statement Results
The following are read from a statement after it runs (get_option_int on
the statement, or the adbc_statement of a Python cursor), as the ADBC
interface has no room for them on a call that also returns a reader.
kinetica.count_affected
kinetica.count_affected
Rows the last statement changed, or
-1 if it was a querykinetica.total_number_of_records
kinetica.total_number_of_records
Rows the last statement’s whole result holds, however many have been read so far, or
-1 if it produced no result.
A query bound to several rows of parameters runs once for each, and this adds up the runs made so far. Also available
as the standard adbc.statement.exec.max_progress option.kinetica.key_lookup
kinetica.key_lookup
1 if the last read was answered by the rank holding its row, 0 if it went through the SQL engineLogging
The driver logs through thekinetica.log_level & kinetica.log_path
options; see Connection Options. A host program that has
installed a logger of its own keeps it.
Kinetica logs inbound SQL requests, internal calls made on behalf of those
requests, and other debugging information. These logs can be found in the
following log files:
- /opt/gpudb/core/logs/host-manager-<hostname>-<datetime>.log: Contains
all endpoint calls, including the initial call to
/execute/sqland any endpoint calls made as a result of servicing the request - /opt/gpudb/sql/logs/sql-engine-<kinetica-hostname>.log: Contains detailed error messages