clintropolis commented on a change in pull request #9879:
URL: https://github.com/apache/druid/pull/9879#discussion_r428436911
##########
File path: docs/tutorials/tutorial-query.md
##########
@@ -24,56 +24,165 @@ sidebar_label: "Querying data"
-->
-This tutorial will demonstrate how to query data in Apache Druid, with
examples for Druid SQL and Druid's native query format.
+This tutorial demonstrates how to query data in Apache Druid using Druid SQL,
a SQL-like language
Review comment:
imo maybe this should just be
>This tutorial demonstrates how to query data in Apache Druid using SQL.
##########
File path: docs/tutorials/tutorial-query.md
##########
@@ -162,150 +272,8 @@ The following results should be returned:
]
```
-### More Druid SQL examples
-
-Here is a collection of queries to try out:
-
-#### Query over time
-
-```sql
-SELECT FLOOR(__time to HOUR) AS HourTime, SUM(deleted) AS LinesDeleted
-FROM wikipedia WHERE "__time" BETWEEN TIMESTAMP '2015-09-12 00:00:00' AND
TIMESTAMP '2015-09-13 00:00:00'
-GROUP BY 1
-```
-
-
-
-#### General group by
-
-```sql
-SELECT channel, page, SUM(added)
-FROM wikipedia WHERE "__time" BETWEEN TIMESTAMP '2015-09-12 00:00:00' AND
TIMESTAMP '2015-09-13 00:00:00'
-GROUP BY channel, page
-ORDER BY SUM(added) DESC
-```
-
-
-
-#### Select raw data
-
-```sql
-SELECT user, page
-FROM wikipedia WHERE "__time" BETWEEN TIMESTAMP '2015-09-12 02:00:00' AND
TIMESTAMP '2015-09-12 03:00:00'
-LIMIT 5
-```
-
-
-
-### Explain query plan
-
-Druid SQL has the ability to explain the query plan for a given query.
-In the console this functionality is accessible from the `...` button.
-
-
-
-If you are querying in other ways you can get the plan by prepending `EXPLAIN
PLAN FOR ` to a Druid SQL query.
-
-Using a query from an example above:
-
-`EXPLAIN PLAN FOR SELECT page, COUNT(*) AS Edits FROM wikipedia WHERE "__time"
BETWEEN TIMESTAMP '2015-09-12 00:00:00' AND TIMESTAMP '2015-09-13 00:00:00'
GROUP BY page ORDER BY Edits DESC LIMIT 10;`
-
-```bash
-dsql> EXPLAIN PLAN FOR SELECT page, COUNT(*) AS Edits FROM wikipedia WHERE
"__time" BETWEEN TIMESTAMP '2015-09-12 00:00:00' AND TIMESTAMP '2015-09-13
00:00:00' GROUP BY page ORDER BY Edits DESC LIMIT 10;
-┌─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┐
-│ PLAN
│
-├─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┤
-│
DruidQueryRel(query=[{"queryType":"topN","dataSource":{"type":"table","name":"wikipedia"},"virtualColumns":[],"dimension":{"type":"default","dimension":"page","outputName":"d0","outputType":"STRING"},"metric":{"type":"numeric","metric":"a0"},"threshold":10,"intervals":{"type":"intervals","intervals":["2015-09-12T00:00:00.000Z/2015-09-13T00:00:00.001Z"]},"filter":null,"granularity":{"type":"all"},"aggregations":[{"type":"count","name":"a0"}],"postAggregations":[],"context":{},"descending":false}],
signature=[{d0:STRING, a0:LONG}]) │
-└─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┘
-Retrieved 1 row in 0.03s.
-```
-
-
-## Native JSON queries
-
-Druid's native query format is expressed in JSON.
-
-### Native query via the console
-
-You can issue native Druid queries from the console's Query view.
-
-Here is a query that retrieves the 10 Wikipedia pages with the most page edits
on 2015-09-12.
-
-```json
-{
- "queryType" : "topN",
- "dataSource" : "wikipedia",
- "intervals" : ["2015-09-12/2015-09-13"],
- "granularity" : "all",
- "dimension" : "page",
- "metric" : "count",
- "threshold" : 10,
- "aggregations" : [
- {
- "type" : "count",
- "name" : "count"
- }
- ]
-}
-```
-
-Simply paste it into the console to switch the editor into JSON mode.
-
-
-
-
-### Native queries over HTTP
-
-We have included a sample native TopN query under
`quickstart/tutorial/wikipedia-top-pages.json`:
-
-Let's submit this query to Druid:
-
-```bash
-curl -X 'POST' -H 'Content-Type:application/json' -d
@quickstart/tutorial/wikipedia-top-pages.json
http://localhost:8888/druid/v2?pretty
-```
-
-You should see the following query results:
-
-```json
-[ {
- "timestamp" : "2015-09-12T00:46:58.771Z",
- "result" : [ {
- "count" : 33,
- "page" : "Wikipedia:Vandalismusmeldung"
- }, {
- "count" : 28,
- "page" : "User:Cyde/List of candidates for speedy deletion/Subpage"
- }, {
- "count" : 27,
- "page" : "Jeremy Corbyn"
- }, {
- "count" : 21,
- "page" : "Wikipedia:Administrators' noticeboard/Incidents"
- }, {
- "count" : 20,
- "page" : "Flavia Pennetta"
- }, {
- "count" : 18,
- "page" : "Total Drama Presents: The Ridonculous Race"
- }, {
- "count" : 18,
- "page" : "User talk:Dudeperson176123"
- }, {
- "count" : 18,
- "page" : "Wikipédia:Le Bistro/12 septembre 2015"
- }, {
- "count" : 17,
- "page" : "Wikipedia:In the news/Candidates"
- }, {
- "count" : 17,
- "page" : "Wikipedia:Requests for page protection"
- } ]
-} ]
-```
-
-
## Further reading
-The [Queries documentation](../querying/querying.md) has more information on
Druid's native JSON queries.
+See the [Queries documentation](../querying/querying.md) for more information
on Druid native query.
Review comment:
nit: '.. Druid native queries.'
##########
File path: docs/tutorials/tutorial-query.md
##########
@@ -24,56 +24,165 @@ sidebar_label: "Querying data"
-->
-This tutorial will demonstrate how to query data in Apache Druid, with
examples for Druid SQL and Druid's native query format.
+This tutorial demonstrates how to query data in Apache Druid using Druid SQL,
a SQL-like language
+for querying data in Druid.
-The tutorial assumes that you've already completed one of the 4 ingestion
tutorials, as we will be querying the sample Wikipedia edits data.
+It assumes that you've completed the [Quickstart](../tutorials/index.md)
+or one of the following tutorials, since we'll query datasources that you
would have created
+by following one of them:
* [Tutorial: Loading a file](../tutorials/tutorial-batch.md)
* [Tutorial: Loading stream data from Kafka](../tutorials/tutorial-kafka.md)
* [Tutorial: Loading a file using
Hadoop](../tutorials/tutorial-batch-hadoop.md)
-Druid queries are sent over HTTP.
-The Druid console includes a view to issue queries to Druid and nicely format
the results.
+There are various ways to run Druid SQL queries: from the Druid console, using
a command line utility
+and by posting the query by HTTP. We'll look at each of these.
-## Druid SQL queries
-Druid supports a dialect of SQL for querying.
+## Query SQL from the Druid console
-This query retrieves the 10 Wikipedia pages with the most page edits on
2015-09-12.
+The Druid console includes a view that makes it easier to build and test
queries, and
+view their results.
-```sql
-SELECT page, COUNT(*) AS Edits
-FROM wikipedia
-WHERE TIMESTAMP '2015-09-12 00:00:00' <= "__time" AND "__time" < TIMESTAMP
'2015-09-13 00:00:00'
-GROUP BY page
-ORDER BY Edits DESC
-LIMIT 10
-```
+1. Start up the Druid cluster, if it's not already running, and open the Druid
console in your web
+browser.
+
+2. Click **Query** from the header to open the Query view:
+
+ 
+
+ You can write queries directly in the edit pane, but we'll generate a
starter query
Review comment:
"query builder controls" isn't super obvious I think, suggestion:
> You can always write queries directly in the edit pane, but the Query view
also provides facilities to help you construct SQL queries, which we will use
to generate a starter query.
##########
File path: docs/tutorials/tutorial-query.md
##########
@@ -162,150 +272,8 @@ The following results should be returned:
]
```
-### More Druid SQL examples
-
-Here is a collection of queries to try out:
-
-#### Query over time
-
-```sql
-SELECT FLOOR(__time to HOUR) AS HourTime, SUM(deleted) AS LinesDeleted
-FROM wikipedia WHERE "__time" BETWEEN TIMESTAMP '2015-09-12 00:00:00' AND
TIMESTAMP '2015-09-13 00:00:00'
-GROUP BY 1
-```
-
-
-
-#### General group by
-
-```sql
-SELECT channel, page, SUM(added)
-FROM wikipedia WHERE "__time" BETWEEN TIMESTAMP '2015-09-12 00:00:00' AND
TIMESTAMP '2015-09-13 00:00:00'
-GROUP BY channel, page
-ORDER BY SUM(added) DESC
-```
-
-
-
-#### Select raw data
-
-```sql
-SELECT user, page
-FROM wikipedia WHERE "__time" BETWEEN TIMESTAMP '2015-09-12 02:00:00' AND
TIMESTAMP '2015-09-12 03:00:00'
-LIMIT 5
-```
-
-
-
-### Explain query plan
-
-Druid SQL has the ability to explain the query plan for a given query.
-In the console this functionality is accessible from the `...` button.
-
-
-
-If you are querying in other ways you can get the plan by prepending `EXPLAIN
PLAN FOR ` to a Druid SQL query.
-
-Using a query from an example above:
-
-`EXPLAIN PLAN FOR SELECT page, COUNT(*) AS Edits FROM wikipedia WHERE "__time"
BETWEEN TIMESTAMP '2015-09-12 00:00:00' AND TIMESTAMP '2015-09-13 00:00:00'
GROUP BY page ORDER BY Edits DESC LIMIT 10;`
-
-```bash
-dsql> EXPLAIN PLAN FOR SELECT page, COUNT(*) AS Edits FROM wikipedia WHERE
"__time" BETWEEN TIMESTAMP '2015-09-12 00:00:00' AND TIMESTAMP '2015-09-13
00:00:00' GROUP BY page ORDER BY Edits DESC LIMIT 10;
-┌─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┐
-│ PLAN
│
-├─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┤
-│
DruidQueryRel(query=[{"queryType":"topN","dataSource":{"type":"table","name":"wikipedia"},"virtualColumns":[],"dimension":{"type":"default","dimension":"page","outputName":"d0","outputType":"STRING"},"metric":{"type":"numeric","metric":"a0"},"threshold":10,"intervals":{"type":"intervals","intervals":["2015-09-12T00:00:00.000Z/2015-09-13T00:00:00.001Z"]},"filter":null,"granularity":{"type":"all"},"aggregations":[{"type":"count","name":"a0"}],"postAggregations":[],"context":{},"descending":false}],
signature=[{d0:STRING, a0:LONG}]) │
-└─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┘
-Retrieved 1 row in 0.03s.
-```
-
-
-## Native JSON queries
-
-Druid's native query format is expressed in JSON.
-
-### Native query via the console
-
-You can issue native Druid queries from the console's Query view.
-
-Here is a query that retrieves the 10 Wikipedia pages with the most page edits
on 2015-09-12.
-
-```json
-{
- "queryType" : "topN",
- "dataSource" : "wikipedia",
- "intervals" : ["2015-09-12/2015-09-13"],
- "granularity" : "all",
- "dimension" : "page",
- "metric" : "count",
- "threshold" : 10,
- "aggregations" : [
- {
- "type" : "count",
- "name" : "count"
- }
- ]
-}
-```
-
-Simply paste it into the console to switch the editor into JSON mode.
-
-
-
-
-### Native queries over HTTP
-
-We have included a sample native TopN query under
`quickstart/tutorial/wikipedia-top-pages.json`:
-
-Let's submit this query to Druid:
-
-```bash
-curl -X 'POST' -H 'Content-Type:application/json' -d
@quickstart/tutorial/wikipedia-top-pages.json
http://localhost:8888/druid/v2?pretty
-```
-
-You should see the following query results:
-
-```json
-[ {
- "timestamp" : "2015-09-12T00:46:58.771Z",
- "result" : [ {
- "count" : 33,
- "page" : "Wikipedia:Vandalismusmeldung"
- }, {
- "count" : 28,
- "page" : "User:Cyde/List of candidates for speedy deletion/Subpage"
- }, {
- "count" : 27,
- "page" : "Jeremy Corbyn"
- }, {
- "count" : 21,
- "page" : "Wikipedia:Administrators' noticeboard/Incidents"
- }, {
- "count" : 20,
- "page" : "Flavia Pennetta"
- }, {
- "count" : 18,
- "page" : "Total Drama Presents: The Ridonculous Race"
- }, {
- "count" : 18,
- "page" : "User talk:Dudeperson176123"
- }, {
- "count" : 18,
- "page" : "Wikipédia:Le Bistro/12 septembre 2015"
- }, {
- "count" : 17,
- "page" : "Wikipedia:In the news/Candidates"
- }, {
- "count" : 17,
- "page" : "Wikipedia:Requests for page protection"
- } ]
-} ]
-```
-
-
## Further reading
-The [Queries documentation](../querying/querying.md) has more information on
Druid's native JSON queries.
+See the [Queries documentation](../querying/querying.md) for more information
on Druid native query.
-The [Druid SQL documentation](../querying/sql.md) has more information on
using Druid SQL queries.
+See the [Druid SQL documentation](../querying/sql.md) for more information on
using Druid SQL queries.
Review comment:
Should the order of these links be flipped since it makes SQL more
prominent than native queries?
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]