Skip to content

SQL: Cannot use HAVING clause with aggregates and fields #71350

@costin

Description

@costin

Currently the HAVING clause translation takes into account only aggregations - however when dealing with subqueries, fields can be used as well:

SELECT * FROM (
  SELECT languages, COUNT(*) AS c FROM test_emp 
)
WHERE c > 0 OR languages IS NOT NULL

Due to the disjunction languages > 0 cannot be pushed down and the execution will fail due to the generated script being incorrect:

"source" : "InternalQlScriptUtils.nullSafeFilter(InternalQlScriptUtils.or(InternalQlScriptUtils.nullSafeFilter(InternalSqlScriptUtils.gt(params.a0,params.v0)),InternalQlScriptUtils.nullSafeFilter(InternalQlScriptUtils.isNotNull(InternalQlScriptUtils.docValue(doc,params.v2)))",

Metadata

Metadata

Assignees

No one assigned

    Labels

    :Analytics/SQLSQL querying>bugTeam:AnalyticsMeta label for analytical engine team (ESQL/Aggs/Geo)

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions