You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@druid.apache.org by GitBox <gi...@apache.org> on 2021/12/22 19:25:14 UTC

[GitHub] [druid] vtlim opened a new pull request #12093: Docs: add FILTER to sql query syntax

vtlim opened a new pull request #12093:
URL: https://github.com/apache/druid/pull/12093


   Adds the FILTER clause to the SQL docs.
   
   
   This PR has:
   - [x] been self-reviewed.
   
   


-- 
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.

To unsubscribe, e-mail: commits-unsubscribe@druid.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@druid.apache.org
For additional commands, e-mail: commits-help@druid.apache.org


[GitHub] [druid] vogievetsky commented on a change in pull request #12093: Docs: add FILTER to sql query syntax

Posted by GitBox <gi...@apache.org>.
vogievetsky commented on a change in pull request #12093:
URL: https://github.com/apache/druid/pull/12093#discussion_r774259240



##########
File path: docs/querying/sql.md
##########
@@ -47,11 +47,11 @@ Druid SQL supports SELECT queries with the following structure:
 ```
 [ EXPLAIN PLAN FOR ]
 [ WITH tableName [ ( column1, column2, ... ) ] AS ( query ) ]
-SELECT [ ALL | DISTINCT ] { * | exprs }
+SELECT [ ALL | DISTINCT ] { * | exprs } [ FILTER ( WHERE expr ) ]

Review comment:
       I don't think this belongs in the query syntax description at all. It should be a section in the aggregation functions as it can only apply there. Have a look at how it is implemented on [Calcite's reference page](https://calcite.apache.org/docs/reference.html) (search for `FILTER (`)




-- 
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.

To unsubscribe, e-mail: commits-unsubscribe@druid.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@druid.apache.org
For additional commands, e-mail: commits-help@druid.apache.org


[GitHub] [druid] vtlim commented on a change in pull request #12093: Docs: add FILTER to sql query syntax

Posted by GitBox <gi...@apache.org>.
vtlim commented on a change in pull request #12093:
URL: https://github.com/apache/druid/pull/12093#discussion_r774255286



##########
File path: docs/querying/sql.md
##########
@@ -47,8 +47,9 @@ Druid SQL supports SELECT queries with the following structure:
 ```
 [ EXPLAIN PLAN FOR ]
 [ WITH tableName [ ( column1, column2, ... ) ] AS ( query ) ]
-SELECT [ ALL | DISTINCT ] { * | exprs }
+SELECT [ ALL | DISTINCT ] { * | exprs } [ FILTER ( WHERE expr ) ]
 FROM { <table> | (<subquery>) | <o1> [ INNER | LEFT ] JOIN <o2> ON condition }
+[ FILTER ( WHERE condition ) ]
 [ WHERE expr ]
 [ GROUP BY [ exprs | GROUPING SETS ( (exprs), ... ) | ROLLUP (exprs) | CUBE (exprs) ] ]
 [ HAVING expr ]

Review comment:
       ```suggestion
   [ HAVING expr [ FILTER ( WHERE expr ) ] ]
   ```




-- 
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.

To unsubscribe, e-mail: commits-unsubscribe@druid.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@druid.apache.org
For additional commands, e-mail: commits-help@druid.apache.org


[GitHub] [druid] vtlim commented on a change in pull request #12093: Docs: add FILTER to sql query syntax

Posted by GitBox <gi...@apache.org>.
vtlim commented on a change in pull request #12093:
URL: https://github.com/apache/druid/pull/12093#discussion_r774257640



##########
File path: docs/querying/sql.md
##########
@@ -47,11 +47,12 @@ Druid SQL supports SELECT queries with the following structure:
 ```
 [ EXPLAIN PLAN FOR ]
 [ WITH tableName [ ( column1, column2, ... ) ] AS ( query ) ]
-SELECT [ ALL | DISTINCT ] { * | exprs }
+SELECT [ ALL | DISTINCT ] { * | exprs } [ FILTER ( WHERE expr ) ]
 FROM { <table> | (<subquery>) | <o1> [ INNER | LEFT ] JOIN <o2> ON condition }
+[ FILTER ( WHERE condition ) ]

Review comment:
       ```suggestion
   ```




-- 
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.

To unsubscribe, e-mail: commits-unsubscribe@druid.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@druid.apache.org
For additional commands, e-mail: commits-help@druid.apache.org


[GitHub] [druid] vtlim commented on a change in pull request #12093: Docs: add FILTER to sql query syntax

Posted by GitBox <gi...@apache.org>.
vtlim commented on a change in pull request #12093:
URL: https://github.com/apache/druid/pull/12093#discussion_r774252154



##########
File path: docs/querying/sql.md
##########
@@ -49,6 +49,7 @@ Druid SQL supports SELECT queries with the following structure:
 [ WITH tableName [ ( column1, column2, ... ) ] AS ( query ) ]
 SELECT [ ALL | DISTINCT ] { * | exprs }

Review comment:
       ```suggestion
   SELECT [ ALL | DISTINCT ] { * | exprs } [ FILTER ( WHERE expr ) ]
   ```




-- 
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.

To unsubscribe, e-mail: commits-unsubscribe@druid.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@druid.apache.org
For additional commands, e-mail: commits-help@druid.apache.org


[GitHub] [druid] clintropolis commented on a change in pull request #12093: Docs: add FILTER to sql query syntax

Posted by GitBox <gi...@apache.org>.
clintropolis commented on a change in pull request #12093:
URL: https://github.com/apache/druid/pull/12093#discussion_r774246307



##########
File path: docs/querying/sql.md
##########
@@ -49,6 +49,7 @@ Druid SQL supports SELECT queries with the following structure:
 [ WITH tableName [ ( column1, column2, ... ) ] AS ( query ) ]
 SELECT [ ALL | DISTINCT ] { * | exprs }
 FROM { <table> | (<subquery>) | <o1> [ INNER | LEFT ] JOIN <o2> ON condition }
+[ FILTER ( WHERE condition ) ]

Review comment:
       this is an optional part of SELECT and also HAVING, so I guess more accurate would be removing this newly added line and changing those lines to:
   
   ```
   SELECT [ ALL | DISTINCT ] { * | exprs } [ FILTER ( WHERE expr ) ]
   ```
   and
   ```
   [ HAVING expr [ FILTER ( WHERE expr ) ] ]
   ```
   I think?




-- 
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.

To unsubscribe, e-mail: commits-unsubscribe@druid.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@druid.apache.org
For additional commands, e-mail: commits-help@druid.apache.org


[GitHub] [druid] vtlim commented on a change in pull request #12093: Docs: add FILTER to sql query syntax

Posted by GitBox <gi...@apache.org>.
vtlim commented on a change in pull request #12093:
URL: https://github.com/apache/druid/pull/12093#discussion_r774253143



##########
File path: docs/querying/sql.md
##########
@@ -49,6 +49,7 @@ Druid SQL supports SELECT queries with the following structure:
 [ WITH tableName [ ( column1, column2, ... ) ] AS ( query ) ]
 SELECT [ ALL | DISTINCT ] { * | exprs }
 FROM { <table> | (<subquery>) | <o1> [ INNER | LEFT ] JOIN <o2> ON condition }
+[ FILTER ( WHERE condition ) ]
 [ WHERE expr ]
 [ GROUP BY [ exprs | GROUPING SETS ( (exprs), ... ) | ROLLUP (exprs) | CUBE (exprs) ] ]
 [ HAVING expr ]

Review comment:
       ```suggestion
   [ WHERE expr ]
   [ GROUP BY [ exprs | GROUPING SETS ( (exprs), ... ) | ROLLUP (exprs) | CUBE (exprs) ] ]
   [ HAVING expr [ FILTER ( WHERE expr ) ] ]
   ```




-- 
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.

To unsubscribe, e-mail: commits-unsubscribe@druid.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@druid.apache.org
For additional commands, e-mail: commits-help@druid.apache.org


[GitHub] [druid] vtlim commented on a change in pull request #12093: Docs: add FILTER to sql query syntax

Posted by GitBox <gi...@apache.org>.
vtlim commented on a change in pull request #12093:
URL: https://github.com/apache/druid/pull/12093#discussion_r774176073



##########
File path: docs/querying/sql.md
##########
@@ -76,6 +77,11 @@ FROM clause, metadata tables are not considered datasources. They exist only in
 For more information about table, lookup, query, and join datasources, refer to the [Datasources](datasource.md)
 documentation.
 
+### FILTER
+
+The FILTER clause limits an aggregation query to execute only on the rows for which a condition evaluates to true.

Review comment:
       ```suggestion
   The FILTER clause limits an aggregation query to only the rows for which a condition evaluates to true.
   ```




-- 
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.

To unsubscribe, e-mail: commits-unsubscribe@druid.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@druid.apache.org
For additional commands, e-mail: commits-help@druid.apache.org


[GitHub] [druid] clintropolis merged pull request #12093: Docs: add FILTER to sql query syntax

Posted by GitBox <gi...@apache.org>.
clintropolis merged pull request #12093:
URL: https://github.com/apache/druid/pull/12093


   


-- 
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.

To unsubscribe, e-mail: commits-unsubscribe@druid.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@druid.apache.org
For additional commands, e-mail: commits-help@druid.apache.org


[GitHub] [druid] clintropolis commented on a change in pull request #12093: Docs: add FILTER to sql query syntax

Posted by GitBox <gi...@apache.org>.
clintropolis commented on a change in pull request #12093:
URL: https://github.com/apache/druid/pull/12093#discussion_r774253604



##########
File path: docs/querying/sql.md
##########
@@ -49,6 +49,7 @@ Druid SQL supports SELECT queries with the following structure:
 [ WITH tableName [ ( column1, column2, ... ) ] AS ( query ) ]
 SELECT [ ALL | DISTINCT ] { * | exprs }
 FROM { <table> | (<subquery>) | <o1> [ INNER | LEFT ] JOIN <o2> ON condition }
+[ FILTER ( WHERE condition ) ]

Review comment:
       actually wondering if i messed the select one up and it should be 
   
   ```
   SELECT [ ALL | DISTINCT ] { * | exprs [ FILTER ( WHERE expr ) ] } 
   ```
   
   but that’s not really quite right either, sort of would need to expand `exprs` into 
   
   ```
   expr1 [ FILTER ( WHERE expr ) ], expr2 ...
   ```
   
   maybe its fine as it is, though it sort of reads like you could write `SELECT * FILTER (WHERE ...) FROM ... ``` which you can't




-- 
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.

To unsubscribe, e-mail: commits-unsubscribe@druid.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@druid.apache.org
For additional commands, e-mail: commits-help@druid.apache.org


[GitHub] [druid] clintropolis commented on a change in pull request #12093: Docs: add FILTER to sql query syntax

Posted by GitBox <gi...@apache.org>.
clintropolis commented on a change in pull request #12093:
URL: https://github.com/apache/druid/pull/12093#discussion_r774253604



##########
File path: docs/querying/sql.md
##########
@@ -49,6 +49,7 @@ Druid SQL supports SELECT queries with the following structure:
 [ WITH tableName [ ( column1, column2, ... ) ] AS ( query ) ]
 SELECT [ ALL | DISTINCT ] { * | exprs }
 FROM { <table> | (<subquery>) | <o1> [ INNER | LEFT ] JOIN <o2> ON condition }
+[ FILTER ( WHERE condition ) ]

Review comment:
       actually wondering if i messed the select one up and it should be 
   
   ```
   SELECT [ ALL | DISTINCT ] { * | exprs [ FILTER ( WHERE expr ) ] } 
   ```
   
   but that’s not really quite right either, sort of would need to expand `exprs` into 
   
   ```
   expr1 [ FILTER ( WHERE expr ) ], expr2 ...
   ```
   
   maybe its fine as it is, though it sort of reads like you could write 
   
   ```
   SELECT * FILTER (WHERE ...) FROM ...
   ```
    which you can't




-- 
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.

To unsubscribe, e-mail: commits-unsubscribe@druid.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@druid.apache.org
For additional commands, e-mail: commits-help@druid.apache.org


[GitHub] [druid] vtlim commented on a change in pull request #12093: Docs: add FILTER to sql query syntax

Posted by GitBox <gi...@apache.org>.
vtlim commented on a change in pull request #12093:
URL: https://github.com/apache/druid/pull/12093#discussion_r774253143



##########
File path: docs/querying/sql.md
##########
@@ -49,6 +49,7 @@ Druid SQL supports SELECT queries with the following structure:
 [ WITH tableName [ ( column1, column2, ... ) ] AS ( query ) ]
 SELECT [ ALL | DISTINCT ] { * | exprs }
 FROM { <table> | (<subquery>) | <o1> [ INNER | LEFT ] JOIN <o2> ON condition }
+[ FILTER ( WHERE condition ) ]
 [ WHERE expr ]
 [ GROUP BY [ exprs | GROUPING SETS ( (exprs), ... ) | ROLLUP (exprs) | CUBE (exprs) ] ]
 [ HAVING expr ]

Review comment:
       ```suggestion
   [ WHERE expr ]
   [ GROUP BY [ exprs | GROUPING SETS ( (exprs), ... ) | ROLLUP (exprs) | CUBE (exprs) ] ]
   [ HAVING expr [ FILTER ( WHERE expr ) ] ]
   ```




-- 
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.

To unsubscribe, e-mail: commits-unsubscribe@druid.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@druid.apache.org
For additional commands, e-mail: commits-help@druid.apache.org


[GitHub] [druid] vtlim commented on a change in pull request #12093: Docs: add FILTER to sql query syntax

Posted by GitBox <gi...@apache.org>.
vtlim commented on a change in pull request #12093:
URL: https://github.com/apache/druid/pull/12093#discussion_r774255857



##########
File path: docs/querying/sql.md
##########
@@ -47,8 +47,9 @@ Druid SQL supports SELECT queries with the following structure:
 ```
 [ EXPLAIN PLAN FOR ]
 [ WITH tableName [ ( column1, column2, ... ) ] AS ( query ) ]
-SELECT [ ALL | DISTINCT ] { * | exprs }
+SELECT [ ALL | DISTINCT ] { * | exprs } [ FILTER ( WHERE expr ) ]
 FROM { <table> | (<subquery>) | <o1> [ INNER | LEFT ] JOIN <o2> ON condition }
+[ FILTER ( WHERE condition ) ]
 [ WHERE expr ]
 [ GROUP BY [ exprs | GROUPING SETS ( (exprs), ... ) | ROLLUP (exprs) | CUBE (exprs) ] ]
 [ HAVING expr ]

Review comment:
       ```suggestion
   [ HAVING expr [ FILTER ( WHERE expr ) ] ]
   ```




-- 
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.

To unsubscribe, e-mail: commits-unsubscribe@druid.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@druid.apache.org
For additional commands, e-mail: commits-help@druid.apache.org