neo4j-rstats/neo4r

Subscript out of bounds with what looks like returning relationship properties using Movie Graph

dfgit opened this issue · 3 comments

dfgit commented

Seems to be tied to relationships with properties. Have other examples of same type of error that seem to be the same root cause

res<-"MATCH (people:Person)-[relatedTo]-(:Movie {title: 'Cloud Atlas'}) RETURN people.name, Type(relatedTo), relatedTo" %>%
  call_neo4j(con, type = 'row')

Should return

╒══════════════════╤═════════════════╤══════════════════════════════════════════════════════════════════════╕
│"people.name"     │"type(relatedTo)"│"relatedTo"                                                           │
╞══════════════════╪═════════════════╪══════════════════════════════════════════════════════════════════════╡
│"Hugo Weaving"    │"ACTED_IN"       │{"roles":["Bill Smoke","Haskell Moore","Tadeusz Kesselring","Nurse Noa│
│                  │                 │kes","Boardman Mephi","Old Georgie"]}                                 │
├──────────────────┼─────────────────┼──────────────────────────────────────────────────────────────────────┤
│"Jessica Thompson"│"REVIEWED"       │{"summary":"An amazing journey","rating":95}                          │
├──────────────────┼─────────────────┼──────────────────────────────────────────────────────────────────────┤
│"Stefan Arndt"    │"PRODUCED"       │{}                                                                    │
├──────────────────┼─────────────────┼──────────────────────────────────────────────────────────────────────┤
│"Tom Hanks"       │"ACTED_IN"       │{"roles":["Zachry","Dr. Henry Goose","Isaac Sachs","Dermot Hoggins"]} │
├──────────────────┼─────────────────┼──────────────────────────────────────────────────────────────────────┤
│"Jim Broadbent"   │"ACTED_IN"       │{"roles":["Vyvyan Ayrs","Captain Molyneux","Timothy Cavendish"]}      │
├──────────────────┼─────────────────┼──────────────────────────────────────────────────────────────────────┤
│"Halle Berry"     │"ACTED_IN"       │{"roles":["Luisa Rey","Jocasta Ayrs","Ovid","Meronym"]}               │
├──────────────────┼─────────────────┼──────────────────────────────────────────────────────────────────────┤
│"Lilly Wachowski" │"DIRECTED"       │{}                                                                    │
├──────────────────┼─────────────────┼──────────────────────────────────────────────────────────────────────┤
│"David Mitchell"  │"WROTE"          │{}                                                                    │
├──────────────────┼─────────────────┼──────────────────────────────────────────────────────────────────────┤
│"Tom Tykwer"      │"DIRECTED"       │{}                                                                    │
├──────────────────┼─────────────────┼──────────────────────────────────────────────────────────────────────┤
│"Lana Wachowski"  │"DIRECTED"       │{}                                                                    │

Instead get subscript out of bonds error

Error in .x[[i]] : subscript out of bounds

last_error

> rlang::last_error()
<error>
message: Each column must either be a list of vectors or a list of data frames [roles]
class:   `rlang_error`
backtrace:
 1. neo4r::unnest_relationships(res$relationships)
 3. tidyr:::unnest.data.frame(relationships_tbl)
Call `rlang::last_trace()` to see the full backtrace

> rlang::last_trace()
    █
 1. └─neo4r::unnest_relationships(res$relationships)
 2.   ├─tidyr::unnest(relationships_tbl)
 3.   └─tidyr:::unnest.data.frame(relationships_tbl)

Traceback

30. $is_atomic(.x)
29. $modify_depth_rec(x, .depth - 1, .f, ..., .ragged = .ragged, .atomic = .atomic)
28. $.f(.x[[i]], ...)
27. $modify.default(.x, function(x) { modify_depth_rec(x, .depth - 1, .f, ..., .ragged = .ragged, .atomic = .atomic) })
26. $modify(.x, function(x) { modify_depth_rec(x, .depth - 1, .f, ..., .ragged = .ragged, .atomic = .atomic) })
25. $modify_depth_rec(x, .depth - 1, .f, ..., .ragged = .ragged, .atomic = .atomic)
24. $.f(.x[[i]], ...)
23. $modify.default(.x, function(x) { modify_depth_rec(x, .depth - 1, .f, ..., .ragged = .ragged, .atomic = .atomic) })
22. $modify(.x, function(x) { modify_depth_rec(x, .depth - 1, .f, ..., .ragged = .ragged, .atomic = .atomic) })
21. $modify_depth_rec(x, .depth - 1, .f, ..., .ragged = .ragged, .atomic = .atomic)
20. $.f(.x[[i]], ...)
19. $modify.default(.x, function(x) { modify_depth_rec(x, .depth - 1, .f, ..., .ragged = .ragged, .atomic = .atomic) })
18. $modify(.x, function(x) { modify_depth_rec(x, .depth - 1, .f, ..., .ragged = .ragged, .atomic = .atomic) })
17. $modify_depth_rec(x, .depth - 1, .f, ..., .ragged = .ragged, .atomic = .atomic)
16. $.f(.x[[i]], ...)
15. $modify.default(.x, function(x) { modify_depth_rec(x, .depth - 1, .f, ..., .ragged = .ragged, .atomic = .atomic) })
14. $modify(.x, function(x) { modify_depth_rec(x, .depth - 1, .f, ..., .ragged = .ragged, .atomic = .atomic) })
13. $modify_depth_rec(.x, .depth, .f, ..., .ragged = .ragged, .atomic = FALSE)
12. $modify_depth.default(results, vec_depth(results) - 1, function(x) { if (is.null(x)) { NA } ... $11. $modify_depth(results, vec_depth(results) - 1, function(x) { if (is.null(x)) { NA } ... $10. $parse_api_results(res = res, type = type, format = format, include_stats = include_stats, meta = include_meta)
9. $call_neo4j(., con, type = "row")
8. $function_list[[k]](value)
7. $withVisible(function_list[[k]](value))
6. $freduce(value, `_function_list`)
5. $`_fseq`(`_lhs`)
4. $eval(quote(`_fseq`(`_lhs`)), env, env)
3. $eval(quote(`_fseq`(`_lhs`)), env, env)
2. $withVisible(eval(quote(`_fseq`(`_lhs`)), env, env))
1. $"MATCH (people:Person)-[relatedTo]-(:Movie {title: 'Cloud Atlas'}) RETURN people.name, Type(relatedTo), relatedTo" %>% call_neo4j(con, type = "row")

Fixed with last commit.

library(neo4r)
con <- neo4j_api$new(url = "http://localhost:7474", 
                     user = "neo4j", password = "neo4j")
                     
"MATCH (people:Person)-[relatedTo]-(:Movie {title: 'Cloud Atlas'}) RETURN people.name, Type(relatedTo), relatedTo" %>%
  call_neo4j(con, type = 'row')
#> $people.name
#> # A tibble: 20 x 1
#>    value           
#>    <chr>           
#>  1 Jessica Thompson
#>  2 Stefan Arndt    
#>  3 Lana Wachowski  
#>  4 David Mitchell  
#>  5 Tom Tykwer      
#>  6 Lilly Wachowski 
#>  7 Halle Berry     
#>  8 Jim Broadbent   
#>  9 Tom Hanks       
#> 10 Hugo Weaving    
#> 11 Lana Wachowski  
#> 12 Lilly Wachowski 
#> 13 Stefan Arndt    
#> 14 David Mitchell  
#> 15 Jessica Thompson
#> 16 Tom Tykwer      
#> 17 Jim Broadbent   
#> 18 Halle Berry     
#> 19 Hugo Weaving    
#> 20 Tom Hanks       
#> 
#> $`Type(relatedTo)`
#> # A tibble: 20 x 1
#>    value   
#>    <chr>   
#>  1 REVIEWED
#>  2 PRODUCED
#>  3 DIRECTED
#>  4 WROTE   
#>  5 DIRECTED
#>  6 DIRECTED
#>  7 ACTED_IN
#>  8 ACTED_IN
#>  9 ACTED_IN
#> 10 ACTED_IN
#> 11 DIRECTED
#> 12 DIRECTED
#> 13 PRODUCED
#> 14 WROTE   
#> 15 REVIEWED
#> 16 DIRECTED
#> 17 ACTED_IN
#> 18 ACTED_IN
#> 19 ACTED_IN
#> 20 ACTED_IN
#> 
#> $relatedTo
#> # A tibble: 36 x 3
#>    summary            rating roles    
#>    <chr>               <int> <list>   
#>  1 An amazing journey     95 <NULL>   
#>  2 <NA>                   NA <chr [1]>
#>  3 <NA>                   NA <chr [1]>
#>  4 <NA>                   NA <chr [1]>
#>  5 <NA>                   NA <chr [1]>
#>  6 <NA>                   NA <chr [1]>
#>  7 <NA>                   NA <chr [1]>
#>  8 <NA>                   NA <chr [1]>
#>  9 <NA>                   NA <chr [1]>
#> 10 <NA>                   NA <chr [1]>
#> # … with 26 more rows
#> 
#> attr(,"class")
#> [1] "neo"  "neo"  "list"

Created on 2019-03-03 by the reprex package (v0.2.1)

Session info
devtools::session_info()
#> ─ Session info ──────────────────────────────────────────────────────────
#>  setting  value                       
#>  version  R version 3.4.4 (2018-03-15)
#>  os       macOS  10.14                
#>  system   x86_64, darwin15.6.0        
#>  ui       X11                         
#>  language (EN)                        
#>  collate  en_US.UTF-8                 
#>  ctype    en_US.UTF-8                 
#>  tz       Europe/Paris                
#>  date     2019-03-03                  
#> 
#> ─ Packages ──────────────────────────────────────────────────────────────
#>  package     * version    date       lib source                          
#>  assertthat    0.2.0      2017-04-11 [1] CRAN (R 3.4.0)                  
#>  attempt       0.2.1      2018-04-20 [1] CRAN (R 3.4.4)                  
#>  backports     1.1.3      2018-12-14 [1] CRAN (R 3.4.4)                  
#>  base64enc     0.1-3      2015-07-28 [1] CRAN (R 3.4.0)                  
#>  callr         3.0.0      2018-08-24 [1] CRAN (R 3.4.4)                  
#>  cli           1.0.1      2018-09-25 [1] CRAN (R 3.4.4)                  
#>  crayon        1.3.4      2017-09-16 [1] CRAN (R 3.4.1)                  
#>  curl          3.3        2019-01-10 [1] CRAN (R 3.4.4)                  
#>  data.table    1.12.0     2019-01-13 [1] CRAN (R 3.4.4)                  
#>  debugme       1.1.0      2017-10-22 [1] CRAN (R 3.4.2)                  
#>  desc          1.2.0      2018-05-01 [1] CRAN (R 3.4.4)                  
#>  devtools      2.0.0.9000 2018-10-29 [1] Github (r-lib/devtools@4953bd6) 
#>  digest        0.6.18     2018-10-10 [1] CRAN (R 3.4.4)                  
#>  evaluate      0.12       2018-10-09 [1] CRAN (R 3.4.4)                  
#>  fansi         0.4.0      2018-10-05 [1] CRAN (R 3.4.4)                  
#>  fs            1.2.6      2018-08-23 [1] CRAN (R 3.4.4)                  
#>  glue          1.3.0      2018-07-17 [1] RSPM (R 3.4.4)                  
#>  highr         0.7        2018-06-09 [1] CRAN (R 3.4.4)                  
#>  htmltools     0.3.6      2017-04-28 [1] CRAN (R 3.4.0)                  
#>  httpuv        1.4.5.9002 2019-01-09 [1] Github (rstudio/httpuv@14f0b97) 
#>  httr          1.4.0      2018-12-11 [1] CRAN (R 3.4.4)                  
#>  jsonlite      1.6        2018-12-07 [1] CRAN (R 3.4.4)                  
#>  knitr         1.21       2018-12-10 [1] CRAN (R 3.4.4)                  
#>  later         0.7.5.9001 2019-01-30 [1] Github (r-lib/later@5e3a07c)    
#>  magrittr      1.5        2014-11-22 [1] CRAN (R 3.4.0)                  
#>  memoise       1.1.0      2017-04-21 [1] CRAN (R 3.4.0)                  
#>  mime          0.6        2018-10-05 [1] CRAN (R 3.4.4)                  
#>  neo4r       * 0.1.2      2019-03-03 [1] local                           
#>  pillar        1.3.1      2018-12-15 [1] CRAN (R 3.4.4)                  
#>  pkgbuild      1.0.2      2018-10-16 [1] CRAN (R 3.4.4)                  
#>  pkgconfig     2.0.2      2018-08-16 [1] CRAN (R 3.4.4)                  
#>  pkgload       1.0.1      2018-10-11 [1] CRAN (R 3.4.4)                  
#>  prettyunits   1.0.2      2015-07-13 [1] CRAN (R 3.4.0)                  
#>  processx      3.2.0      2018-08-16 [1] CRAN (R 3.4.4)                  
#>  promises      1.0.1      2018-04-13 [1] CRAN (R 3.4.4)                  
#>  ps            1.2.0      2018-10-16 [1] CRAN (R 3.4.4)                  
#>  purrr         0.3.0      2019-01-27 [1] CRAN (R 3.4.4)                  
#>  R6            2.3.0      2018-10-04 [1] CRAN (R 3.4.4)                  
#>  Rcpp          1.0.0      2018-11-07 [1] CRAN (R 3.4.4)                  
#>  remotes       2.0.2      2018-10-30 [1] CRAN (R 3.4.4)                  
#>  rlang         0.3.1      2019-01-08 [1] CRAN (R 3.4.4)                  
#>  rmarkdown     1.10       2018-06-11 [1] CRAN (R 3.4.4)                  
#>  rprojroot     1.3-2      2018-01-03 [1] CRAN (R 3.4.3)                  
#>  rstudioapi    0.9.0      2019-01-09 [1] CRAN (R 3.4.4)                  
#>  sessioninfo   1.1.0      2018-09-25 [1] CRAN (R 3.4.4)                  
#>  shiny         1.2.0      2018-11-02 [1] CRAN (R 3.4.4)                  
#>  stringi       1.2.4      2018-07-20 [1] CRAN (R 3.4.4)                  
#>  stringr       1.3.1      2018-05-10 [1] CRAN (R 3.4.4)                  
#>  testthat      2.0.0.9000 2018-07-20 [1] Github (r-lib/testthat@d43ed65) 
#>  tibble        2.0.1      2019-01-12 [1] CRAN (R 3.4.4)                  
#>  tidyr         0.8.2      2018-10-28 [1] CRAN (R 3.4.4)                  
#>  usethis       1.4.0      2018-08-14 [1] CRAN (R 3.4.4)                  
#>  utf8          1.1.4      2018-05-24 [1] CRAN (R 3.4.4)                  
#>  withr         2.1.2.9000 2018-10-29 [1] Github (jimhester/withr@be57595)
#>  xfun          0.5        2019-02-20 [1] CRAN (R 3.4.4)                  
#>  xtable        1.8-3      2018-08-29 [1] CRAN (R 3.4.4)                  
#>  yaml          2.2.0      2018-07-25 [1] CRAN (R 3.4.4)                  
#> 
#> [1] /Library/Frameworks/R.framework/Versions/3.4/Resources/library

Working

I'm limited to using only the CRAN version of this package (0.1.1) where this error still persists.
Is there a workaround for those who cannot install the newer versions from gitlab?