Visitar URL original
[Bug] DUPLICATE KEY tables accept unsupported BITMAP/HLL/QUANTILE_STATE distribution columns · Issue #68749 · apache/doris · GitHub
Skip to content

[Bug] DUPLICATE KEY tables accept unsupported BITMAP/HLL/QUANTILE_STATE distribution columns #68749

Description

@zghong

Search before asking

  • I had searched in the issues and found no similar issues.

Version

4.1.4.1

What's Wrong?

A DUPLICATE KEY table can distribute on a non-key BITMAP column. With enable_non_aggregate_table_state_types enabled, HLL and QUANTILE_STATE columns are also accepted as distribution columns, although these types lack complete, correct write-side routing support:

  • BITMAP and QUANTILE_STATE have no case in RawValue::zlib_crc32() and reach the default DCHECK(false) followed by return 0. A real tablet-finder test reproduced BITMAP assertion termination in an ASAN subprocess. QUANTILE_STATE routing was inspected in source, not separately executed.
  • HLL has a case, but it hashes the C++ object memory returned by ColumnHLL::get_data_at(). In a real tablet-finder test, an original HLL, its copy and an independently deserialized instance have identical serialization but receive different bucket IDs.

Distribution-type validation already rejects ARRAY, MAP, STRUCT, JSONB, VARIANT and floating-point types, but omits these three state types. Relaxing table-model restrictions through the compatibility switch should not also permit unsupported distribution columns.

What You Expected?

CREATE TABLE should reject unsupported BITMAP, HLL and QUANTILE_STATE distribution columns with a clear error, even when the non-aggregate state-type compatibility switch is enabled.

How to Reproduce?

  1. With the default configuration, execute:
CREATE DATABASE IF NOT EXISTS issue_state_distribution;
USE issue_state_distribution;

DROP TABLE IF EXISTS bitmap_hash;
CREATE TABLE bitmap_hash (k INT, s BITMAP)
DUPLICATE KEY(k)
DISTRIBUTED BY HASH(s) BUCKETS 1
PROPERTIES ('replication_num' = '1');

SHOW CREATE TABLE bitmap_hash;

Actual: CREATE succeeds and the definition retains HASH(s), where s is BITMAP. This unsupported distribution definition should be rejected.

  1. Temporarily enable the compatibility switch on the same test cluster and execute the complete definitions for the other two state types:
ADMIN SET FRONTEND CONFIG
('enable_non_aggregate_table_state_types' = 'true');

DROP TABLE IF EXISTS hll_hash;
CREATE TABLE hll_hash (k INT, s HLL)
DUPLICATE KEY(k)
DISTRIBUTED BY HASH(s) BUCKETS 1
PROPERTIES ('replication_num' = '1');

SHOW CREATE TABLE hll_hash;

DROP TABLE IF EXISTS quantile_hash;
CREATE TABLE quantile_hash (k INT, s QUANTILE_STATE)
DUPLICATE KEY(k)
DISTRIBUTED BY HASH(s) BUCKETS 1
PROPERTIES ('replication_num' = '1');

SHOW CREATE TABLE quantile_hash;

ADMIN SET FRONTEND CONFIG
('enable_non_aggregate_table_state_types' = 'false');

Actual: both HLL and QUANTILE_STATE tables are created with state-type distribution columns. With the switch disabled, these two DUP definitions are rejected by the aggregate-table-only restriction. Once it is enabled, no independent distribution-type check rejects them.

Anything Else?

This admission gap is specific to DUPLICATE KEY tables because they allow non-key columns as distribution columns. AGGREGATE KEY and UNIQUE KEY tables require distribution columns to be key columns, and BITMAP, HLL and QUANTILE_STATE are already prohibited as key columns. Those existing restrictions prevent these types from being used for distribution in AGGREGATE KEY and UNIQUE KEY tables, whereas DUPLICATE KEY tables require an explicit distribution-type check.

Are you willing to submit PR?

  • Yes I am willing to submit a PR!

Code of Conduct

Activity

  1. Doris-Breakwater commented on Oct 7, 2026

    @Doris-Breakwater
    Collaborator

    Breakwater-GitHub-Analysis-Slot: slot_59ec37628f1c

    Initial assessment: This is a credible FE distribution-validation gap with a write-routing consequence. The supplied DDL and tablet-finder results are specific enough to investigate without additional logs. I inspected local upstream/branch-4.1 at 5e1ee245e23 (2026-09-25), not the exact 4.1.4.1 build, so runtime results below remain reporter-provided.

    Verified in that source snapshot: HashDistributionDesc.toDistributionInfo() calls HashDistributionInfo.checkDistributionColumnType(), which rejects several complex and floating-point types but has no BITMAP/HLL/QUANTILE_STATE case. VOlapTablePartitionParam::find_tablets() hashes each distribution column through RawValue::zlib_crc32(). That function has no BITMAP or QUANTILE_STATE case and reaches DCHECK(false)/return 0; its HLL case hashes the bytes from get_data_at(). ColumnComplexType::get_data_at() returns the C++ object's memory, not its serialized value. These paths explain the reported assertion and HLL bucket instability. The reporter executed BITMAP and HLL tablet-finder tests; QUANTILE_STATE routing was source-inspected only. I did not rerun those tests.

    Scope: FE already requires AGGREGATE/UNIQUE distribution columns to be keys, while the state types cannot be key columns. DUPLICATE KEY permits non-key distribution columns, exposing the omitted type check. The local snapshot lacks enable_non_aggregate_table_state_types, so its behavior in the exact 4.1.4.1 build still needs confirmation there.

    Suggested next steps: Reject all three state types in the shared hash-distribution column-type check, independent of the table-model compatibility switch, with a clear DDL error. Add CREATE TABLE regression cases for BITMAP under default settings and HLL/QUANTILE_STATE with the switch enabled, covering both SQL planner paths if applicable. Confirm the change also covers partition distribution overrides and does not invalidate existing tables during metadata loading. Use more than one bucket when checking HLL routing; BUCKETS 1 demonstrates DDL admission but cannot show bucket divergence. For exact-version confirmation, please attach the 4.1.4.1 FE/BE build commit IDs and the tablet-finder test or assertion output if available.

  2. yiguolei commented on Oct 10, 2026

    @yiguolei
    Contributor

    I think we should forbid using bitmap,hll, QUANTILE_STATE as distributed key columns or sorted key columns

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions