mirror of
https://github.com/GreptimeTeam/greptimedb.git
synced 2026-01-14 09:12:57 +00:00
chore: add tests to comment column on information_schema (#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>
This commit is contained in:
@@ -399,8 +399,8 @@ impl InformationSchemaColumnsBuilder {
|
||||
self.is_nullables.push(Some("No"));
|
||||
}
|
||||
self.column_types.push(Some(&data_type));
|
||||
self.column_comments
|
||||
.push(column_schema.column_comment().map(|x| x.as_ref()));
|
||||
let column_comment = column_schema.column_comment().map(|x| x.as_ref());
|
||||
self.column_comments.push(column_comment);
|
||||
}
|
||||
|
||||
fn finish(&mut self) -> Result<RecordBatch> {
|
||||
|
||||
@@ -144,7 +144,7 @@ impl Categorizer {
|
||||
}
|
||||
}
|
||||
// all group by expressions are partition columns can push down, unless
|
||||
// another push down(including `Limit` or `Sort`) is already in progress(which will then prvent next cond commutative node from being push down).
|
||||
// another push down(including `Limit` or `Sort`) is already in progress(which will then prevent next cond commutative node from being push down).
|
||||
// TODO(discord9): This is a temporary solution(that works), a better description of
|
||||
// commutativity is needed under this situation.
|
||||
Commutativity::ConditionalCommutative(None)
|
||||
|
||||
@@ -234,7 +234,7 @@ impl QueryEngineState {
|
||||
rules.retain(|rule| rule.name() != name);
|
||||
}
|
||||
|
||||
/// Optimize the logical plan by the extension anayzer rules.
|
||||
/// Optimize the logical plan by the extension analyzer rules.
|
||||
pub fn optimize_by_extension_rules(
|
||||
&self,
|
||||
plan: DfLogicalPlan,
|
||||
|
||||
@@ -32,6 +32,17 @@ SHOW CREATE TABLE comment_table_test;
|
||||
| | ) |
|
||||
+--------------------+---------------------------------------------------+
|
||||
|
||||
SELECT table_comment
|
||||
FROM information_schema.tables
|
||||
WHERE table_schema = 'public'
|
||||
AND table_name = 'comment_table_test';
|
||||
|
||||
+-------------------------+
|
||||
| table_comment |
|
||||
+-------------------------+
|
||||
| table level description |
|
||||
+-------------------------+
|
||||
|
||||
-- Remove table comment
|
||||
COMMENT ON TABLE comment_table_test IS NULL;
|
||||
|
||||
@@ -54,6 +65,17 @@ SHOW CREATE TABLE comment_table_test;
|
||||
| | |
|
||||
+--------------------+---------------------------------------------------+
|
||||
|
||||
SELECT table_comment
|
||||
FROM information_schema.tables
|
||||
WHERE table_schema = 'public'
|
||||
AND table_name = 'comment_table_test';
|
||||
|
||||
+---------------+
|
||||
| table_comment |
|
||||
+---------------+
|
||||
| |
|
||||
+---------------+
|
||||
|
||||
DROP TABLE comment_table_test;
|
||||
|
||||
Affected Rows: 0
|
||||
@@ -90,6 +112,18 @@ SHOW CREATE TABLE comment_column_test;
|
||||
| | |
|
||||
+---------------------+---------------------------------------------------------+
|
||||
|
||||
SELECT column_comment
|
||||
FROM information_schema.columns
|
||||
WHERE table_schema = 'public'
|
||||
AND table_name = 'comment_column_test'
|
||||
AND column_name = 'val';
|
||||
|
||||
+--------------------------+
|
||||
| column_comment |
|
||||
+--------------------------+
|
||||
| value column description |
|
||||
+--------------------------+
|
||||
|
||||
-- Remove column comment
|
||||
COMMENT ON COLUMN comment_column_test.val IS NULL;
|
||||
|
||||
@@ -112,6 +146,18 @@ SHOW CREATE TABLE comment_column_test;
|
||||
| | |
|
||||
+---------------------+----------------------------------------------------+
|
||||
|
||||
SELECT column_comment
|
||||
FROM information_schema.columns
|
||||
WHERE table_schema = 'public'
|
||||
AND table_name = 'comment_column_test'
|
||||
AND column_name = 'val';
|
||||
|
||||
+----------------+
|
||||
| column_comment |
|
||||
+----------------+
|
||||
| |
|
||||
+----------------+
|
||||
|
||||
DROP TABLE comment_column_test;
|
||||
|
||||
Affected Rows: 0
|
||||
@@ -155,6 +201,16 @@ SHOW CREATE FLOW flow_comment_test;
|
||||
| | AS SELECT desc_str, ts FROM flow_source_comment_test |
|
||||
+-------------------+------------------------------------------------------+
|
||||
|
||||
SELECT comment
|
||||
FROM information_schema.flows
|
||||
WHERE flow_name = 'flow_comment_test';
|
||||
|
||||
+------------------------+
|
||||
| comment |
|
||||
+------------------------+
|
||||
| flow level description |
|
||||
+------------------------+
|
||||
|
||||
-- Remove flow comment
|
||||
COMMENT ON FLOW flow_comment_test IS NULL;
|
||||
|
||||
@@ -170,6 +226,16 @@ SHOW CREATE FLOW flow_comment_test;
|
||||
| | AS SELECT desc_str, ts FROM flow_source_comment_test |
|
||||
+-------------------+------------------------------------------------------+
|
||||
|
||||
SELECT comment
|
||||
FROM information_schema.flows
|
||||
WHERE flow_name = 'flow_comment_test';
|
||||
|
||||
+---------+
|
||||
| comment |
|
||||
+---------+
|
||||
| |
|
||||
+---------+
|
||||
|
||||
DROP FLOW flow_comment_test;
|
||||
|
||||
Affected Rows: 0
|
||||
|
||||
@@ -9,10 +9,18 @@ CREATE TABLE comment_table_test (
|
||||
-- Add table comment
|
||||
COMMENT ON TABLE comment_table_test IS 'table level description';
|
||||
SHOW CREATE TABLE comment_table_test;
|
||||
SELECT table_comment
|
||||
FROM information_schema.tables
|
||||
WHERE table_schema = 'public'
|
||||
AND table_name = 'comment_table_test';
|
||||
|
||||
-- Remove table comment
|
||||
COMMENT ON TABLE comment_table_test IS NULL;
|
||||
SHOW CREATE TABLE comment_table_test;
|
||||
SELECT table_comment
|
||||
FROM information_schema.tables
|
||||
WHERE table_schema = 'public'
|
||||
AND table_name = 'comment_table_test';
|
||||
|
||||
DROP TABLE comment_table_test;
|
||||
|
||||
@@ -27,10 +35,20 @@ CREATE TABLE comment_column_test (
|
||||
-- Add column comment
|
||||
COMMENT ON COLUMN comment_column_test.val IS 'value column description';
|
||||
SHOW CREATE TABLE comment_column_test;
|
||||
SELECT column_comment
|
||||
FROM information_schema.columns
|
||||
WHERE table_schema = 'public'
|
||||
AND table_name = 'comment_column_test'
|
||||
AND column_name = 'val';
|
||||
|
||||
-- Remove column comment
|
||||
COMMENT ON COLUMN comment_column_test.val IS NULL;
|
||||
SHOW CREATE TABLE comment_column_test;
|
||||
SELECT column_comment
|
||||
FROM information_schema.columns
|
||||
WHERE table_schema = 'public'
|
||||
AND table_name = 'comment_column_test'
|
||||
AND column_name = 'val';
|
||||
|
||||
DROP TABLE comment_column_test;
|
||||
|
||||
@@ -54,12 +72,17 @@ SELECT desc_str, ts FROM flow_source_comment_test;
|
||||
-- Add flow comment
|
||||
COMMENT ON FLOW flow_comment_test IS 'flow level description';
|
||||
SHOW CREATE FLOW flow_comment_test;
|
||||
SELECT comment
|
||||
FROM information_schema.flows
|
||||
WHERE flow_name = 'flow_comment_test';
|
||||
|
||||
-- Remove flow comment
|
||||
COMMENT ON FLOW flow_comment_test IS NULL;
|
||||
SHOW CREATE FLOW flow_comment_test;
|
||||
SELECT comment
|
||||
FROM information_schema.flows
|
||||
WHERE flow_name = 'flow_comment_test';
|
||||
|
||||
DROP FLOW flow_comment_test;
|
||||
DROP TABLE flow_source_comment_test;
|
||||
DROP TABLE flow_sink_comment_test;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user