diff --git a/docs/source/language/snql.rst b/docs/source/language/snql.rst index f4b6b102bc4..e01b01170ae 100644 --- a/docs/source/language/snql.rst +++ b/docs/source/language/snql.rst @@ -45,11 +45,18 @@ MATCH clause that are currently supported: ``MATCH ( [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() [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:** diff --git a/docs/source/query/overview.rst b/docs/source/query/overview.rst index f56d59190dd..1c5686158ae 100644 --- a/docs/source/query/overview.rst +++ b/docs/source/query/overview.rst @@ -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` @@ -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.