subgrounds icon indicating copy to clipboard operation
subgrounds copied to clipboard

How can one filter a column by condition NOT NULL

Open gabrielfior opened this issue 11 months ago • 6 comments

Describe the bug It's not clear from the documentation how one can filter the subgraph results by a column which should not be NULL.

To Reproduce My (incorrect) query:

latest_markets = subgraph.Query.fixedProductMarketMakers(
        orderBy=subgraph.FixedProductMarketMaker.creationTimestamp,
        orderDirection="desc",
        first=2,
        where=[str(subgraph.FixedProductMarketMaker.resolutionTimestamp) != "null"], # problem here
    )

Expected behavior I would expect an example to be found in the documentation.

gabrielfior avatar Mar 19 '24 19:03 gabrielfior

Hey thanks for the report here, I'll def. add an example for this use-case to our docs. Do you mind sharing the specific subgraph here for context?

0xMochan avatar Mar 19 '24 21:03 0xMochan

I actually figured out that one can write object.column is not None and use that as filter. So problem solved.

For reference, the subgraph is https://api.thegraph.com/subgraphs/name/protofire/omen-xdai/graphql

gabrielfior avatar Mar 20 '24 21:03 gabrielfior

Glad you figured it out! I'll look towards adding a FAQ for this to try to help future devs.

0xMochan avatar Mar 20 '24 21:03 0xMochan

Correction - the IS NOT NULL filter_condition I mentioned earlier does not work, see screenshot below

where_stms.append(fpmm.resolutionTimestamp is not None)

SUBGRAPH_URL = https://api.thegraph.com/subgraphs/name/protofire/omen-xdai/graphql

image

They get defined as True or False statements, hence not valid.

gabrielfior avatar Mar 21 '24 20:03 gabrielfior

@0xMochan created a PR for this (https://github.com/0xPlaygrounds/subgrounds/pull/53). I got the filter to work after all. Thanks for the help.

gabrielfior avatar Mar 22 '24 16:03 gabrielfior

@0xMochan created a PR for this (#53). I got the filter to work after all. Thanks for the help.

Thanks so much for improving Subgrounds and creating a PR. I apologize for the delay in the response, but I'm looking to dive into this and quickly get it merged next week! Also, LMK if you had any issues with the CONTRIBUTING.md guide, I'm always looking for feedback to make it clearer and easier for newcomers to contribute!

0xMochan avatar Mar 28 '24 23:03 0xMochan