You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I was trying to find a way to programmatically generate a query by splatting a list of symbols into an @select. I found that the splat ... syntax, (or any objects containing whitespace or hyphens generated with the Symbol function for that matter), generated errors, though passing a variable with a list of symbols of any sort does seem to work.
Example:
using DataFrames
myDict =Dict()
myDict["aKey"] =1:10
myDict["anotherKey"] =zeros(10)
myDict["a_nice_key"] =rand(Bool, 10)
myDict["a nasty key"] =fill("oof", 10)
df =DataFrame(myDict)
using DataFramesMeta, Lazy
colsOfInterest = [:anotherKey, :a_nice_key]
# Splatting errors, even though went you write out what the splat "evaluates to", it works.#=x = @> begin df @where(:aKey .< 4) @select(colsOfInterest...)end=## This also errors:#=x = @> begin df @where(:aKey .< 4) @select(:a_nice_key, Symbol("a nasty key"))end=## This surprisingly does not error:pushfirst!(colsOfInterest, Symbol("a nasty key"))
x = @>begin
df
@where(:aKey.<4)
@select(colsOfInterest)
end
The text was updated successfully, but these errors were encountered:
At some point, when this package is maintained, it should be decided what is best to do in these cases. For the time being here is what you should pass in two of cases that error for you to make them work:
# first error
x = @> begin
df
@where(:aKey .< 4)
@select(colsOfInterest)
end
# second error
x = @> begin
df
@where(:aKey .< 4)
@select(:a_nice_key, :var"a nasty key")
end
Cross-post from discourse, at the request of @pdeffebach.
I was trying to find a way to programmatically generate a query by splatting a list of symbols into an
@select
. I found that the splat...
syntax, (or any objects containing whitespace or hyphens generated with theSymbol
function for that matter), generated errors, though passing a variable with a list of symbols of any sort does seem to work.Example:
The text was updated successfully, but these errors were encountered: