Skip to content

Commit

Permalink
update docs for snuba storage queries
Browse files Browse the repository at this point in the history
  • Loading branch information
enochtangg committed Jun 9, 2024
1 parent ada4804 commit 70fce43
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 4 deletions.
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

0 comments on commit 70fce43

Please sign in to comment.