Skip to content

[Bug] Incorrect result of show create MTMV when partition by date_trunc alias #62910

@zwy991114

Description

@zwy991114

Search before asking

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

Version

master, latest version

What's Wrong?

The result returned by show create materialized view is inconsistent with the initial creation statement.

What You Expected?

The input and output of the creation statement shouled keep consistent.

How to Reproduce?

create table

CREATE TABLE test (
	`k1` LARGEINT NOT NULL,
	`k2` DATE NOT NULL
) ENGINE=OLAP
DUPLICATE KEY(`k1`)
COMMENT 'OLAP'
PARTITION BY range(`k2`)
(
PARTITION p_20200101 VALUES [("2020-01-01"),("2020-01-02")),
PARTITION p_20200102 VALUES [("2020-01-02"),("2020-01-03")),
PARTITION p_20200201 VALUES [("2020-02-01"),("2020-02-02"))
)
DISTRIBUTED BY HASH(`k1`) BUCKETS 2
PROPERTIES ('replication_num' = '1') ;

create mv

CREATE MATERIALIZED VIEW mv_month
BUILD DEFERRED REFRESH AUTO ON MANUAL
partition by (month_dt)
DISTRIBUTED BY RANDOM BUCKETS 2
PROPERTIES (
'replication_num' = '1'
)
AS select date_trunc(`k2`, 'month') as month_dt, k1 from test;

show create mv

CREATE MATERIALIZED VIEW mv_month
(month_dt,k1)
BUILD DEFERRED REFRESH AUTO ON MANUAL
DUPLICATE KEY(`month_dt`, `k1`)
PARTITION BY (date_trunc(`month_dt`, 'month'))
DISTRIBUTED BY RANDOM BUCKETS 2
PROPERTIES (
"replication_allocation" = "tag.location.default: 1",
"min_load_replica_num" = "-1",
"is_being_synced" = "false",
"storage_medium" = "hdd",
"storage_format" = "V2",
"inverted_index_storage_format" = "V3",
"light_schema_change" = "true",
"disable_auto_compaction" = "false",
"enable_single_replica_compaction" = "false",
"group_commit_interval_ms" = "10000",
"group_commit_data_bytes" = "134217728"
)
AS select date_trunc(`internal`.`test`.`test`.`k2`, 'month') as `month_dt`, `internal`.`test`.`test`.`k1` from `internal`.`test`.`test`

The output is PARTITION BY (date_trunc(month_dt, 'month')) while the input is partition by (month_dt).

Anything Else?

No response

Are you willing to submit PR?

  • Yes I am willing to submit a PR!

Code of Conduct

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions