Overview
Write data to MySQL databases. Tables are created automatically from your source schema, and rows are upserted when aprimary_key is provided.
Configuration
Parameters
Database name. MySQL treats schemas and databases as synonyms; this value is
used as the database the sink writes to.
Optional. Column (or comma-separated list of columns) to use as the table’s
primary key. When set, inserts become upserts. Without it, writes are plain
INSERTs and the auto-created table has no primary key.Behavior when a row with the same primary key already exists.
update uses
ON DUPLICATE KEY UPDATE to overwrite non-key columns. nothing uses
INSERT IGNORE to skip the duplicate. Only applies when primary_key is set.Optional. Maximum time to wait before flushing a partial batch, parsed as a humantime duration (for example,
"500ms", "1s", "2s").Secret format
MySQL secrets are stored as a structured JSON object with the connection fields (host, port, user, password, databaseName). Create one with the
CLI:
mysql://user:pass@host:3306/database) or individual fields at the prompt;
both are parsed client-side into the structured shape before the secret is
saved. The databaseName in the secret populates the database the plugin
connects to; it does not need to match the schema field in your pipeline
YAML, but typically does.
Behavior
- Auto table creation: The sink issues
CREATE TABLE IF NOT EXISTSon startup. Ifprimary_keyis set, the table is created with thatPRIMARY KEY. Composite keys are supported (e.g.,primary_key: id,version). - No schema migrations: If the table already exists, the sink does not
ALTER TABLE. Adding a new upstream column against an existing table will fail the insert. - Upsert vs insert: With
primary_keyset, the sink usesINSERT ... ON DUPLICATE KEY UPDATE(orINSERT IGNOREwhenon_conflict: nothing). Without it, writes are plain inserts. - Deletes: Rows arriving with
_gs_op = "d"are deleted by primary key. Deletes are a no-op when noprimary_keyis configured. - Type mapping: Arrow types map to MySQL as
Int32 → INT,Int64 → BIGINT,UInt64 → BIGINT UNSIGNED,Float64 → DOUBLE,Utf8 → TEXT,Binary → LONGBLOB,Timestamp → DATETIME(6),Date → DATE,Decimal(p,s) → DECIMAL(p,s)(precision capped at 65), and nested types (struct/list/map) →JSON.