neo4j / graph-data-science

Source code for the Neo4j Graph Data Science library of graph algorithms.
https://neo4j.com/docs/graph-data-science/current/
Other
629 stars 161 forks source link

Error while creating a graph: Graph creation failed Unsupported type [TEXT] #31

Closed karrtikiyer closed 4 years ago

karrtikiyer commented 4 years ago

Neo4J DB Version -3.5.17 Enterprise Graph Data Science Library -1.1.0 CALL gds.graph.create.cypher( 'my-cypher-graph', 'MATCH (n) WHERE n:ROLE OR n:SKILL OR n:PERSON RETURN id(n) AS id, n.name AS name', 'MATCH (n:ROLE)-[r:WORKS_AS]-(p:PERSON)-[s:SKILLED_IN]-(m:SKILL) RETURN id(n) AS source, id(m) AS target, r.cost+s.cost as cost' ) Error Log: 2020-04-18 13:54:40.253+0000 WARN Graph creation failed Unsupported type [TEXT] of value Director of Finance Systems. Please use a numeric property. java.lang.IllegalArgumentException: Unsupported type [TEXT] of value Director of Finance Systems. Please use a numeric property. at org.neo4j.graphalgo.core.loading.NodeRowVisitor.processProperties(NodeRowVisitor.java:153) at org.neo4j.graphalgo.core.loading.NodeRowVisitor.visit(NodeRowVisitor.java:81) at org.neo4j.cypher.internal.compatibility.v3_5.runtime.executionplan.StandardInternalExecutionResult$$anon$4.visit(StandardInternalExecutionResult.scala:178) at org.neo4j.cypher.internal.runtime.RuntimeJavaValueConverter$feedQueryResultRecordIteratorToVisitable.accept(RuntimeJavaValueConverter.scala:65) at org.neo4j.cypher.internal.compatibility.v3_5.runtime.PipeExecutionResult.accept(PipeExecutionResult.scala:74) at org.neo4j.cypher.internal.compatibility.v3_5.runtime.executionplan.StandardInternalExecutionResult.accept(StandardInternalExecutionResult.scala:192) at org.neo4j.cypher.internal.compatibility.v3_5.runtime.executionplan.StandardInternalExecutionResult.accept(StandardInternalExecutionResult.scala:170) at org.neo4j.cypher.internal.compatibility.ClosingExecutionResult$$anonfun$accept$1.apply$mcV$sp(ClosingExecutionResult.scala:153) at org.neo4j.cypher.internal.compatibility.ClosingExecutionResult$$anonfun$accept$1.apply(ClosingExecutionResult.scala:153) at org.neo4j.cypher.internal.compatibility.ClosingExecutionResult$$anonfun$accept$1.apply(ClosingExecutionResult.scala:153) at org.neo4j.cypher.internal.compatibility.ClosingExecutionResult$$anonfun$safelyAndClose$1.apply(ClosingExecutionResult.scala:171) at org.neo4j.cypher.exceptionHandler$runSafely$.apply(exceptionHandler.scala:89) at org.neo4j.cypher.internal.compatibility.ClosingExecutionResult.safelyAndClose(ClosingExecutionResult.scala:174) at org.neo4j.cypher.internal.compatibility.ClosingExecutionResult.accept(ClosingExecutionResult.scala:152) at org.neo4j.cypher.internal.javacompat.ExecutionResult.accept(ExecutionResult.java:313) at org.neo4j.graphalgo.core.loading.CypherNodeLoader.loadSingleBatch(CypherNodeLoader.java:106) at org.neo4j.graphalgo.core.loading.CypherRecordLoader.lambda$load$0(CypherRecordLoader.java:76) at org.neo4j.graphalgo.core.loading.CypherFactory$Ktx.run(CypherFactory.java:176) at org.neo4j.graphalgo.core.loading.CypherRecordLoader.load(CypherRecordLoader.java:76) at org.neo4j.graphalgo.core.loading.CypherFactory.build(CypherFactory.java:92) at org.neo4j.graphalgo.catalog.GraphCreateProc.createGraph(GraphCreateProc.java:162) at org.neo4j.graphalgo.catalog.GraphCreateProc.lambda$create$1(GraphCreateProc.java:130) at org.neo4j.graphalgo.BaseProc.runWithExceptionLogging(BaseProc.java:87) at org.neo4j.graphalgo.catalog.GraphCreateProc.create(GraphCreateProc.java:128) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:498) at org.neo4j.kernel.impl.proc.ReflectiveProcedureCompiler$ReflectiveProcedure.apply(ReflectiveProcedureCompiler.java:664) at org.neo4j.kernel.impl.proc.ProcedureRegistry.callProcedure(ProcedureRegistry.java:219) at org.neo4j.kernel.impl.proc.Procedures.callProcedure(Procedures.java:290) at org.neo4j.kernel.impl.newapi.AllStoreHolder.callProcedure(AllStoreHolder.java:1098) at org.neo4j.kernel.impl.newapi.AllStoreHolder.procedureCallRead(AllStoreHolder.java:863) at org.neo4j.cypher.internal.runtime.interpreted.CallSupport$$anonfun$2.apply(CallSupport.scala:62) at org.neo4j.cypher.internal.runtime.interpreted.CallSupport$$anonfun$2.apply(CallSupport.scala:62) at org.neo4j.cypher.internal.runtime.interpreted.CallSupport$.callProcedure(CallSupport.scala:167) at org.neo4j.cypher.internal.runtime.interpreted.CallSupport$.callReadOnlyProcedure(CallSupport.scala:64) at org.neo4j.cypher.internal.runtime.interpreted.TransactionBoundQueryContext.callReadOnlyProcedure(TransactionBoundQueryContext.scala:974) at org.neo4j.cypher.internal.compatibility.v3_5.ExceptionTranslatingQueryContext$$anonfun$callReadOnlyProcedure$1.apply(ExceptionTranslatingQueryContext.scala:166) at org.neo4j.cypher.internal.compatibility.v3_5.ExceptionTranslatingQueryContext$$anonfun$callReadOnlyProcedure$1.apply(ExceptionTranslatingQueryContext.scala:166) at org.neo4j.cypher.internal.compatibility.v3_5.ExceptionTranslationSupport$class.translateException(ExceptionTranslationSupport.scala:33) at org.neo4j.cypher.internal.compatibility.v3_5.ExceptionTranslatingQueryContext.translateException(ExceptionTranslatingQueryContext.scala:42) at org.neo4j.cypher.internal.compatibility.v3_5.ExceptionTranslationSupport$class.translateIterator(ExceptionTranslationSupport.scala:47) at org.neo4j.cypher.internal.compatibility.v3_5.ExceptionTranslatingQueryContext.translateIterator(ExceptionTranslatingQueryContext.scala:42) at org.neo4j.cypher.internal.compatibility.v3_5.ExceptionTranslatingQueryContext.callReadOnlyProcedure(ExceptionTranslatingQueryContext.scala:166) at org.neo4j.cypher.internal.runtime.LazyReadOnlyCallMode.callProcedure(ProcedureCallMode.scala:48) at org.neo4j.cypher.internal.compatibility.v3_5.runtime.executionplan.procs.ProcedureCallRuntimeResult.executeCall(ProcedureCallRuntimeResult.scala:72) at org.neo4j.cypher.internal.compatibility.v3_5.runtime.executionplan.procs.ProcedureCallRuntimeResult.<init>(ProcedureCallRuntimeResult.scala:66) at org.neo4j.cypher.internal.compatibility.v3_5.runtime.executionplan.procs.ProcedureCallExecutionPlan.run(ProcedureCallExecutionPlan.scala:88) at org.neo4j.cypher.internal.compatibility.CypherCurrentCompiler$CypherExecutableQuery$$anonfun$execute$3.apply(CypherCurrentCompiler.scala:204) at org.neo4j.cypher.internal.compatibility.CypherCurrentCompiler$CypherExecutableQuery$$anonfun$execute$3.apply(CypherCurrentCompiler.scala:190) at org.neo4j.cypher.exceptionHandler$runSafely$.apply(exceptionHandler.scala:89) at org.neo4j.cypher.internal.compatibility.CypherCurrentCompiler$CypherExecutableQuery.execute(CypherCurrentCompiler.scala:223) at org.neo4j.cypher.internal.ExecutionEngine.execute(ExecutionEngine.scala:116) at org.neo4j.cypher.internal.javacompat.ExecutionEngine.executeQuery(ExecutionEngine.java:85) at org.neo4j.bolt.v1.runtime.TransactionStateMachineV1SPI$BoltResultHandleV1.start(TransactionStateMachineV1SPI.java:189) at org.neo4j.bolt.v1.runtime.TransactionStateMachine$State.startExecution(TransactionStateMachine.java:506) at org.neo4j.bolt.v1.runtime.TransactionStateMachine$State$2.run(TransactionStateMachine.java:385) at org.neo4j.bolt.v1.runtime.TransactionStateMachine.run(TransactionStateMachine.java:110) at org.neo4j.bolt.v1.runtime.TransactionStateMachine.run(TransactionStateMachine.java:98) at org.neo4j.bolt.v3.runtime.TransactionReadyState.processRunMessage(TransactionReadyState.java:82) at org.neo4j.bolt.v3.runtime.TransactionReadyState.processUnsafe(TransactionReadyState.java:49) at org.neo4j.bolt.v3.runtime.FailSafeBoltStateMachineState.process(FailSafeBoltStateMachineState.java:48) at org.neo4j.bolt.v1.runtime.BoltStateMachineV1.nextState(BoltStateMachineV1.java:144) at org.neo4j.bolt.v1.runtime.BoltStateMachineV1.process(BoltStateMachineV1.java:92) at org.neo4j.bolt.messaging.BoltRequestMessageReader.lambda$doRead$1(BoltRequestMessageReader.java:89) at org.neo4j.bolt.runtime.MetricsReportingBoltConnection.lambda$enqueue$0(MetricsReportingBoltConnection.java:68) at org.neo4j.bolt.runtime.DefaultBoltConnection.processNextBatch(DefaultBoltConnection.java:191) at org.neo4j.bolt.runtime.MetricsReportingBoltConnection.processNextBatch(MetricsReportingBoltConnection.java:86) at org.neo4j.bolt.runtime.DefaultBoltConnection.processNextBatch(DefaultBoltConnection.java:139) at org.neo4j.bolt.runtime.ExecutorBoltScheduler.executeBatch(ExecutorBoltScheduler.java:171) at org.neo4j.bolt.runtime.ExecutorBoltScheduler.lambda$scheduleBatchOrHandleError$2(ExecutorBoltScheduler.java:154) at java.util.concurrent.CompletableFuture$AsyncSupply.run(CompletableFuture.java:1604) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) at java.lang.Thread.run(Thread.java:748)

tomasonjo commented 4 years ago

Node and relationship properties should be either floats or integers... It seems that you are trying to import a string value in your node query:

MATCH (n) WHERE n:ROLE OR n:SKILL OR n:PERSON RETURN id(n) AS id, n.name AS name

And this is not allowed. If you remove returning the name it will probably work. On a side note, what are you trying to achieve with importing the name property?

karrtikiyer commented 4 years ago

I was trying to follow below example and thought that instead of labels it could be any string property: CALL gds.graph.create.cypher( 'my-cypher-graph', 'MATCH (n) WHERE n:Author OR n:Article OR n:Book RETURN id(n) AS id, labels(n) AS labels', 'MATCH (n:Author)-[r:WROTE]->(m) RETURN id(n) AS source, id(m) AS target' )

tomasonjo commented 4 years ago

Node query has a designated property labels, that is actually an array of strings and can be later used to filter nodes with nodeLabels parameter. Relationship query similarly has a designated property type. All other properties should be a number.

Mats-SX commented 4 years ago

It is true that the label could be any string value (such as from a property), but it has to go into the labels return item. For example:

MATCH (n) 
  WHERE n:ROLE OR n:SKILL OR n:PERSON 
RETURN id(n) AS id, [n.name] AS labels

However, while valid, I would not expect this projection query to give good results. Labels are typically used to define groups of nodes, and I wouldn't expect names to correlate with groups, as names are typically more unique.

With only limited knowledge of your graph model, I would expect that this is a better projection query:

MATCH (n) 
  WHERE n:ROLE OR n:SKILL OR n:PERSON 
RETURN id(n) AS id, labels(n) AS labels