Skip to main content
Version: Next

HugeGraph Sink Connector

Sink: HugeGraph

Description

The HugeGraph sink connector allows you to write data from SeaTunnel to Apache HugeGraph, a fast and scalable graph database.

This connector supports writing data as vertices or edges, providing flexible mapping from relational data models to graph structures. It is designed for high-performance data loading.

Key Features

The connector writes rows as either vertices or edges. It supports insert, update, and delete row kinds, and it can flush buffered records by batch_size or batch_interval_ms.

caution

New mappings configurations default to schema_save_mode = CREATE_SCHEMA_WHEN_NOT_EXIST and create missing HugeGraph PropertyKey/VertexLabel/EdgeLabel definitions before writing. Legacy schema_config jobs retain the previous ERROR_WHEN_SCHEMA_NOT_EXIST behavior unless this option is explicitly set.

Configuration Options

NameTypeRequiredDefault ValueDescription
hostStringYes-The host of the HugeGraph server.
portIntegerYes-The port of the HugeGraph server.
protocolStringNohttpServer protocol: http or https. HTTPS uses the JVM trust store.
graph_nameStringYes-The name of the graph to write to.
graph_spaceStringNoDEFAULTThe graph space the graph belongs to.
usernameStringNo-The username for HugeGraph authentication.
passwordStringNo-The password for HugeGraph authentication.
batch_sizeIntegerNo500The number of records to buffer before writing to HugeGraph in a single batch.
batch_interval_msIntegerNo5000The maximum time in milliseconds to wait before flushing a batch.
batch_failure_fallbackBooleanNotrueWhen a batch insert fails, fall back to inserting the batch record by record so a single bad ("poison") record no longer fails the whole batch. Failed records are logged and skipped; the rest succeed. If every record fails (systemic error), it is surfaced. Set to false to fail the whole batch instead.
max_insert_errorsIntegerNo500Maximum number of records that may be skipped by the single-record fallback (batch_failure_fallback=true) before the task is failed. Bounds the otherwise unlimited silent skipping of poison records. Set to -1 for unlimited. Only applies when batch_failure_fallback is enabled.
failure_data_pathStringNo-Optional local directory. When set, every record skipped by the single-record fallback is appended (mapped id, label, properties and the server error) to a per-subtask file (hugegraph-sink-failures-subtask-N.log) for offline investigation. In cluster mode the file is created on the worker node running the sink subtask.
check_vertexBooleanNofalseWhether the server verifies that an edge's source/target vertices exist when writing edges. When false, edges whose endpoints were never loaded are written as orphan edges (or trigger server-side phantom vertex auto-creation). Enable to reject such edges.
max_retriesIntegerNo3Retries after the initial attempt. Set to 0 to disable retries.
retry_backoff_msIntegerNo5000Base backoff between retries in ms. Grows exponentially per attempt (retry_backoff_ms * 2^(attempt-1)), capped at retry_backoff_max_ms.
retry_backoff_max_msIntegerNo30000Upper bound in ms for the exponential retry backoff.

Sink Options

NameTypeRequiredDefault ValueDescription
mappingsListYes-Recommended mapping configuration. Each entry maps input rows to one HugeGraph vertex or edge label.
schema_save_modeEnumNoCREATE_SCHEMA_WHEN_NOT_EXIST for mappings; ERROR_WHEN_SCHEMA_NOT_EXIST for legacy schema_configSchema management mode.
data_save_modeEnumNoAPPEND_DATAHow pre-existing data is handled before writing. APPEND_DATA keeps existing data. DROP_DATA deletes, once at job start, only the data of the labels this job targets (edges then vertices), preserving their schema and any other labels' data; the drop is scoped per label (so one table's drop does not wipe another) and is not re-run on checkpoint restart.
delete_vertex_with_edgesBooleanNofalse for mappings; true for legacy schema_configWhen true, DELETE rows for vertices also delete associated edges.
schema_configObjectNo-Deprecated legacy mapping object. Use mappings instead. Either mappings or schema_config must be specified.
selected_fieldsListNo-Deprecated. Still honored with legacy schema_config; use mapping properties for new jobs.
ignored_fieldsListNo-Deprecated. Still honored with legacy schema_config; use mapping properties for new jobs.

If both mappings and schema_config are configured, mappings wins and schema_config is ignored with a warning.

Mapping Configuration (mappings)

Each mappings entry defines how input rows are mapped to one HugeGraph vertex or edge label.

NameTypeRequiredDefault ValueDescription
typeStringYes-The type of graph element to map to. Must be VERTEX or EDGE.
labelStringYes-The label of the vertex or edge in HugeGraph.
propertiesList<String>No-Source field names written as HugeGraph properties. If empty, all input fields are considered.
ttlLongNo-The time-to-live for the vertex or edge in seconds.
ttlStartTimeStringNo-The start time for the TTL.
enableLabelIndexStringNo-Reserved label-index setting passed through the mapping config.
userdataMap<String, Object>No-User-defined data associated with the label.
idStrategyStringFor Vertex-The ID generation strategy for vertices, such as PRIMARY_KEY, CUSTOMIZE_STRING, CUSTOMIZE_NUMBER, CUSTOMIZE_UUID, or AUTOMATIC.
idFieldsList<string>For Vertex-A list of source field names used to generate the vertex ID. Required when idStrategy is not AUTOMATIC.
sourceConfigObjectFor Edge-An object defining the mapping for the edge's source vertex. See Source/Target Config below.
targetConfigObjectFor Edge-An object defining the mapping for the edge's target vertex. See Source/Target Config below.
frequencyStringFor Edge-The frequency of the edge, e.g., SINGLE, MULTIPLE.
sortKeysList<String>For Edge-Source field names (as they appear in the input row, before fieldMapping is applied) whose values distinguish edges sharing the same source and target vertices. Required when frequency = MULTIPLE. Example: with fieldMapping = {event_time: created_at}, use sortKeys = [event_time], not [created_at].
fieldMappingMap<String, String>No-A map where the key is the source field name and the value is the target property name in HugeGraph.
valueMappingMap<String, Map<Object, Object>>No-Per-field value transform. Outer key = source field name; inner map = originalValue -> newValue.
ignoredList<String>No-Blacklist of source fields excluded from properties (implicit mode only). Mutually exclusive with properties (which acts as the selected whitelist).
updateStrategiesMap<String, String>No-Per-property merge strategy on write, keyed by target property name: OVERRIDE, APPEND, SUM, UNION, BIGGER, SMALLER, etc. When set, existing elements are merged instead of overwritten.
nullableKeysList<String>No-Explicit allow-list of property keys that may be null on an auto-created label. When set, it overrides the default below (only these keys are nullable). Key properties (primary keys, MULTIPLE-edge sort keys) are always excluded. Mutually exclusive with notNullableKeys.
notNullableKeysList<String>No-Opt-out list used with the default nullability. By default, when neither nullableKeys nor notNullableKeys is set, all non-key properties of an auto-created label are nullable; list here the properties that must instead be required. Mutually exclusive with nullableKeys. Only affects newly auto-created labels.
nullValuesList<String>No-A list of string values that should be treated as null.
dateFormatStringNoyyyy-MM-ddThe date format for parsing date strings.
extraDateFormatsList<String>No-Additional date patterns tried in order, after dateFormat, when parsing date strings — for sources that mix multiple date formats.
listFormatObjectNo-How a raw string cell is parsed into SET/LIST property elements: startSymbol (default [), endSymbol (default ]), elemDelimiter (default ,), and ignoredElems.
unfoldBooleanNofalse(Vertex) Expand a list-valued CUSTOMIZE id cell into one vertex per element. INSERT/append-only.
unfoldSourceBooleanNofalse(Edge) Expand a list-valued source-endpoint id cell into multiple edges (CUSTOMIZE endpoint). INSERT/append-only.
unfoldTargetBooleanNofalse(Edge) Expand a list-valued target-endpoint id cell into multiple edges (cartesian with source). INSERT/append-only.
timeZoneStringNoWorker JVM defaultThe time zone for date parsing. When omitted, the worker JVM default time zone is used, matching the HugeGraph Source so a Source→Sink round-trip preserves absolute times.

Legacy Schema Configuration (schema_config)

schema_config defines how one input stream is mapped to a specific vertex or edge label in HugeGraph. It is deprecated; new jobs should use mappings.

NameTypeRequiredDefault ValueDescription
typeStringYes-The type of graph element to map to. Must be VERTEX or EDGE.
labelStringYes-The label of the vertex or edge in HugeGraph.
tablePathStringNo-Reserved table path value carried in the schema config.
propertiesList<String>No-A list of source field names for the vertex or edge.
ttlLongNo-The time-to-live for the vertex or edge in seconds.
ttlStartTimeStringNo-The start time for the TTL.
enableLabelIndexStringNo-Reserved label-index setting passed through the schema config.
userdataMap<String, Object>No-User-defined data associated with the label.
idStrategyStringFor Vertex-The ID generation strategy for vertices, such as PRIMARY_KEY, CUSTOMIZE_STRING, CUSTOMIZE_NUMBER, CUSTOMIZE_UUID, or AUTOMATIC.
idFieldsList<string>For Vertex-A list of source field names used to generate the vertex ID.
sourceConfigObjectFor Edge-An object defining the mapping for the edge's source vertex. See Source/Target Config below.
targetConfigObjectFor Edge-An object defining the mapping for the edge's target vertex. See Source/Target Config below.
frequencyStringFor Edge-The frequency of the edge, e.g., SINGLE, MULTIPLE.
mappingObjectNo-An object defining advanced field and value mappings. See Mapping Config below.

Source/Target Config (sourceConfig and targetConfig)

This object is used within an EDGE schema to define how to identify the source and target vertices.

NameTypeRequiredDefault ValueDescription
labelStringYes-The label of the source or target vertex.
idFieldsList<String>Yes-A list of source field names from the input row used to construct the ID of the source/target vertex. The values will be concatenated to form the vertex ID. For a HugeGraph → HugeGraph clone, set this to the single reserved column that already carries the assembled endpoint id — ["~source_id"] for sourceConfig, ["~target_id"] for targetConfig — and the connector reuses that id directly (see Cloning from a HugeGraph Source below).

Cloning from a HugeGraph Source (reserved-id passthrough)

When the input is the HugeGraph Source, each row carries reserved columns holding the already-assembled element ids (~id for a vertex; ~source_id/~target_id for an edge's endpoints). To clone losslessly:

  • Vertex with a CUSTOMIZE_STRING/CUSTOMIZE_NUMBER/CUSTOMIZE_UUID id: set idStrategy to the matching CUSTOMIZE_* and idFields = ["~id"]; the original id is written verbatim. PRIMARY_KEY vertices instead reuse their key property columns (which the Source already emits), and AUTOMATIC ids cannot be preserved (the target server assigns new ones).
  • Edge: set sourceConfig.idFields = ["~source_id"] and targetConfig.idFields = ["~target_id"]. The endpoint ids are reused directly, so edges clone regardless of the endpoint vertices' id strategies. The target endpoint vertex labels must already exist (the connector will not auto-create a vertex label from a reserved id).

Mapping Config (mapping)

This object provides advanced control over how fields and values are mapped to properties.

NameTypeRequiredDefault ValueDescription
fieldMappingMap<String, String>No-A map where the key is the source field name and the value is the target property name in HugeGraph. If not specified, the source field name is used as the target property name.
valueMappingMap<String, Map<Object, Object>>No-Per-field value transform. The outer key is the source field name; the inner map is originalValue -> newValue. Scoping by field prevents one column's rule from affecting another (e.g. gender M->male will not rewrite status M).
ignoredList<String>No-Blacklist of source fields excluded from properties (implicit mode only). Mutually exclusive with properties (which acts as the selected whitelist).
updateStrategiesMap<String, String>No-Per-property merge strategy on write, keyed by target property name: OVERRIDE, APPEND, SUM, UNION, BIGGER, SMALLER, etc. When set, existing elements are merged instead of overwritten.
nullableKeysList<String>No-Explicit allow-list of property keys that may be null on an auto-created label. Overrides the nullable-by-default behavior. Mutually exclusive with notNullableKeys.
notNullableKeysList<String>No-Opt-out list of properties that must be required, used together with the nullable-by-default behavior. Mutually exclusive with nullableKeys.
nullValuesList<String>No-A list of string values that should be treated as null. Any field containing one of these values will not be written.
dateFormatStringNoyyyy-MM-ddThe date format for parsing date strings.
extraDateFormatsList<String>No-Additional date patterns tried in order, after dateFormat, when parsing date strings — for sources that mix multiple date formats.
listFormatObjectNo-How a raw string cell is parsed into SET/LIST property elements: startSymbol (default [), endSymbol (default ]), elemDelimiter (default ,), and ignoredElems.
unfoldBooleanNofalse(Vertex) Expand a list-valued CUSTOMIZE id cell into one vertex per element. INSERT/append-only.
unfoldSourceBooleanNofalse(Edge) Expand a list-valued source-endpoint id cell into multiple edges (CUSTOMIZE endpoint). INSERT/append-only.
unfoldTargetBooleanNofalse(Edge) Expand a list-valued target-endpoint id cell into multiple edges (cartesian with source). INSERT/append-only.
timeZoneStringNoWorker JVM defaultThe time zone for date parsing. When omitted, the worker JVM default time zone is used.
sortKeysList<String>For Edge-Source field names (before fieldMapping is applied) whose values distinguish edges sharing the same source and target vertices. Example: with fieldMapping = {event_time: created_at}, use [event_time], not [created_at].

Supported Types

The connector validates the SeaTunnel row schema against the existing HugeGraph schema before writing.

SeaTunnel typeHugeGraph property type
BYTESBLOB
TINYINTINT
SMALLINTINT
INTINT
BIGINTLONG
FLOATFLOAT
DOUBLEDOUBLE
BOOLEANBOOLEAN
DATEDATE
TIMESTAMPDATE
ARRAYA non-single-cardinality HugeGraph property whose element type is compatible
STRINGTEXT
DECIMALTEXT
MAPTEXT
ROWTEXT
TIMETEXT
NULLTEXT

Write Behavior Notes

  • For vertices, idStrategy controls how the vertex ID is built. PRIMARY_KEY joins all idFields with HugeGraph's primary-key format, CUSTOMIZE_STRING joins multiple idFields with : (backslash-escaping any : in a value so distinct field tuples cannot collide; a single field is used verbatim), CUSTOMIZE_NUMBER expects one integer-valued field (a fractional value like 1.9 is rejected, not silently truncated), and CUSTOMIZE_UUID expects one UUID field.
  • For edges, the connector reads the ID strategy from the existing source and target vertex labels in HugeGraph. sourceConfig.idFields and targetConfig.idFields must provide enough fields to rebuild those vertex IDs.
  • INSERT writes a new vertex or edge, UPDATE_AFTER updates the existing graph element, and DELETE deletes it. Delete rows only need the fields required to build the element ID.
  • AUTOMATIC vertex IDs support INSERT only. UPDATE and DELETE require a reconstructable ID strategy.
  • The sink is at-least-once. Replayed INSERT records with AUTOMATIC IDs can create duplicates after retries or checkpoint recovery.
  • Edge batches use the configured check_vertex (default false). With the default, vertices and edges may be written out of order and the graph reaches its final consistent state after all batches complete; set check_vertex=true to have the server reject edges whose endpoints do not yet exist.
  • nullValues treats matching string values as null and skips those properties during writes.
  • Time zone is configured per mapping via timeZone (there is no top-level time_zone option on the sink, unlike the HugeGraph Source, because date parsing is a per-mapping concern). When omitted it defaults to the worker JVM zone, matching the Source so a Source→Sink round-trip preserves absolute times.

Usage Examples

The examples below use the default schema_save_mode = CREATE_SCHEMA_WHEN_NOT_EXIST. If you set schema_save_mode = ERROR_WHEN_SCHEMA_NOT_EXIST, create the corresponding HugeGraph schema before running the job.

1. Writing Vertices

This example shows how to read from a FakeSource and write person vertices to HugeGraph. The vertex ID is based on the name field.

env {
job.mode = "BATCH"
}

source {
FakeSource {
plugin_input = "fake_source"
schema = {
fields = {
name = "string"
age = "int"
}
}
}
}

sink {
HugeGraph {
host = "localhost"
port = 8080
graph_name = "hugegraph"
mappings = [
{
type = "VERTEX"
label = "person"
idStrategy = "PRIMARY_KEY"
idFields = ["name"]
properties = ["name", "age"]
}
]
}
}

2. Writing Edges

This example syncs a relationship table to knows edges in HugeGraph. The source table contains the names of the two people who know each other and the year they met.

env {
job.mode = "BATCH"
}

source {
FakeSource {
plugin_input = "fake_source"
schema = {
fields = {
person1_name = "string"
person2_name = "string"
since = "int"
}
}
}
}

sink {
HugeGraph {
host = "localhost"
port = 8080
graph_name = "hugegraph"
mappings = [
{
type = "EDGE"
label = "knows"
sourceConfig = {
label = "person"
idFields = ["person1_name"]
}
targetConfig = {
label = "person"
idFields = ["person2_name"]
}
properties = ["since"]
fieldMapping = {
person1_name = "name"
person2_name = "name"
}
}
]
}
}

Changelog

Change Log
ChangeCommitVersion
[Fix][Connector-V2] Enforce topology-safe execution order in HugeGraph multi-mapping sinkhttps://github.com/apache/seatunnel/commit/467980a6a0dev
[Feature][Connector-V2] Add HugeGraph source connector and refactor sink with multi-mapping supporthttps://github.com/apache/seatunnel/commit/0f503024d7dev
[Feature][Connector-V2] Support sink connector for Apache HugeGraphhttps://github.com/apache/seatunnel/pull/10002/commits/002a653d11f48c3f76b47db23f5f2a68bc9d690c2.3.12