Skip to content

Commit 3556eb4

Browse files
authored
chore: add tests to comment column on information_schema (GreptimeTeam#7514)
* feat: show comment on information_schema Signed-off-by: Ruihang Xia <waynestxia@gmail.com> * add to information schema for columns, add sqlness tests Signed-off-by: Ruihang Xia <waynestxia@gmail.com> * remove duplications Signed-off-by: Ruihang Xia <waynestxia@gmail.com> * fix typo Signed-off-by: Ruihang Xia <waynestxia@gmail.com> * update integration test Signed-off-by: Ruihang Xia <waynestxia@gmail.com> --------- Signed-off-by: Ruihang Xia <waynestxia@gmail.com>
1 parent 9343da7 commit 3556eb4

File tree

5 files changed

+94
-5
lines changed

5 files changed

+94
-5
lines changed

src/catalog/src/system_schema/information_schema/columns.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -399,8 +399,8 @@ impl InformationSchemaColumnsBuilder {
399399
self.is_nullables.push(Some("No"));
400400
}
401401
self.column_types.push(Some(&data_type));
402-
self.column_comments
403-
.push(column_schema.column_comment().map(|x| x.as_ref()));
402+
let column_comment = column_schema.column_comment().map(|x| x.as_ref());
403+
self.column_comments.push(column_comment);
404404
}
405405

406406
fn finish(&mut self) -> Result<RecordBatch> {

src/query/src/dist_plan/commutativity.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@ impl Categorizer {
144144
}
145145
}
146146
// all group by expressions are partition columns can push down, unless
147-
// another push down(including `Limit` or `Sort`) is already in progress(which will then prvent next cond commutative node from being push down).
147+
// another push down(including `Limit` or `Sort`) is already in progress(which will then prevent next cond commutative node from being push down).
148148
// TODO(discord9): This is a temporary solution(that works), a better description of
149149
// commutativity is needed under this situation.
150150
Commutativity::ConditionalCommutative(None)

src/query/src/query_engine/state.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -234,7 +234,7 @@ impl QueryEngineState {
234234
rules.retain(|rule| rule.name() != name);
235235
}
236236

237-
/// Optimize the logical plan by the extension anayzer rules.
237+
/// Optimize the logical plan by the extension analyzer rules.
238238
pub fn optimize_by_extension_rules(
239239
&self,
240240
plan: DfLogicalPlan,

tests/cases/standalone/common/comment.result

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,17 @@ SHOW CREATE TABLE comment_table_test;
3232
| | ) |
3333
+--------------------+---------------------------------------------------+
3434

35+
SELECT table_comment
36+
FROM information_schema.tables
37+
WHERE table_schema = 'public'
38+
AND table_name = 'comment_table_test';
39+
40+
+-------------------------+
41+
| table_comment |
42+
+-------------------------+
43+
| table level description |
44+
+-------------------------+
45+
3546
-- Remove table comment
3647
COMMENT ON TABLE comment_table_test IS NULL;
3748

@@ -54,6 +65,17 @@ SHOW CREATE TABLE comment_table_test;
5465
| | |
5566
+--------------------+---------------------------------------------------+
5667

68+
SELECT table_comment
69+
FROM information_schema.tables
70+
WHERE table_schema = 'public'
71+
AND table_name = 'comment_table_test';
72+
73+
+---------------+
74+
| table_comment |
75+
+---------------+
76+
| |
77+
+---------------+
78+
5779
DROP TABLE comment_table_test;
5880

5981
Affected Rows: 0
@@ -90,6 +112,18 @@ SHOW CREATE TABLE comment_column_test;
90112
| | |
91113
+---------------------+---------------------------------------------------------+
92114

115+
SELECT column_comment
116+
FROM information_schema.columns
117+
WHERE table_schema = 'public'
118+
AND table_name = 'comment_column_test'
119+
AND column_name = 'val';
120+
121+
+--------------------------+
122+
| column_comment |
123+
+--------------------------+
124+
| value column description |
125+
+--------------------------+
126+
93127
-- Remove column comment
94128
COMMENT ON COLUMN comment_column_test.val IS NULL;
95129

@@ -112,6 +146,18 @@ SHOW CREATE TABLE comment_column_test;
112146
| | |
113147
+---------------------+----------------------------------------------------+
114148

149+
SELECT column_comment
150+
FROM information_schema.columns
151+
WHERE table_schema = 'public'
152+
AND table_name = 'comment_column_test'
153+
AND column_name = 'val';
154+
155+
+----------------+
156+
| column_comment |
157+
+----------------+
158+
| |
159+
+----------------+
160+
115161
DROP TABLE comment_column_test;
116162

117163
Affected Rows: 0
@@ -155,6 +201,16 @@ SHOW CREATE FLOW flow_comment_test;
155201
| | AS SELECT desc_str, ts FROM flow_source_comment_test |
156202
+-------------------+------------------------------------------------------+
157203

204+
SELECT comment
205+
FROM information_schema.flows
206+
WHERE flow_name = 'flow_comment_test';
207+
208+
+------------------------+
209+
| comment |
210+
+------------------------+
211+
| flow level description |
212+
+------------------------+
213+
158214
-- Remove flow comment
159215
COMMENT ON FLOW flow_comment_test IS NULL;
160216

@@ -170,6 +226,16 @@ SHOW CREATE FLOW flow_comment_test;
170226
| | AS SELECT desc_str, ts FROM flow_source_comment_test |
171227
+-------------------+------------------------------------------------------+
172228

229+
SELECT comment
230+
FROM information_schema.flows
231+
WHERE flow_name = 'flow_comment_test';
232+
233+
+---------+
234+
| comment |
235+
+---------+
236+
| |
237+
+---------+
238+
173239
DROP FLOW flow_comment_test;
174240

175241
Affected Rows: 0

tests/cases/standalone/common/comment.sql

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,18 @@ CREATE TABLE comment_table_test (
99
-- Add table comment
1010
COMMENT ON TABLE comment_table_test IS 'table level description';
1111
SHOW CREATE TABLE comment_table_test;
12+
SELECT table_comment
13+
FROM information_schema.tables
14+
WHERE table_schema = 'public'
15+
AND table_name = 'comment_table_test';
1216

1317
-- Remove table comment
1418
COMMENT ON TABLE comment_table_test IS NULL;
1519
SHOW CREATE TABLE comment_table_test;
20+
SELECT table_comment
21+
FROM information_schema.tables
22+
WHERE table_schema = 'public'
23+
AND table_name = 'comment_table_test';
1624

1725
DROP TABLE comment_table_test;
1826

@@ -27,10 +35,20 @@ CREATE TABLE comment_column_test (
2735
-- Add column comment
2836
COMMENT ON COLUMN comment_column_test.val IS 'value column description';
2937
SHOW CREATE TABLE comment_column_test;
38+
SELECT column_comment
39+
FROM information_schema.columns
40+
WHERE table_schema = 'public'
41+
AND table_name = 'comment_column_test'
42+
AND column_name = 'val';
3043

3144
-- Remove column comment
3245
COMMENT ON COLUMN comment_column_test.val IS NULL;
3346
SHOW CREATE TABLE comment_column_test;
47+
SELECT column_comment
48+
FROM information_schema.columns
49+
WHERE table_schema = 'public'
50+
AND table_name = 'comment_column_test'
51+
AND column_name = 'val';
3452

3553
DROP TABLE comment_column_test;
3654

@@ -54,12 +72,17 @@ SELECT desc_str, ts FROM flow_source_comment_test;
5472
-- Add flow comment
5573
COMMENT ON FLOW flow_comment_test IS 'flow level description';
5674
SHOW CREATE FLOW flow_comment_test;
75+
SELECT comment
76+
FROM information_schema.flows
77+
WHERE flow_name = 'flow_comment_test';
5778

5879
-- Remove flow comment
5980
COMMENT ON FLOW flow_comment_test IS NULL;
6081
SHOW CREATE FLOW flow_comment_test;
82+
SELECT comment
83+
FROM information_schema.flows
84+
WHERE flow_name = 'flow_comment_test';
6185

6286
DROP FLOW flow_comment_test;
6387
DROP TABLE flow_source_comment_test;
6488
DROP TABLE flow_sink_comment_test;
65-

0 commit comments

Comments
 (0)