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/11/11 15:12:32 UTC

[GitHub] [druid] zemin-piao opened a new issue #11909: Druid SQL cannot do aggregation on metric column with name "count"

zemin-piao opened a new issue #11909:
URL: https://github.com/apache/druid/issues/11909


   Please provide a detailed title (e.g. "Broker crashes when using TopN query with Bound filter" instead of just "Broker crashes").
   
   ### 0.21.0
   
   The Druid version where the problem was encountered.
   
   ### Description
   
   As mentioned in the title, when running sql query which does aggregation on column with name "count", it returns SQL parse failed issue. For example:
   
   ```
   select sum(count) from capturesummary where id = 707849 and ps = 459 group by jt, ps, __time
   ```
   
   error message: 
   
   ```
   SQL parse failed (org.apache.calcite.sql.parser.SqlParseException): Encountered "count )" at line 1, column 12.
   Was expecting one of:
       "ALL" ...
       "ARRAY" ...
       "CASE" ...
       "CURRENT" ...
       "CURRENT_CATALOG" ...
       "CURRENT_DATE" ...
       "CURRENT_DEFAULT_TRANSFORM_GROUP" ...
       "CURRENT_PATH" ...
       "CURRENT_ROLE" ...
       "CURRENT_SCHEMA" ...
       "CURRENT_TIME" ...
   ```


-- 
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] kfaraz commented on issue #11909: Druid SQL cannot do aggregation on metric column with name "count"

Posted by GitBox <gi...@apache.org>.
kfaraz commented on issue #11909:
URL: https://github.com/apache/druid/issues/11909#issuecomment-976783496


   In json, it would look like this:
   
   ```
   {
       "query":"SELECT sum(\"count\") ..."
   }    
   ```
   
   Hope this resolves the issue.


-- 
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] zemin-piao closed issue #11909: Druid SQL cannot do aggregation on metric column with name "count"

Posted by GitBox <gi...@apache.org>.
zemin-piao closed issue #11909:
URL: https://github.com/apache/druid/issues/11909


   


-- 
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] kfaraz commented on issue #11909: Druid SQL cannot do aggregation on metric column with name "count"

Posted by GitBox <gi...@apache.org>.
kfaraz commented on issue #11909:
URL: https://github.com/apache/druid/issues/11909#issuecomment-966403406


   Using `count` as is would not work as it is a keyword/function name.
   Try using it within quotes, like `"count"`


-- 
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] zemin-piao commented on issue #11909: Druid SQL cannot do aggregation on metric column with name "count"

Posted by GitBox <gi...@apache.org>.
zemin-piao commented on issue #11909:
URL: https://github.com/apache/druid/issues/11909#issuecomment-973187200


   > Using `count` as is would not work as it is a keyword/function name. Try using it within quotes, like `"count"`
   > 
   > So the query would be something like `SELECT SUM("count") ...`
   
   Thanks a lot for your reply, that indeed works when the query itself is not in part of a json.
   
   The only edge case I've found is when we specify the query as part of json e.g. 
   ```{
   "query": "select sum(count) ..."
   }```
   
   Tried to use slash + quote, it does not work as well. Do we also have workaround for this scenario? 


-- 
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] zemin-piao commented on issue #11909: Druid SQL cannot do aggregation on metric column with name "count"

Posted by GitBox <gi...@apache.org>.
zemin-piao commented on issue #11909:
URL: https://github.com/apache/druid/issues/11909#issuecomment-981116713


   > In json, it would look like this:
   > 
   > ```
   > {
   >     "query":"SELECT sum(\"count\") ..."
   > }    
   > ```
   > 
   > Hope this resolves the issue.
   
   As I mentioned, Slash + double quote does not work. So naming columns using SQL keywords is strongly not recommended.   Will look into the project and debug a bit to start to get familiar with Druid. 
   
   Double quote:
   
   ```python
   import requests
   url = "http://localhost:8082/druid/v2/sql"
   headers = {"Content-Type": "application/json"}
   sql_json_for_query = """
   {"query": "select sum(\"count\") from wikipedia"}
   """
   requests.post(url, sql_json_for_query, headers=headers).text
   ```
   
   ```
   '<html>\n<head>\n<meta http-equiv="Content-Type" content="text/html;charset=utf-8"/>\n<title>Error 500 javax.servlet.ServletException: com.fasterxml.jackson.core.JsonParseException: Unexpected character (&apos;c&apos; (code 99)): was expecting comma to separate Object entries\n
   ```


-- 
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] zemin-piao commented on issue #11909: Druid SQL cannot do aggregation on metric column with name "count"

Posted by GitBox <gi...@apache.org>.
zemin-piao commented on issue #11909:
URL: https://github.com/apache/druid/issues/11909#issuecomment-981962361


   > ```python
   > ```python
   > import requests
   > url = "http://localhost:8082/druid/v2/sql"
   > headers = {"Content-Type": "application/json"}
   > sql_json_for_query = """
   > {"query": "select sum(\"count\") from wikipedia"}
   > """
   > requests.post(url, sql_json_for_query, headers=headers).text
   > ```
   > 
   > 
   >     
   >       
   >     
   > 
   >       
   >     
   > 
   >     
   >   
   > ```
   
   Thanks a lot, this works. Gonna close this issue then


-- 
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] kfaraz edited a comment on issue #11909: Druid SQL cannot do aggregation on metric column with name "count"

Posted by GitBox <gi...@apache.org>.
kfaraz edited a comment on issue #11909:
URL: https://github.com/apache/druid/issues/11909#issuecomment-966403406


   Using `count` as is would not work as it is a keyword/function name.
   Try using it within quotes, like `"count"`
   
   So the query would be something like `SELECT SUM("count") ...`


-- 
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] kfaraz commented on issue #11909: Druid SQL cannot do aggregation on metric column with name "count"

Posted by GitBox <gi...@apache.org>.
kfaraz commented on issue #11909:
URL: https://github.com/apache/druid/issues/11909#issuecomment-981264955


   If you are using python, you would have to escape backslash properly too.
   
   You might have to do something like this.
   
   ```
   sql_json_for_query = """
   {"query": "SELECT SUM(\\"count\\") FROM wikipedia"}
   """
   
   ```


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