Skip to content

Druid: ARRAY expressions falsely mutated #36926

@its-felix

Description

@its-felix

Bug description

With the update to Superset 6.0.0, ARRAY expressions on Apache Druid are falsely mutated.

Any query with an array expression (i.e. ARRAY[1, 2, 3]) is mutated to a wrong form ARRAY(1, 2, 3), causing the following exception in Druid:

class org.apache.calcite.sql.fun.SqlArrayValueConstructor cannot be cast to class org.apache.calcite.sql.SqlFunction (org.apache.calcite.sql.fun.SqlArrayValueConstructor

I have created a fix in sqlglot at tobymao/sqlglot#6664

For other readers: the issue can be monkey-patched, i.e. in superset_config.py:

# monkey patch Druid Dialect (see https://github.com/apache/superset/issues/36926 / https://github.com/tobymao/sqlglot/pull/6664)
from sqlglot import exp
from sqlglot.dialects.druid import Druid
Druid.Generator.TRANSFORMS[exp.Array] = lambda self, e: f"ARRAY[{self.expressions(e)}]"

Screenshots/recordings

No response

Superset version

6.0.0 (Docker)

Python version

Whatever the 6.0.0 Docker Image uses

Node version

Whatever the 6.0.0 Docker Image uses

Browser

Chrome

Additional context

No response

Checklist

  • I have searched Superset docs and Slack and didn't find a solution to my problem.
  • I have searched the GitHub issue tracker and didn't find a similar bug report.
  • I have checked Superset's logs for errors and if I found a relevant Python stacktrace, I included it here as text in the "additional context" section.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions