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

Subquery not getting converted property #293

Open
veerappans opened this issue Sep 15, 2022 · 2 comments
Open

Subquery not getting converted property #293

veerappans opened this issue Sep 15, 2022 · 2 comments
Labels

Comments

@veerappans
Copy link

veerappans commented Sep 15, 2022

I tried a simple subquery query:

`
sub_query = druid_conn.sub_query(datasource='twitterstream_res',
granularity='day',
intervals='2022-01-01/2022-01-03',
dimensions=[],
aggregations={"first_value": doublesum("REVENUE")},
)

group_query = druid_conn.timeseries(
datasource=sub_query,
granularity='day',
intervals='2022-01-01/2022-01-03',
aggregations={"outer_final_value": doublesum("first_value")}
)

df = group_query.export_pandas()
df
`

when I do this, I am getting an druid query syntax error. Its getting converted incorrectly. Can anyone please help.

`{
"aggregations": [
{
"fieldName": "first_value",
"name": "outer_final_value",
"type": "doubleSum"
}
],
"dataSource": {
"dataSources": {
"query": {
"aggregations": [
{
"fieldName": "REVENUE",
"name": "first_value",
"type": "doubleSum"
}
],
"dataSource": "twitterstream",
"granularity": "day",
"intervals": "2022-01-01/2022-01-03",
"queryType": "groupBy"
},
"type": "query"
},
"type": "union"
},
"granularity": "day",
"intervals": "2022-01-01/2022-01-03",
"queryType": "timeseries"
}

druid_conn.timeseries(
datasource=sub_query,
granularity='day',
intervals='2022-01-01/2022-01-03',
aggregations={"outer_final_value": doublesum("first_value")}
)
`

Adding an extra 'union'

@nbehnam
Copy link
Contributor

nbehnam commented Jan 26, 2023

I ran into the same thing. basically the subquery returns a dict but it isn't handled properly in parse_datasource, it basically assumes that it is a list vs a dictionary and thus thinks its a list of data sources.

@nbehnam
Copy link
Contributor

nbehnam commented Jan 26, 2023

I created #299 which "should" fix it.

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

No branches or pull requests

3 participants