Skip to main content
GuideServerConfigure and deploy Tabsdata servers on your machine.TutorialsConfigure data integration workflows within a running Tabsdata server.API ReferenceCLI ReferenceRelease Notes
Version: 2.3.0

Apache Druid

The Apache Druid connector lets Tabsdata subscribers write data from Tabsdata tables into Druid datasources.

The connector stages the data as Parquet files in cloud storage, then submits a Druid ingestion task that loads it from there.

See the full subscriber walkthrough

The subscriber is registered in a collection created with a DruidDestConn connection. The connection, and how to create the collection, are described in Connection, at the end of this page.

Prerequisites​

  • The Druid Overlord API is reachable from the Tabsdata server.
  • The Overlord credentials can submit and inspect ingestion tasks.
  • Tabsdata can write to the S3 or Azure staging location and Druid can read the staged Parquet files.
  • The Druid cluster has the druid-parquet-extensions extension loaded, plus the S3 or Azure extension for the staging location.

Subscriber​

Configure DruidDest as the destination of a subscriber function to define which datasources Tabsdata writes in Druid.

write_events.py
from tabsdatak.api import subscriber, TableFrameSpec
from tabsdatak.conn.druid import DruidDest

@subscriber(
destination=DruidDest(
tables=[
"events",
],
),
input_tables=["events"],
)
def write_events(events: TableFrameSpec) -> TableFrameSpec:
return events
  • required
  • optional
  • optional
  • optional
  • optional
  • optional
  • optional
  • optional
  • optional

Function Config Parameters​

tables​

Defines the Druid datasources the subscriber writes to. Each name is 1 to 128 characters, does not start with . or _, and contains no /, backslash or NUL.

Each element in tables represents one destination slot and maps positionally to a value returned by the subscriber function.

if_table_exists​

"append" (the default) adds rows to the datasource. "replace" overwrites it.

time_column​

The column Druid uses as its primary __time field. Druid requires a time column on every datasource. Without one, every row gets the fixed timestamp 2000-01-01T00:00:00Z, so set time_column to a column that holds a timestamp for every row.

segment_granularity​

The time span of each Druid segment: ALL (the default), NONE, SECOND, MINUTE, FIFTEEN_MINUTE, THIRTY_MINUTE, HOUR, SIX_HOUR, DAY, WEEK, MONTH, QUARTER or YEAR.

max_concurrent_subtasks, max_rows_per_segment, max_rows_in_memory and http_timeout_sec​

Tuning for the ingestion task: its concurrency (default 1), the row cap per segment (default 5000000), the in-memory row cap per task (default 1000000), and the HTTP request timeout in seconds (default 300).

dest_cfg​

Sets additional destination configuration. The only accepted key is druid.logging_level. The keys druid.poll_interval_seconds, druid.retry_attempts and druid.retry_backoff_seconds are accepted but have no effect. The connector polls the task every 2 seconds and makes 3 attempts, with 2-second exponential backoff, on 429, 502, 503 and 504 responses and on connection or timeout errors.

Write behavior​

Each entry in tables is one destination slot and maps by position to a value returned by the subscriber function. Returning None for a slot skips that write.

if_table_exists="append" adds data to the datasource. "replace" overwrites it: the ingestion task drops the existing segments in the range 1970-01-01 to 2100-01-01, and rows outside that range are discarded. Datasources are written one after another. time_column selects the row timestamp used as Druid __time; without it, every row gets __time set to 2000-01-01T00:00:00Z.

Schema evolution​

Druid cannot enforce a schema, so "update" is its only schema_evolution value and its default; "strict" is refused at registration. On "append" and "replace", Druid's native schema discovery adds a new column to the datasource, and a column the batch lacks reads as NULL. Druid has no keyed upsert, so "merge" is not supported.

Operational notes​

  • The connection is to the Overlord API, not a SQL endpoint.
  • A write finishes only after the submitted ingestion task finishes. The task is polled with no overall timeout. http_timeout_sec limits each HTTP request, not the whole wait.
  • Staged files are deleted when the ingestion task ends, whether it succeeds or fails with DRUID_9. If the outcome is unknown, the files are kept, so a lifecycle rule on the staging prefix can clear them. The staging credentials need delete permission.
  • segment_granularity and the row limits change the ingestion task, not the Tabsdata input table.
  • Tabsdata does not contact Druid or the staging service when the collection is created. Those checks happen when the subscriber runs.

Connection​

Druid subscribers use DruidDestConn to define the Overlord, the credentials, and the cloud storage the data is staged in.

conn-druid.yaml
kind: connectionDef
apiVersion: '1.0'
type: tabsdatak.conn.druid:DruidDestConn
spec:
overlord_url: 'http://druid-overlord.internal:8081'
credentials:
kind: userPasswordCredentials
apiVersion: '1.0'
type: tabsdatak.conn.common.types:UserPassword
spec:
user: 'secret:tabsdata_writer'
password: 'secret:example-password'
staging:
kind: druidS3Location
apiVersion: '1.0'
type: tabsdatak.conn.druid:S3Location
spec:
bucket: 'acme-staging'
region: 'us-east-1'
credentials:
kind: awsAccessSecretKeyCredentials
apiVersion: '1.0'
type: tabsdatak.conn.common.types:AwsAccessSecretKey
spec:
access_key_id: 'secret:example-access-key'
secret_access_key: 'secret:example-secret-key'
base_path: '/druid'
  • required
  • required
  • required
  • optional

Create the collection​

A subscriber is registered in a destination collection, and a destination collection is created with its connection. Every function registered in the collection uses that connection.

Generate a connection template, which lists all the connection fields:

tdk connection template --type druid-bulk-out --file conn-druid.yaml

Edit the template file with the Druid connection information, check it, and create the collection with it:

tdk connection validate --file conn-druid.yaml
tdk collection create --name druid_out --conn-file conn-druid.yaml

Then register the subscriber in the collection:

tdk fn register --coll druid_out --path write_events.py::write_events
  • The collection goes in the destinations group, because the connection is a destination connection. --group can be left out; if it is given, it must be destinations.
  • secret:<value> gives a secret value in the file itself. $secret:<ENV_VAR> reads it from an environment variable when the collection is created, so the value never appears in the file. Either way, Tabsdata stores the secret separately, and the stored connection only shows a placeholder.
  • Functions in the collection must use the connector of its connection: DruidDest for a collection created with DruidDestConn. Transformers go in a collection of their own.
  • To change the connection later, for example to rotate a password, run tdk collection update --name druid_out --conn-file conn-druid.yaml. The connector cannot change; to use another one, create another collection.
  • Creating a source or destination collection requires permission to manage the project.

Connection Config Parameters​

overlord_url​

The http:// or https:// URL of the Druid Overlord, for example http://druid.example:8081. Accepts secret: too.

credentials​

A UserPassword used for HTTP basic authentication with the Overlord. Cloud storage credentials are configured separately under staging.

staging​

An S3Location or an AzBlobLocation from tabsdatak.conn.druid, where the Parquet files are staged before ingestion. Tabsdata must be able to upload the staged files, and Druid must be able to read them. Keys under cfg on the location configure the upload; see Object Store Options.

conn_cfg​

Optional connector configuration. It affects only the explorer, not writes.