queryverse / queryverse/Query.jl

error with @rename macro

Open
#307 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Julia
Stars
403
Forks
48
Avg merge
3d 6h
Merged PRs (30d)
6

Description

If we use:

using Query, DataFrames
df = DataFrame(a=[1,2,3],b=["a","b","c"])

The command:

df |> @rename(:a=>:d)

does the expected rename of the column, however if:

df |> @rename(Symbol("a") => :d)

returns the error:

MethodError: no method matching getindex(::Nothing, ::Int64)

Stacktrace:
 [1] @rename(::LineNumberNode, ::Module, ::Vararg{Any,N} where N) at /Users/XXX/.julia/packages/Query/AwBtd/src/table_query_macros.jl:149

but I would expect the same result. I'm using Julia 1.4.1 and Query 0.12.2.

The reason for doing this would be to rename columns with spaces in them.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Reproduce the two @rename forms with Julia 1.4.1 and Query 0.12.2, then inspect src/table_query_macros.jl around line 149. Compare how the literal and Symbol expressions are handled, and verify the fix with regression coverage showing that both forms rename the column successfully.

Written by the indexing model from the issue text.

Assessment

Tech stack
julia
Domain
data
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.