gtfierro / mdal

metadata-driven data access layer
BSD 2-Clause "Simplified" License
4 stars 1 forks source link

Unsure which aggregation and time window to use for greenbutton id query #12

Open jleyden opened 5 years ago

jleyden commented 5 years ago

Currently, the python dataclient is requiring me to include Aggregation and Time['Window'] for a request where I am querying non-time-series data (greenbutton id). I am not sure what to fill in for these fields. Here is what I tried:

    request = {
        "Variables": {
            "id": {
                "Definition": """SSELECT ?gbm ?uuid FROM %s WHERE {
                    ?gbm rdf:type brick:Green_Button_Meter .
                    ?gbm bf:uuid ?uuid
                }; """ % sitename,
            }
        }
    }
    request['Composition'] = ['id']
    request['Aggregation'] = {'id': ['MEAN']}
    request['Time'] = {
        'Start': time_start,
        'End': time_stop,
        "Window": '5min',
        "Aligned": True
    }
    resp = m.query(request)
    return resp

I am currently getting this error:

File "/Users/jleyden/anaconda3/envs/mortar/lib/python3.6/site-packages/dataclient/__init__.py", line 53, in query
    raise Exception(resp.error)
Exception: Could not run query: Could not complete Brick query: Could not parse hod query: Error in S0: {(10,SSELECT), Pos(offset=0, line=1, column=1), expected one of: SELECT COUNT WHERE

I am thinking this may have to do with the aggregation function?

gtfierro commented 5 years ago

You should read the error message! It can't parse the query because you have SSELECT as the first term instead of SELECT

jleyden commented 5 years ago

True, I should get some sleep. But still does aggregation and time matter here? Now when I run the query I get a df with 0 columns.

gtfierro commented 5 years ago

You are querying timeseries data here; the ?uuid variable corresponds to matching the timeseries database identifier. Aggregation and time are both important and do matter here. Can you send me a full script to reproduce this in an email, along with the name of the site you are using?