Skip to content

at-querify interprets variables as fields/tags #7

Open

Description

@MarcMush
using InfluxDB 

server = InfluxServer("http://localhost:8086") # empty
db = "data"

create_database(server, db)

write(server, db, [
    Measurement("measure",
        Dict("a" => "b"),
        Dict("id" => "b"),
        time()),
    Measurement("measure",
        Dict("a" => "c"),
        Dict("id" => "d"),
        time()),
])

a = "d"
q1 = query(server, db, SELECT(measurements=["measure"], condition=@querify(:id == a)))
q2 = query(server, db, SELECT(measurements=["measure"], condition=InfluxDB.querify(:(:id == $a))))

I would expect the first query to work like the second one
I might try to fix it but macros are a pain so I'll stick with the second option for now

q1[1] = 1×3 DataFrame
│ Row │ time                         │ a      │ id     │
│     │ String                       │ String │ String │
├─────┼──────────────────────────────┼────────┼────────┤
│ 1   │ 2020-08-14T08:49:58.5606848Z │ b      │ b      │
q2[1] = 1×3 DataFrame
│ Row │ time                           │ a      │ id     │
│     │ String                         │ String │ String │
├─────┼────────────────────────────────┼────────┼────────┤
│ 1   │ 2020-08-14T08:49:58.560722944Z │ c      │ d      │

Activity

  1. staticfloat commented on Jan 7, 2021

    @staticfloat
    Owner

    The @querify macro is.... not built very well. The issue is that it is piecemeal converting Expr's to strings, and it is doing that directly, at compile-time, when what it should be doing is converting Exprs to other Expr's that result in Strings, so that the caller stitches all the Strings together. Without that fundamental change, the macro doesn't have access to the value of the variable you're trying to pass in at compile-time. Whoops.

    Anyone who wants to try and rewrite this has my blessing. Even better, if there's a standard query parsing package, that would be even better!

  2. MarcMush commented on Jan 7, 2021

    @MarcMush
    ContributorAuthor

    I found it easier to directly write condition as a string, which can be interpolated without problem

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions