Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Not implemented? SQLSubqueryTableSource cannot be cast to SQLJoinTableSource #333

Open
elyday opened this issue Nov 28, 2016 · 10 comments
Open

Comments

@elyday
Copy link

elyday commented Nov 28, 2016

Hi

i want to use two select queries in one query with ( ).
The SQL Query looks like:

SELECT * FROM (
	SELECT column, column2, column3, column4, SUM(column5) AS column6
	FROM jdbc
  	WHERE column2 >= 2016 AND column2 <= 2016 AND column3 = 'BIA' AND column4 IS NULL
  	GROUP BY column, column2, column3, column4
) WHERE column6 = 13315

The Stacktrace say this:

{"error":{"root_cause":[{"type":"class_cast_exception","reason":"com.alibaba.druid.sql.ast.statement.SQLSubqueryTableSource cannot be cast to com.alibaba.druid.sql.ast.statement.SQLJoinTableSource"}],"type":"class_cast_exception","reason":"com.alibaba.druid.sql.ast.statement.SQLSubqueryTableSource cannot be cast to com.alibaba.druid.sql.ast.statement.SQLJoinTableSource"},"status":500}

Have i an error in my sql query? Or is this not implemented yet?

Greetings

@eliranmoyal
Copy link
Contributor

eliranmoyal commented Nov 28, 2016

Hey ,
sorry this type of query is not implemented yet

@elyday
Copy link
Author

elyday commented Nov 29, 2016

Is this on a todo list or it isn't planed to implement this?

@eliranmoyal
Copy link
Contributor

For the more generic idea there is none (we are not planing querying data not by elasticsearch)
But I am planing to add something like "having clause" to help with this specific kind of queries. This called bucket selector aggregation https://www.elastic.co/guide/en/elasticsearch/reference/current/search-aggregations-pipeline-bucket-selector-aggregation.html

@elyday
Copy link
Author

elyday commented Nov 29, 2016

Okay, thats look really nice

@allwefantasy
Copy link
Member

allwefantasy commented Nov 30, 2016 via email

@michael-ancestor
Copy link

crate这个项目底层用的也是es,看它的document,支持了sub query、group by...having以及join,希望[ealsticsearch-sql]也能赶上

@justgig8
Copy link

Do we have support for HAVING clause now?

I wish to run the following SQL:-

select CUSTMR_ID.keyword, count(1) as count from engaged where ACTION = 'OPEN' group by CUSTMR_ID.keyword having count(1) > 4

Right now am trying to run this instead:-

select * from (select CUSTMR_ID.keyword, count(1) as count from engaged where ACTION = 'OPEN' group by CUSTMR_ID.keyword) a where a.count > 4

and am getting same exception as:-

{"error":{"root_cause":[{"type":"class_cast_exception","reason":"com.alibaba.druid.sql.ast.statement.SQLSubqueryTableSource cannot be cast to com.alibaba.druid.sql.ast.statement.SQLJoinTableSource"}],"type":"class_cast_exception","reason":"com.alibaba.druid.sql.ast.statement.SQLSubqueryTableSource cannot be cast to com.alibaba.druid.sql.ast.statement.SQLJoinTableSource"},"status":500}

@Desperado2
Copy link

I wish to run the following SQL:
SELECT name FROM (SELECT * FROM people) T GROUP BY name

and I getting same exception as:
java.lang.ClassCastException: com.alibaba.druid.sql.ast.statement.SQLSubqueryTableSource cannot be cast to com.alibaba.druid.sql.ast.statement.SQLJoinTableSource

is this not implemented yet?

@shi-yuan
Copy link
Member

shi-yuan commented Jan 5, 2020

SELECT name FROM people GROUP BY name

@iProcess
Copy link

I wish to run the following SQL:
select count(1) from (SELECT username,age,last,datetime,weight from table_config where username='aaa')
and I getting same exception as:
Caused by: java.lang.ClassCastException: com. alibaba.druid.sql.ast.statement.SQLSubqueryTableSource cannot be cast to com. alibaba.druid.sql.ast.statement.SQLJoinTableSource

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

8 participants