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

SQL: group by converted date doesn't work #37023

Closed
astefan opened this issue Dec 28, 2018 · 2 comments
Closed

SQL: group by converted date doesn't work #37023

astefan opened this issue Dec 28, 2018 · 2 comments

Comments

@astefan
Copy link
Contributor

astefan commented Dec 28, 2018

Test data:

POST localhost:9200/calcs/doc/_bulk

{"index":{}}
{"date2":"1977-04-20","date0":"2004-04-15"}
{"index":{}}
{"date2":"1995-09-03","date0":"1972-07-04"}
{"index":{}}
{"date2":"1997-09-19","date0":"1975-11-12"}
{"index":{}}
{"date2":"1980-07-26","date0":"2004-06-04"}
{"index":{}}
{"date2":"1997-05-30","date0":"2004-06-19"}

Query: SELECT {fn CONVERT(date0, SQL_DOUBLE)} AS x FROM calcs GROUP BY x

Result:

{
    "error": {
        "root_cause": [
            {
                "type": "sql_illegal_argument_exception",
                "reason": "No idea what's the DataType for class org.elasticsearch.script.JodaCompatibleZonedDateTime"
            }
        ],
        "type": "search_phase_execution_exception",
        "reason": "all shards failed",
        "phase": "query",
        "grouped": true,
        "failed_shards": [
            {
                "shard": 0,
                "index": "calcs",
                "node": "Aw7CDFFcQLmM_uCa97TTow",
                "reason": {
                    "type": "script_exception",
                    "reason": "runtime error",
                    "script_stack": [
                        "org.elasticsearch.xpack.sql.type.DataTypes.fromJava(DataTypes.java:79)",
                        "org.elasticsearch.xpack.sql.type.DataTypeConversion.convert(DataTypeConversion.java:372)",
                        "org.elasticsearch.xpack.sql.expression.function.scalar.whitelist.InternalSqlScriptUtils.cast(InternalSqlScriptUtils.java:471)",
                        "InternalSqlScriptUtils.cast(InternalSqlScriptUtils.docValue(doc,params.v0),params.v1)",
                        "                                                                                 ^---- HERE"
                    ],
                    "script": "InternalSqlScriptUtils.cast(InternalSqlScriptUtils.docValue(doc,params.v0),params.v1)",
                    "lang": "painless",
                    "caused_by": {
                        "type": "sql_illegal_argument_exception",
                        "reason": "No idea what's the DataType for class org.elasticsearch.script.JodaCompatibleZonedDateTime"
                    }
                }
            }
        ],
        "caused_by": {
            "type": "sql_illegal_argument_exception",
            "reason": "No idea what's the DataType for class org.elasticsearch.script.JodaCompatibleZonedDateTime"
        }
    },
    "status": 400
}
@elasticmachine
Copy link
Collaborator

Pinging @elastic/es-search

@astefan
Copy link
Contributor Author

astefan commented Jan 4, 2019

master (7.0.0): 3578e69
6.x (6.7.0): f2747b0
6.6 (6.6.0): 4e8c3ba

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

No branches or pull requests

3 participants