neo4j-rstats / neo4r

A Modern and Flexible Neo4J Driver
https://neo4j-rstats.github.io/user-guide/
Other
106 stars 29 forks source link

when the result comes back with a null, the null gets ignored. #41

Closed RMHogervorst closed 5 years ago

RMHogervorst commented 5 years ago

I'm using the game of thrones dataset and ask back the relationships per book

MATCH ()-[r]->()
 RETURN r.book as book, count(r) ORDER BY book

The browser returns a table

╒══════╤══════════╕ │"book"│"count(r)"│ ╞══════╪══════════╡ │1 │684 │ ├──────┼──────────┤ │2 │775 │ ├──────┼──────────┤ │3 │1008 │ ├──────┼──────────┤ │45 │1329 │ ├──────┼──────────┤ │null │2823 │ └──────┴──────────┘

neo4r seems to ignore the null, but can't return a data frame either because of the unequal lengths, so it returns a list with a tibble of nrow 4 and a tibble with nrow 5

ColinFay commented 5 years ago

Ah, thanks @RMHogervorst for opening that issue!

Can you confirm this : https://github.com/neo4j-examples/game-of-thrones is the example you're playing with?

ColinFay commented 5 years ago

I wonder what the output should be in that case.

Does the null here account for books without an ID? (so it should be NA)

ColinFay commented 5 years ago

i think NA would work for null there

RMHogervorst commented 5 years ago

Yes NA would be better here

ColinFay commented 5 years ago

Hey,

null are now turned to NA through https://github.com/neo4j-rstats/neo4r/blob/master/R/api_result_parsing.R#L25

library(neo4r)
con <- neo4j_api$new(url = "http://localhost:7474", 
                     user = "neo4j", password = "neo4j")

'MATCH ()-[r]->()
 RETURN r.book as book, count(r) ORDER BY book' %>%
  call_neo4j(con)

$book
# A tibble: 1 x 1
  value
  <lgl>
1 NA   

$`count(r)`
# A tibble: 1 x 1
  value
  <int>
1  1485

attr(,"class")
[1] "neo"  "neo"  "list"

Which seems to be the desired behavior.

Does it sound good to you?

RMHogervorst commented 5 years ago

yes!