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

chore(docs): Update snuba docs with storage direct queries #6013

Merged
merged 1 commit into from
Jun 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 10 additions & 3 deletions docs/source/language/snql.rst
Original file line number Diff line number Diff line change
Expand Up @@ -45,11 +45,18 @@ MATCH clause that are currently supported:

``MATCH (<entity> [SAMPLE n])``

This is equivalent to all of our current queries. This is querying data from
a single entity (Events, Transactions etc.) It is possible to add an optional
Or for datasets without entities:

``MATCH (STORAGE(<storage>) [SAMPLE n])``

This is equivalent to all of our current queries. This either queries data from
a single entity or a single storage directly. It is possible to add an optional
sample to the query by adding it with the entity.

Example ``MATCH (events)``.
Example::

MATCH (events) # for entity queries
MATCH (STORAGE(profile_chunks)) # for storage queries.

**Subquery:**

Expand Down
20 changes: 19 additions & 1 deletion docs/source/query/overview.rst
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ Exploring the Snuba data model
==============================

In order to architect a Snuba query, the first step is being able to
know which Dataset you should query, which Entities you should select
know which Dataset you should query, which Entities you should select,
and what the schema of each Entity is.

For an introduction about Datasets and Entities, see the :doc:`/architecture/datamodel`
Expand Down Expand Up @@ -99,6 +99,24 @@ The query is represented as a ``Query`` object like::
granularity=Granularity(3600),
)

For simpler datasets, there may not exist an entity. In this case, we can
query the storage directly like::

query = Query(
dataset="profiles",
match=Storage("profile_chunks"),
select=[
Column("chunk_id"),
],
where=[
Condition(Column("start_timestamp"), Op.GT, datetime.datetime(2021, 1, 1)),
Condition(Column("end_timestamp"), Op.LT, datetime.datetime(2021, 1, 2)),
Condition(Column("project_id"), Op.IN, Function("tuple", [1, 2, 3])),
],
limit=Limit(10),
offset=Offset(0),
)

More details on how to build a query are in the sdk documentation.

Once the query object is ready it can be sent to Snuba.
Expand Down
Loading