Skip to content

Commit 15ca07c

Browse files
authored
fix: analyze table contain keyword bug (#17131)
fix analyze contain keyword
1 parent 5f3afe0 commit 15ca07c

File tree

2 files changed

+23
-1
lines changed

2 files changed

+23
-1
lines changed

src/query/service/src/interpreters/interpreter_table_analyze.rs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -160,11 +160,16 @@ impl Interpreter for AnalyzeTableInterpreter {
160160
)
161161
};
162162

163+
let quote = self
164+
.ctx
165+
.get_settings()
166+
.get_sql_dialect()?
167+
.default_ident_quote();
163168
let index_cols: Vec<(u32, String)> = schema
164169
.fields()
165170
.iter()
166171
.filter(|f| RangeIndex::supported_type(&f.data_type().into()))
167-
.map(|f| (f.column_id(), f.name.clone()))
172+
.map(|f| (f.column_id(), format!("{quote}{}{quote}", f.name)))
168173
.collect();
169174

170175
// 0.01625 --> 12 buckets --> 4K size per column

tests/sqllogictests/suites/base/09_fuse_engine/09_0020_analyze.test

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,23 @@ CREATE DATABASE db_09_0020
77
statement ok
88
USE db_09_0020
99

10+
statement ok
11+
create or replace table t_17129(`offset` varchar);
12+
13+
statement ok
14+
insert into t_17129 values('ttt');
15+
16+
statement ok
17+
analyze table t_17129;
18+
19+
query TI
20+
select column_name, distinct_count from fuse_statistic('db_09_0020','t_17129');
21+
----
22+
offset 1
23+
24+
statement ok
25+
drop table t_17129;
26+
1027
statement ok
1128
create table t(a uint64)
1229

0 commit comments

Comments
 (0)