-
Notifications
You must be signed in to change notification settings - Fork 1.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Feature][Connector-v2] Neo4j source connector #2777
Conversation
hi, thanks for your contribution, could you add the e2e test for this PR? https://github.com/apache/incubator-seatunnel/tree/dev/seatunnel-e2e |
public static final String PLUGIN_NAME = "Neo4j"; | ||
|
||
public static final String KEY_NEO4J_URI = "uri"; | ||
public static final String KEY_USERNAME = "username"; | ||
public static final String KEY_PASSWORD = "password"; | ||
public static final String KEY_BEARER_TOKEN = "bearer_token"; | ||
public static final String KEY_KERBEROS_TICKET = "kerberos_ticket"; // Base64 encoded | ||
|
||
public static final String KEY_DATABASE = "database"; | ||
public static final String KEY_QUERY = "query"; | ||
public static final String KEY_MAX_TRANSACTION_RETRY_TIME = "max_transaction_retry_time"; | ||
public static final String KEY_MAX_CONNECTION_TIMEOUT = "max_connection_timeout"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Extract common configuration to Neo4jCommonConfig
?
if (dataType.equals(BasicType.STRING_TYPE)) { | ||
return value.asString(); | ||
} else if (dataType.equals(BasicType.BOOLEAN_TYPE)) { | ||
return value.asBoolean(); | ||
} else if (dataType.equals(BasicType.LONG_TYPE)) { | ||
return value.asLong(); | ||
} else if (dataType.equals(BasicType.DOUBLE_TYPE)) { | ||
return value.asDouble(); | ||
} else if (dataType.equals(BasicType.VOID_TYPE)) { | ||
return null; | ||
} else if (dataType.equals(PrimitiveByteArrayType.INSTANCE)) { | ||
return value.asByteArray(); | ||
} else if (dataType.equals(LocalTimeType.LOCAL_DATE_TYPE)) { | ||
return value.asLocalDate(); | ||
} else if (dataType.equals(LocalTimeType.LOCAL_TIME_TYPE)) { | ||
return value.asLocalTime(); | ||
} else if (dataType.equals(LocalTimeType.LOCAL_DATE_TIME_TYPE)) { | ||
return value.asLocalDateTime(); | ||
} else if (dataType instanceof MapType) { | ||
if (!((MapType<?, ?>) dataType).getKeyType().equals(BasicType.STRING_TYPE)) { | ||
throw new IllegalArgumentException("Key Type of MapType must String type"); | ||
} | ||
return value.asMap(); | ||
} else if (dataType.equals(BasicType.INT_TYPE)) { | ||
return value.asInt(); | ||
} else if (dataType.equals(BasicType.FLOAT_TYPE)) { | ||
return value.asFloat(); | ||
} else { | ||
throw new IllegalArgumentException("not supported data type: " + dataType); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use switch(dataType.getSqlType())
?
@hailin0 |
} | ||
neo4jSourceConfig.setQuery(pluginConfig.getString(KEY_QUERY)); | ||
|
||
final CheckResult schemaConfigCheck = CheckConfigUtil.checkAllExists(pluginConfig, SeaTunnelSchema.SCHEMA); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why not use CheckConfigUtil.checkAllExists(pluginConfig, KEY_QUERY, SeaTunnelSchema.SCHEMA)
Objects.requireNonNull(value); | ||
|
||
switch (dataType.getSqlType()) { | ||
case STRING: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you case Neo4j.List
to SqlType.ARRAY
?
// then | ||
Assertions.assertEquals(0, execResult.getExitCode()); | ||
|
||
final Result result = neo4jSession.run("MATCH (a:Person) RETURN a.name, a.age"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please test all of the datatype.
@Test | ||
public void testSource() throws IOException, InterruptedException { | ||
// given | ||
neo4jSession.run("CREATE (a:Person {name: 'foo', age: 10})"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same as above.
Container.ExecResult execResult = executeSeaTunnelSparkJob("/neo4j/fake_to_neo4j.conf"); | ||
|
||
// then | ||
Assertions.assertEquals(0, execResult.getExitCode()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same as the flink e2e.
name=STRING | ||
age=INT |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
query = "MATCH (a:Person) RETURN a.name, a.age" | ||
|
||
schema { | ||
fields { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
FakeSource { | ||
result_table_name = "fake" | ||
schema = { | ||
fields = { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
query = "MATCH (a:Person) RETURN a.name, a.age" | ||
|
||
schema { | ||
fields { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
} | ||
|
||
@Test | ||
public void testSink() throws IOException, InterruptedException { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you test source and sink at the once job?
@EricJoy2048 @hailin0 |
Yes I know. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
...connector-neo4j-spark-e2e/src/test/java/org/apache/seatunnel/e2e/spark/v2/neo4j/Neo4jIT.java
Outdated
Show resolved
Hide resolved
...connector-neo4j-flink-e2e/src/test/java/org/apache/seatunnel/e2e/flink/v2/neo4j/Neo4jIT.java
Outdated
Show resolved
Hide resolved
a.age=INT | ||
a.name=STRING |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Better not to include .
?
e.g.
xxx_age = INT
xxx_name = STRING
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@hailin0
I think the dot(.
) expression is familiar to neo4j users.
because dot means reference of node's property.
is the dot naming in the field forbidden in SeaTunnel?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@hailin0 PTAL
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is the dot naming in the field forbidden in SeaTunnel?
You could use, seatunnel currently has no restrictions on field names
…-spark-e2e/src/test/java/org/apache/seatunnel/e2e/spark/v2/neo4j/Neo4jIT.java Co-authored-by: hailin0 <[email protected]>
…-flink-e2e/src/test/java/org/apache/seatunnel/e2e/flink/v2/neo4j/Neo4jIT.java Co-authored-by: hailin0 <[email protected]>
…onnectorv2-neo4j-source
Hi, @getChan Thanks for your contribution, Please resolve conflicts. |
# Conflicts: # seatunnel-e2e/seatunnel-flink-connector-v2-e2e/pom.xml # seatunnel-e2e/seatunnel-spark-connector-v2-e2e/pom.xml
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
+1
Thanks:) |
Purpose of this pull request
To add Neo4j Source Connector
Check list
New License Guide