Querying with JSON over HTTP dose not work

Hi,

I am very new to Druid and interesting in SQL query supported by 0.10.0 release. I following the instruction in https://github.com/druid-io/druid/blob/master/docs/content/querying/sql.md but for some reason i can not make it work.

Here is the output and query json.

curl -XPOST http://localhost:8082/druid/v2/sql/ -H ‘content-type: application/json’ -d @sql.json

{“error”:“Unknown exception”,“errorMessage”:"Encountered “-” at line 1, column 32.\nWas expecting one of:\n \n “ORDER” …\n “LIMIT” …\n “OFFSET” …\n “FETCH” …\n “NATURAL” …\n “JOIN” …\n “INNER” …\n “LEFT” …\n “RIGHT” …\n “FULL” …\n “CROSS” …\n “,” …\n “OUTER” …\n “EXTEND” …\n “(” …\n “.” …\n “AS” …\n …\n <QUOTED_IDENTIFIER> …\n <BACK_QUOTED_IDENTIFIER> …\n <BRACKET_QUOTED_IDENTIFIER> …\n <UNICODE_QUOTED_IDENTIFIER> …\n “TABLESAMPLE” …\n “WHERE” …\n “GROUP” …\n “HAVING” …\n “WINDOW” …\n “UNION” …\n “INTERSECT” …\n “EXCEPT” …\n “MINUS” …\n ",“errorClass”:“org.apache.calcite.sql.parser.SqlParseException”,“host”:null}

cat sql.json

{

“query”:“SELECT COUNT(*) FROM wikiticker-kafka”

}

But i can get the result via dsql as below:

SELECT COUNT(*) FROM “wikiticker-kafka”;

┌────────┐

│ EXPR$0 │

├────────┤

│ 2848 │

└────────┘

Retrieved 1 row in 1.06s.

Any suggestion will be appreciated!

Thanks in advance.

Does this work if you use the following JSON?

{

“query”:“SELECT COUNT(*) FROM ‘wikiticker-kafka’”

}

The “-” in wikiticker-kafka might require the datasource name to be quoted

I think it would need to be,

{

“query”:“SELECT COUNT(*) FROM “wikiticker-kafka””

}

Since identifiers are quoted with double quotes and literals are quoted with single quotes.

thank you all for the reply.

I realize it is due to the format. Now everything works just as expected.

Thanks again for the reply.