RickyHuo commented on a change in pull request #1028: URL: https://github.com/apache/incubator-seatunnel/pull/1028#discussion_r786649117
########## File path: seatunnel-connectors/seatunnel-connector-spark-neo4j/src/main/scala/org/apache/seatunnel/spark/source/Neo4j.scala ########## @@ -0,0 +1,57 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.seatunnel.spark.source + +import org.apache.seatunnel.common.config.{CheckConfigUtil, CheckResult} +import org.apache.seatunnel.spark.SparkEnvironment +import org.apache.seatunnel.spark.batch.SparkBatchSource +import org.apache.spark.sql.{DataFrameReader, Dataset, Row} + +import scala.collection.JavaConverters._ +import scala.collection.mutable + +class Neo4j extends SparkBatchSource { + + val neo4jConf: mutable.Map[String, String] = mutable.Map() + val readFormatter: String = "org.neo4j.spark.DataSource" + + + override def getData(env: SparkEnvironment): Dataset[Row] = { + val read: DataFrameReader = env.getSparkSession.read + read.format(readFormatter) + neo4jConf.foreach(it => { + read.option(it._1, it._2) + }) + read.load() + + } + + override def checkConfig(): CheckResult = { + + val checkALL: CheckResult = CheckConfigUtil.checkOne(config, "query", "labels", "relationship") + val checkOne: CheckResult = CheckConfigUtil.check(config, "result_table_name", "url") Review comment: The variable name is confused. ########## File path: docs/en/spark/configuration/source-plugins/neo4j.md ########## @@ -0,0 +1,137 @@ +# Source plugin: Neo4j [Spark] + +## Description + +Read data from Neo4j. + +Neo4j Connector for Apache Spark allows you to read data from Neo4j in 3 different ways: by node labels, by relationship name, and by direct Cypher query. + +The Options required of yes* means that you must specify one way of (query labels relationship) + +for detail neo4j config message please visit [neo4j doc](#https://neo4j.com/docs/spark/current/reading/) + + + +## Options + +| name | type | required | default value | +| -------------------------------------------------------------------------| ------ | -------- | ------------- | +| [result_table_name](#result.table.name-string) | string | yes | - | +| [authentication.type](#authentication.type-string) | string | no | - | +| [authentication.basic.username](#authentication.basic.username-string) | string | no | - | +| [authentication.basic.password](#authentication.basic.password-string) | string | no | - | +| [url](#url-string) | string | yes | - | +| [query](#query-string) | string | yes* | - | +| [labels](#labels-string) | string | yes* | - | +| [relationship](#relationship-string) | string | yes* | - | +| [schema.flatten.limit](#schema.flatten.limit-string) | string | no | - | +| [schema.strategy](#schema.strategy-string) | string | no | - | +| [pushdown.filters.enabled](#pushdown.filters.enabled-string) | string | no | - | +| [pushdown.columns.enabled](#pushdown.columns.enabled-string) | string | no | - | +| [partitions](#partitions-string) | string | no | - | +| [query.count](#query.count-string) | string | no | - | +| [relationship.nodes.map](#relationship.nodes.map-string) | string | no | - | +| [relationship.source.labels](#relationship.source.labels-string) | string | Yes | - | +| [relationship.target.labels](#relationship.target.labels-string) | string | Yes | - | + +### result.table.name [string] + +result table name + +### authentication.type [string] + +authentication type + +### authentication.basic.username [string] + +username + +### authentication.basic.password [string] + +password + +### url [string] +url + +### query [string] + +Cypher query to read the data. you must specify one way of (query labels relationship) + +### labels [string] + +List of node labels separated by : The first label will be the primary label. you must specify one way of (query labels relationship) + +### relationship [string] + +Name of a relationship. you must specify one way of (query labels relationship) Review comment: You must specify one option from [query, labels OR relationship] Just a suggestion :) -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
