apache / doris

Apache Doris is an easy-to-use, high performance and unified analytics database.
https://doris.apache.org
Apache License 2.0
12.66k stars 3.27k forks source link

[Bug] Failed to execute CTAS. #12279

Closed siriume closed 2 years ago

siriume commented 2 years ago

Search before asking

Version

trunk-a49bde8

What's Wrong?

Test table like this

CREATE TABLE `test`
(
    `k1`    date          NOT NULL,
    `k2`    varchar(180)  NOT NULL,
     v1     decimal(27,9)
) ENGINE = OLAP UNIQUE KEY(`k1`) COMMENT 'ctas aggregate key column is varchar test'
DISTRIBUTED BY HASH(`k1`) BUCKETS 3
PROPERTIES (
"replication_num" = "1"
);

ctas table sql like this

create table ctas as
SELECT `k2`, sum(v1) AS sumv1
FROM test
GROUP BY k2;

error:

[HY000][1105] Unexpected exception: errCode = 2, detailMessage = Failed to execute CTAS Reason: errCode = 2, detailMessage = Key columns should be a ordered prefix of the schema. KeyColumns[0] (starts from zero) is sumv1, but corresponding column is k2 in the previous columns declaration.

What You Expected?

CTAS succeed

How to Reproduce?

No response

Anything Else?

No response

Are you willing to submit PR?

Code of Conduct

spihiker commented 2 years ago

create table as....没有这样的语法吧?是不是create view啊!

morningman commented 2 years ago

create table as....没有这样的语法吧?是不是creae view啊!

Doris support create table as select stmt