Closed
Description
Ordering by a reference which itself points to an alias defined in a subquery will lead to a NPE:
SELECT g AS h FROM ( SELECT gender AS g FROM test_emp) ORDER BY h
will generate:
"type" : "null_pointer_exception",
"reason" : "Cannot invoke \"org.elasticsearch.xpack.ql.expression.Expression.hashCode()\" because \"e\" is null"
and grouping by it will raise:
"type" : "sql_illegal_argument_exception",
"reason" : "Cannot GROUP BY g{r}#18308"