Skip to content
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

Can't use attributes on Python callable objects in queries #3508

Closed
jmao-denver opened this issue Mar 8, 2023 · 0 comments · Fixed by #3509
Closed

Can't use attributes on Python callable objects in queries #3508

jmao-denver opened this issue Mar 8, 2023 · 0 comments · Fixed by #3509
Assignees
Labels
Milestone

Comments

@jmao-denver
Copy link
Contributor

from deephaven import read_csv

# read_csv will accept a url or a path to a local file
seattle_weather = read_csv("https://media.githubusercontent.com/media/deephaven/examples/main/GSOD/csv/seattle.csv")

from deephaven.time import year, TimeZone
from deephaven import agg

TZ_NY = TimeZone.NY
hi_lo_by_year = seattle_weather.view(formulas=["Year = (int)year(ObservationDate, TimeZone.NY)", "TemperatureF"])\
    .where(filters=["Year >= 2000"])\
    .agg_by([\
        agg.avg(cols=["Avg_Temp = TemperatureF"]),\
        agg.min_(cols=["Lo_Temp = TemperatureF"]),\
        agg.max_(cols=["Hi_Temp = TemperatureF"])
        ],\
     by=["Year"])

Running the above code causes an exception

Having trouble with the following expression:
Full expression           : (int)year(ObservationDate, TimeZone.NY)
Expression having trouble : io.deephaven.engine.table.impl.lang.QueryLanguageParser$VisitArgs@43adc7c1
Exception message         : Cannot resolve field name.
    Expression : TimeZone.NY
    Scope      : TimeZone
    Scope Type : io.deephaven.engine.util.PyCallableWrapper
    Field Name : NY

The workaround is to assign the class attribute to a local variable first (TZ_NY in the code) and replace TimeZone.NY with it in the query string, but it is not natural and confusing to the users.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant