Skip to content

Commit

Permalink
[Bug](materialized-view) fix analyze where clause failed on mv (apach…
Browse files Browse the repository at this point in the history
…e#39061)

## Proposed changes
fix analyze where clause failed on mv
do not analyze slot after replaceSlot to avoid duplicate columns in desc
  • Loading branch information
BiteTheDDDDt authored Aug 9, 2024
1 parent 9986297 commit 3c78aed
Show file tree
Hide file tree
Showing 3 changed files with 71 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -679,6 +679,11 @@ public Expr getResultValue(boolean forPushDownPredicatesToView) throws AnalysisE

@Override
public void replaceSlot(TupleDescriptor tuple) {
// do not analyze slot after replaceSlot to avoid duplicate columns in desc
desc = tuple.getColumnSlot(col);
type = desc.getType();
if (!isAnalyzed) {
analysisDone();
}
}
}
Empty file.
Original file line number Diff line number Diff line change
Expand Up @@ -49,4 +49,70 @@ suite ("routine_load_mapping") {

qt_select "select * from test order by 1,2,3;"
qt_select_mv "select * from test index m_view order by 1,2;"


sql """ DROP TABLE IF EXISTS rt_new; """

sql """
CREATE TABLE `rt_new` (
`battery_id` VARCHAR(50) NULL ,
`create_time` DATETIME(3) NULL ,
`imei` VARCHAR(50) NULL ,
`event_id` VARCHAR(50) NULL ,
`event_name` VARCHAR(50) NULL,
`heart_type` INT NULL
) ENGINE=OLAP
DUPLICATE KEY(`battery_id`, `create_time`)
PARTITION BY RANGE(`create_time`)
(PARTITION p20240421 VALUES [('2024-04-21 00:00:00'), ('2024-04-22 00:00:00')),
PARTITION p20240422 VALUES [('2024-04-22 00:00:00'), ('2024-04-23 00:00:00')),
PARTITION p20240804 VALUES [('2024-08-04 00:00:00'), ('2024-08-05 00:00:00')))
DISTRIBUTED BY HASH(`battery_id`) BUCKETS AUTO
PROPERTIES (
"replication_allocation" = "tag.location.default: 1",
"file_cache_ttl_seconds" = "0",
"is_being_synced" = "false",
"dynamic_partition.enable" = "true",
"dynamic_partition.time_unit" = "DAY",
"dynamic_partition.time_zone" = "Asia/Shanghai",
"dynamic_partition.start" = "-2147483648",
"dynamic_partition.end" = "3",
"dynamic_partition.prefix" = "p",
"dynamic_partition.buckets" = "10",
"dynamic_partition.create_history_partition" = "true",
"dynamic_partition.history_partition_num" = "100",
"dynamic_partition.hot_partition_num" = "0",
"dynamic_partition.reserved_history_periods" = "NULL",
"storage_medium" = "hdd",
"storage_format" = "V2",
"inverted_index_storage_format" = "V2",
"light_schema_change" = "true",
"disable_auto_compaction" = "false",
"enable_single_replica_compaction" = "false",
"group_commit_interval_ms" = "10000",
"group_commit_data_bytes" = "134217728"
);
"""

createMV("""CREATE MATERIALIZED VIEW location_rt_mv AS
SELECT
battery_id,
create_time
FROM
rt_new
WHERE
heart_type = 1
;""")

sql """ ALTER TABLE rt_new MODIFY COLUMN event_id VARCHAR(51) NULL;"""
Thread.sleep(1000)

streamLoad {
table "rt_new"
set 'column_separator', ','
set 'columns', '`battery_id`,`create_time`,`imei`,`event_id`,`event_name`,`heart_type`'

file './test2'
time 10000 // limit inflight 10s
}
}

0 comments on commit 3c78aed

Please sign in to comment.