close
Skip to content

[Feature][Connector-V2] Support sink connector for Apache HugeGraph#10002

Merged
davidzollo merged 42 commits into
apache:devfrom
hugegraph:hg-connector-sink
Nov 27, 2025
Merged

[Feature][Connector-V2] Support sink connector for Apache HugeGraph#10002
davidzollo merged 42 commits into
apache:devfrom
hugegraph:hg-connector-sink

Conversation

@Gfreely

@Gfreely Gfreely commented Oct 30, 2025

Copy link
Copy Markdown
Contributor

Purpose of this pull request

fix #10001

Does this PR introduce any user-facing change?

This PR introduces a new Sink V2 connector: connector-hugegraph.
This allows users to configure a job to sink data into a HugeGraph database. Users can now write SeaTunnelRow data as either Vertices or Edges, specifying mappings for labels, ID strategy, and properties.

How was this patch tested?

Both Unit Tests (UT) and End-to-End (E2E) Tests were added for this new connector.

Unit Tests:

Added unit tests for HugeGraphSinkConfig to verify the parsing and validation of required sink-side options (e.g., checking necessary fields like url and graph_name).

E2E Tests:

Added a new E2E test module connector-hugegraph-e2e under the seatunnel-e2e/seatunnel-connector-v2-e2t/ directory.

This test uses a Docker container to spin up a temporary HugeGraph service instance.

It runs multiple test cases based on configuration files: testing writing SeaTunnelRow data as vertices, and testing writing SeaTunnelRow data as edges.

This is an example config for vertex synchronization:

env {
  job.mode = "BATCH"
}

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

sink {
  HugeGraph {
    host = "127.0.0.1"
    port = 8080
    graph_name = "hugegraph"
    graph_space = "default"
    selected_fields = ["name", "age"]
    schema_config = {
      type = "VERTEX"
      label = "person"
      idStrategy = PRIMARY_KEY
      idFields = ["name"]
      properties = ["name", "age"]
    }
  }
}

Test Sceenshots:
Use fake source to simulate source database, the detailed configuration is in the documentation.
image
The following are the query results before and after the sync.
image

I attempted to sync data from MySQL using stream processing, but I could only synchronize a part of it, likely because I don't have a Hadoop environment.

image image image

Check list

imbajin and others added 20 commits August 20, 2025 19:26
* docs: init SeaTunnel-HG design doc V1 🚧 (#4)

* docs: init hugegraph design doc V1 🚧

* update development docs

---------

Co-authored-by: Frui Guo <guofreedomly@gmail.com>

* update docs

---------

Co-authored-by: imbajin <jin@apache.org>
Replaced GremlinManager-based graph operations with HugeClient REST API methods for vertex management and verification.

Updated schema setup and test logic to improve reliability and remove direct Gremlin queries.
Configured maven-jar-plugin to include Implementation-Version in the jar manifest using hugegraph.client.version.

Refactored HugeGraphSinkWriterIT to improve import ordering and line wrapping for better readability.
@Gfreely Gfreely changed the title [Feature][Connector-V2] Support sink connector for HugeGraph [Feature][Connector-V2] Support sink connector for Apache HugeGraph Nov 6, 2025
@davidzollo

Copy link
Copy Markdown
Contributor

good job
CI failed.
You can check the detailed info through https://github.com/hugegraph/seatunnel/runs/54689699164


class HugeGraphSinkConfigTest {
// 使用 @Mock 注解自动创建 mock 对象
@Mock private ReadonlyConfig mockConfig;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please keep the source code in English

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks. I've addressed all the comments regarding the documentation/notes.

Comment on lines +352 to +353
assertEquals(1, hugeClient.graph().listEdges("knows").size());

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not familiar with graphs. Shouldn't this be 2 when knows adds two edges?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Apologies for the confusion. This is the expected "edge override" behavior.

To confirm, when an EdgeLabel's frequency is single, attempting to create a second edge with the same source, target, and EdgeLabel will overwrite the existing one.

I have refined the test for this specific scenario and moved it to testEdgeInsert.

@davidzollo

Copy link
Copy Markdown
Contributor

Good job, things are getting better
I noticed that there're many execptions, I think you can create a unified class HugeGraphConnectorException for HugeGraph,

package org.apache.seatunnel.connectors.seatunnel.hugegraph.exception;

import java.util.Map;
import org.apache.seatunnel.common.exception.SeaTunnelErrorCode;
import org.apache.seatunnel.common.exception.SeaTunnelRuntimeException;

public class HugeGraphConnectorException extends SeaTunnelRuntimeException {
    public HugeGraphConnectorException(SeaTunnelErrorCode code, String msg) { super(code, msg); }
    public HugeGraphConnectorException(SeaTunnelErrorCode code, String msg, Throwable c) { super(code, msg, c); }
    public HugeGraphConnectorException(SeaTunnelErrorCode code, Map<String,String> params) { super(code, params); }
    public HugeGraphConnectorException(SeaTunnelErrorCode code, Map<String,String> params, Throwable c) { super(code, params, c); }
}

@@ -0,0 +1,357 @@
# SeaTunnel Connector 架构设计分析

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This document is not needed

@corgy-w corgy-w left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you provide a screenshot of the successful run on your local device

@Gfreely

Gfreely commented Nov 19, 2025

Copy link
Copy Markdown
Contributor Author

Could you provide a screenshot of the successful run on your local device

I have updated the PR with the requested changes. Additionally, I've attached a screenshot verifying that the local database synchronization is successful. Please take a look.

@corgy-w corgy-w left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are upsert operations supported now? Does writing graph data need to support upsert?

@Gfreely

Gfreely commented Nov 25, 2025

Copy link
Copy Markdown
Contributor Author

Are upsert operations supported now? Does writing graph data need to support upsert?

The hugegraph-client natively supports upsert operations. For update operations, you can use the update method to update the properties of vertices and edges, excluding the primary key (note that for edges, the values of SortedKeys-related properties constitute the primary key).

@corgy-w

corgy-w commented Nov 26, 2025

Copy link
Copy Markdown
Contributor

Are upsert operations supported now? Does writing graph data need to support upsert?

The hugegraph-client natively supports upsert operations. For update operations, you can use the update method to update the properties of vertices and edges, excluding the primary key (note that for edges, the values of SortedKeys-related properties constitute the primary key).

get

@corgy-w corgy-w left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

THX

@davidzollo davidzollo left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+1
Good job

@davidzollo davidzollo merged commit 1a73b93 into apache:dev Nov 27, 2025
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Feature][Connector-V2] Support sink connector for HugeGraph

4 participants