Skip to content

Commit

Permalink
special-case AsTable
Browse files Browse the repository at this point in the history
  • Loading branch information
pdeffebach committed Oct 31, 2023
1 parent 51c2792 commit a12716b
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/parsing.jl
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ returns `nothing`.
get_column_expr(x) = nothing
function get_column_expr(e::Expr)
e.head == :$ && return e.args[1]
onearg(e, :AsTable) && return e
onearg(e, :AsTable) && return :($AsTable($(e.args[2])))
if onearg(e, :cols)
Base.depwarn("cols is deprecated use $DOLLAR to escape column names instead", :cols)
return e.args[2]
Expand Down
4 changes: 2 additions & 2 deletions test/import.jl
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ import DataFramesMeta
@test t == DataFrames.DataFrame(a = [1, 2, 3], b = [1, 1, 1], c = [2, 2, 2])

# AsTable on the RHS relies on the literal "AsTable" appearing
# so we test that this throws an error
@test_throws UndefVarError t = DataFramesMeta.@transform df :c = sum(AsTable([:a]))
t = DataFramesMeta.@rtransform df :c = sum(AsTable([:a]))
@test t == DataFrames.DataFrame(a = [1, 2, 3], c = [1, 2, 3])

# And confusingly, if you use DataFrames.AsTable on the RHS, none of the
# special escaping happens.
Expand Down

0 comments on commit a12716b

Please sign in to comment.