Coder Social home page Coder Social logo

Comments (5)

jexp avatar jexp commented on May 31, 2024

Sure there is a loadDataFrame method that takes a schema:

scala> import org.neo4j.spark._
import org.neo4j.spark._

scala> val neo = Neo4j(sc)
neo: org.neo4j.spark.Neo4j = org.neo4j.spark.Neo4j@750cd36d

scala> val df = neo.cypher("match (n) return id(n) as id1, id(n) as id2").partitions(4).batch(100).loadDataFrame(("id1"->"int"),("id2"->"int"))
df: org.apache.spark.sql.DataFrame = [id1: bigint, id2: bigint]

scala> df.take(3)
res2: Array[org.apache.spark.sql.Row] = Array([0,0], [1,1], [2,2])

from neo4j-spark-connector.

jexp avatar jexp commented on May 31, 2024

But it also work with just the query (it inspects the result metadata then)

val df = neo.cypher("match (n) return id(n) as id1, id(n) as id2").partitions(4).batch(100).loadDataFrame
df: org.apache.spark.sql.DataFrame = [id1: bigint, id2: bigint]

from neo4j-spark-connector.

sjishan avatar sjishan commented on May 31, 2024

Thanks. Solved.

from neo4j-spark-connector.

anks2024 avatar anks2024 commented on May 31, 2024

@jexp

scala> val df = neo.cypher("match (n:Emp) return id(n) as id, n.name as name, n.dept as dept").loadDataFrame(("id"->"long"),("name"->"string"),("dept"->"long"))
df: org.apache.spark.sql.DataFrame = [id: bigint, name: string ... 1 more field]

scala> df.count()
res15: Long = 28 // When I have only 7 nodes in my Graph. Any specific reason for this repetitions?

from neo4j-spark-connector.

jexp avatar jexp commented on May 31, 2024

@asarraf What happens if you run the same query as Cypher in Neo4j?

from neo4j-spark-connector.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.