-
Notifications
You must be signed in to change notification settings - Fork 105
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
Supporting FILTER and other similar operations #480
Comments
A query built using sqlalchemy + pyathena something like this query = select().where(
func.cardinality(func.filter(
"action",
lambda x: (
func.cast(x['timestamp'], Date) <= '2020-09-07',
func.cast(x['timestamp'], Date) >= '2020-06-01',
func.cast(x['action_count'], Integer) > 3
)
))
) results in a
This is after creating an engine with |
If there is anything missing from the implementation in PyAthena, pull requests are welcome. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Athena has support for
filter
function that can be used to filter values in a array and return the filtered array.https://docs.aws.amazon.com/athena/latest/ug/filtering-arrays.html
It will be quite helpful if we can have an equivalent function in pyathena's SQLAlchemy dialect.
Use Case
I have a table that contains an array of timestamps and an action performed by an actor.
Something like
I would want to write a query which can give me something like, count of times this action was performed more than 3 times b/w certain dates.
Or users who performed this action a total of more than 3 times b/w certain dates.
If had to write Athena SQL for this, it would look something like this
I would like to do something like this for a table with multiple such columns and using
and
or
etc. between those.@laughingman7743 Is there any way I can do this today?
I hate the idea of writing the query as Python F-strings and filling in the values.
The text was updated successfully, but these errors were encountered: