StarRocks/starrocks

Support Query ClickHouse AggregatingMergeTree Engine Table.

Open

#53,950 opened on Dec 15, 2024

View on GitHub
 (5 comments) (0 reactions) (2 assignees)Java (1,246 forks)batch import
good first issuetype/enhancement

Repository metrics

Stars
 (5,717 stars)
PR merge metrics
 (Avg merge 1d 6h) (970 merged PRs in 30d)

Description

Enhancement

StarRocks as Query Engine

Our team is trying to use StarRocks as a unified query engine layer. We are encountering issues when querying materialized views in ClickHouse.

e.g.

ClickHouse

CREATE DATABASE db0;
CREATE TABLE db0.simple (id UInt64, val SimpleAggregateFunction(sum, UInt64)) ENGINE=AggregatingMergeTree() ORDER BY id;
INSERT INTO db0.simple(id, val) VALUES (1, 10),(1, 11),(2, 12);

Expected Result

ClickHouse :) select id, sum(val) from db0.simple GROUP BY id;

SELECT
    id,
    sum(val)
FROM db0.simple
GROUP BY id

Query id: da27ce92-1f98-4790-9a3d-00f5e9d72b03

   ┌─id─┬─sum(val)─┐
1. │  2 │       12 │
2. │  1 │       21 │
   └────┴──────────┘

2 rows in set. Elapsed: 0.004 sec.

StarRocks

CREATE EXTERNAL CATALOG clickhouse
COMMENT 'example'
PROPERTIES
(
    "type"="jdbc", 
    "user"="default",
    "password"="",
    "jdbc_uri"="jdbc:clickhouse:[your ClickHouse address]:8123",
    "driver_url"="file:///[url]/clickhouse-jdbc-0.7.1-all.jar",
    "driver_class"="com.clickhouse.jdbc.ClickHouseDriver"
);

Query ClickHouse table from StarRocks

SELECT id, sum(val) FROM clickhouse.db0.simple GROUP BY id;

Got Error:

ERROR 1064 (HY000): Getting analyzing error. Detail message: Datatype of external table column [val] is not supported!.

Features Required

  1. Support AggregateFuntion types
  2. Support Aggregation pushdown

Contributor guide