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

Enhance auto selection of FieldPaths with filters on field names #31

Open
1 task
cvauclair opened this issue May 30, 2023 · 0 comments
Open
1 task

Enhance auto selection of FieldPaths with filters on field names #31

cvauclair opened this issue May 30, 2023 · 0 comments
Labels
enhancement New feature or request good first issue Good for newcomers

Comments

@cvauclair
Copy link
Contributor

Is your feature request related to a problem? Please describe.
Yes! Currently, Sugrounds supports auto-selection of FieldPaths. This means that if you use one of the querying methods (e.g.: sg.query_df) with a FieldPath that does not select a scalar value, then Subgrounds will automatically grab all scalar fields available from that partial selection (see code snippet below).

However, especially during the data exploration phase, this is too much data to be useful (users have to go through dozens of columns to find the data that interests them. The other option, to individually select all fields of interest, is tedious and verbose. What is missing is a middle ground between both cases.

Introducing, filtered auto-selections! (not to be confused with filters on selections, i.e.: with the where argument). The idea is simple, it would work the same as the regular autocompletion of FieldPaths, while allowing users to specify a filter for the fields they want to select.

Describe the solution you'd like

from subgrounds import Subgrounds

sg = Subgrounds()

subgraph = sg.load_subgraph("https://api.thegraph.com/subgraphs/name/messari/uniswap-v3-ethereum")

# Select individual fields
sg.query_df([
  subgraph.Query.financialsDailySnapshots.timestamp,
  subgraph.Query.financialsDailySnapshots.totalValueLockedUSD,
])

# Auto-select all fields
sg.query_df([
  subgraph.Query.financialsDailySnapshots
])

# NEW: Select all fields starting with `cumulative`
sg.query_df([
  subgraph.Query.financialsDailySnapshots._select("cumulative*")
])

Describe alternatives you've considered
None.

Additional context
For consistency, subgraph.Query.financialsDailySnapshots._select("*") should be equivalent to selecting all the fields (the second case).

Implementation checklist

  • Update FieldPath._select to be able to handle widlcards
@cvauclair cvauclair added the enhancement New feature or request label May 30, 2023
@0xMochan 0xMochan added the good first issue Good for newcomers label Jul 10, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request good first issue Good for newcomers
Projects
None yet
Development

No branches or pull requests

2 participants