-
Notifications
You must be signed in to change notification settings - Fork 35
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Base.Meta.ParseError("extra token after end of expression") #161
Comments
Thank you very much for the feedback! The error message is about parsing, so I suspect the issue is the formatting of the julia command. Actually, it works for me if we define the query in a separate string and then pass the string to the function like this:
And I suggest this approach whenever we nest some multi-line julia command string in R code. And I see that you are trying to benchmark the code. |
Thanks! I've managed to find a way to make it work. This works: query_a <- "
x = @from i in mtcars begin
@where i.disp > 200
@select {i.mpg, i.cyl}
@collect DataFrame
end
"
julia_command(query_a) However, this does not work: query_b <- "
x = @from i in mtcars begin
@where i.disp > 200
@select {i.mpg, i.cyl}
@collect DataFrame
end
"
julia_command(query_b) It seems like white space is somehow very important here when parsing strings. If one looks at the two r$> query_a
[1] "\nx = @from i in mtcars begin\n @where i.disp > 200\n @select {i.mpg, i.cyl}\n @collect DataFrame\nend\n"
r$> query_b
[1] "\n x = @from i in mtcars begin\n @where i.disp > 200\n @select {i.mpg, i.cyl}\n @collect DataFrame\n end\n " If the problem is known, and specifically perhaps to do with the white space at the end of EditThe issue is the trailing white space. This works: library(stringi)
query <- stri_trim_both("
x = @from i in mtcars begin
@where i.disp > 200
@select {i.mpg, i.cyl}
@collect DataFrame
end
")
julia_eval(query)
I have a way forward to not have to worry too much about this now. However, it still might be useful for others if On a related note, is there a faster way to do this than using |
Thank you very much for exploring on this!
From the above link to the performance tips, you can see that the julia performance tip really emphasize on writing functions, which is also the case for JuliaCall.
And when you evaluate the above, you should see
The In summary, we can benchmark the different methods roughly like this:
There is also some note for the different methods. Hope the information is helpful. I think I will further write this information out like a vignette or something. |
Thanks! That's a tonne of good information. I really appreciate it. Everything looks good, apart from one thing. This sequence does not work: julia_command("
function queryjl(mtcars)
x = @from i in mtcars begin
@where i.disp > 200
@select {i.mpg, i.cyl}
@collect DataFrame
x
end
end")
julia_command("queryjl(mtcars);") Results in: UndefVarError: mtcars not defined
Stacktrace:
[1] top-level scope at none:1
[2] eval(::Module, ::Any) at ./boot.jl:331
[3] eval_string(::String) at /home/phillc/R/x86_64-pc-linux-gnu-library/4.0/JuliaCall/julia/setup.jl:203
[4] docall(::Ptr{Nothing}) at /home/phillc/R/x86_64-pc-linux-gnu-library/4.0/JuliaCall/julia/setup.jl:176 However, both of these do return the correct result: julia_call("queryjl", mtcars)
mtcars_julia_object <- JuliaObject(mtcars)
julia_call("queryjl", mtcars_julia_object) |
In |
I was trying to benchmark some JuliaCall code against native R code. The JuliaCall standalone code works, but when trying to include this in a
microbenchmark
an error is returned.This works:
This fails:
Error is:
R sessionInfo()
The text was updated successfully, but these errors were encountered: