druid icon indicating copy to clipboard operation
druid copied to clipboard

Preemptive restriction for queries with approximate count distinct on complex columns of unsupported type

Open Akshat-Jain opened this issue 7 months ago • 0 comments

Description

Currently, we don't support count (distinct complexColumn) + approximation for unsupported types, and the query execution fails with a ClassCastException:

Caused by: java.lang.ClassCastException: class org.apache.druid.segment.nested.StructuredData cannot be cast to class org.apache.druid.hll.HyperLogLogCollector (org.apache.druid.segment.nested.StructuredData and org.apache.druid.hll.HyperLogLogCollector are in unnamed module of loader 'app')

This PR aims to check if the complex column being queried aligns with the supported types in the aggregator and aggregator factories, and throws a user-friendly error message if they don't.

NOTE: This is a draft PR. The current state of the PR only makes these changes in 1 aggregator and 1 factory. If this makes sense to reviewers, I will add tests for the changes, and we can make similar changes for other aggregators and factories.

Error message after this PR's changes in sql layer: image

Error message after this PR's changes in native layer: image


This PR has:

  • [ ] been self-reviewed.
    • [ ] using the concurrency checklist (Remove this item if the PR doesn't have any relation to concurrency.)
  • [ ] added documentation for new or modified features or behaviors.
  • [ ] a release note entry in the PR description.
  • [ ] added Javadocs for most classes and all non-trivial methods. Linked related entities via Javadoc links.
  • [ ] added or updated version, license, or notice information in licenses.yaml
  • [ ] added comments explaining the "why" and the intent of the code wherever would not be obvious for an unfamiliar reader.
  • [ ] added unit tests or modified existing tests to cover new code paths, ensuring the threshold for code coverage is met.
  • [ ] added integration tests.
  • [ ] been tested in a test Druid cluster.

Akshat-Jain avatar Jul 02 '24 10:07 Akshat-Jain