Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 2e178c3

Browse filesBrowse files
committed
Show view definition in information_schema.views.
1 parent 6d6ff2d commit 2e178c3
Copy full SHA for 2e178c3

File tree

Expand file treeCollapse file tree

6 files changed

+37
-16
lines changed
Filter options
Expand file treeCollapse file tree

6 files changed

+37
-16
lines changed

‎be/src/exec/schema_scanner/schema_views_scanner.cpp

Copy file name to clipboardExpand all lines: be/src/exec/schema_scanner/schema_views_scanner.cpp
+8-1Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,14 @@ Status SchemaViewsScanner::_fill_block_impl(vectorized::Block* block) {
140140
std::vector<void*> datas(tables_num);
141141

142142
// catalog
143-
{ RETURN_IF_ERROR(fill_dest_column_for_range(block, 0, null_datas)); }
143+
{
144+
std::string catalog_name = _db_result.catalogs[_db_index - 1];
145+
StringRef str = StringRef(catalog_name.c_str(), catalog_name.size());
146+
for (int i = 0; i < tables_num; ++i) {
147+
datas[i] = &str;
148+
}
149+
RETURN_IF_ERROR(fill_dest_column_for_range(block, 0, datas));
150+
}
144151
// schema
145152
{
146153
std::string db_name = SchemaHelper::extract_db_name(_db_result.dbs[_db_index - 1]);

‎fe/fe-core/src/main/java/org/apache/doris/service/FrontendServiceImpl.java

Copy file name to clipboardExpand all lines: fe/fe-core/src/main/java/org/apache/doris/service/FrontendServiceImpl.java
+4Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@
4545
import org.apache.doris.catalog.TableIf.TableType;
4646
import org.apache.doris.catalog.Tablet;
4747
import org.apache.doris.catalog.TabletMeta;
48+
import org.apache.doris.catalog.View;
4849
import org.apache.doris.cloud.catalog.CloudPartition;
4950
import org.apache.doris.cloud.catalog.CloudTablet;
5051
import org.apache.doris.cloud.proto.Cloud.CommitTxnResponse;
@@ -660,6 +661,9 @@ public TListTableStatusResult listTableStatus(TGetTablesParams params) throws TE
660661
status.setDataLength(table.getDataLength());
661662
status.setAvgRowLength(table.getAvgRowLength());
662663
status.setIndexLength(table.getIndexLength());
664+
if (table instanceof View) {
665+
status.setDdlSql(((View) table).getInlineViewDef());
666+
}
663667
tablesResult.add(status);
664668
} finally {
665669
table.readUnlock();

‎regression-test/data/nereids_p0/system/test_query_sys_tables.out

Copy file name to clipboardExpand all lines: regression-test/data/nereids_p0/system/test_query_sys_tables.out
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,5 +39,5 @@ wait_timeout 31000
3939
'nereids_test_sys_tables'@'%' SELECT NO
4040

4141
-- !views --
42-
test_view
42+
test_view SELECT `internal`.`test_query_sys_db_4`.`test_query_sys_tb_4`.`ccc` AS `a` FROM `internal`.`test_query_sys_db_4`.`test_query_sys_tb_4`
4343

‎regression-test/data/query_p0/system/test_query_sys_tables.out

Copy file name to clipboardExpand all lines: regression-test/data/query_p0/system/test_query_sys_tables.out
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,7 @@ wait_timeout 31000
172172
'original_test_sys_tables'@'%' SELECT NO
173173

174174
-- !views --
175-
test_view
175+
test_view SELECT `internal`.`test_query_sys_db_1`.`test_query_sys_tb_1`.`ccc` AS `a` FROM `internal`.`test_query_sys_db_1`.`test_query_sys_tb_1`
176176

177177
-- !sql --
178178

‎regression-test/data/view_p0/view_p0.out

Copy file name to clipboardExpand all lines: regression-test/data/view_p0/view_p0.out
+6Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,12 @@
88
-- !sql --
99
1
1010

11+
-- !information_schema1 --
12+
internal regression_test_view_p0 test_varchar_view SELECT GROUP_CONCAT(cast( `internal`.`regression_test_view_p0`.`test_view_table`.`id` as varchar)) AS `id` from `internal`.`regression_test_view_p0`.`test_view_table` NONE NO root@% DEFINER utf8 \N
13+
14+
-- !information_schema2 --
15+
internal regression_test_view_p0 test_view select 1,to_base64(AES_ENCRYPT('doris','doris')) NONE NO root@% DEFINER utf8 \N
16+
1117
-- !sql --
1218
1 2023-08-01 DORID_FIELD1 DORID_FIELD2 ["cat", "dog"] cat
1319
1 2023-08-01 DORID_FIELD1 DORID_FIELD2 ["cat", "dog"] dog

‎regression-test/suites/view_p0/view_p0.groovy

Copy file name to clipboardExpand all lines: regression-test/suites/view_p0/view_p0.groovy
+17-13Lines changed: 17 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -21,27 +21,30 @@ suite("view_p0") {
2121
create view test_view as select 1,to_base64(AES_ENCRYPT('doris','doris'));
2222
"""
2323
qt_sql "select * from test_view;"
24-
24+
2525
sql """DROP TABLE IF EXISTS test_view_table"""
26-
26+
2727
sql """
2828
create table test_view_table (id int) distributed by hash(id) properties('replication_num'='1');
2929
"""
30-
30+
3131
sql """insert into test_view_table values(1);"""
32-
32+
3333
sql """DROP VIEW IF EXISTS test_varchar_view"""
34-
34+
3535
sql """
3636
create view test_varchar_view (id) as SELECT GROUP_CONCAT(cast( id as varchar)) from test_view_table;
3737
"""
38-
38+
3939
qt_sql "select * from test_varchar_view;"
4040
qt_sql "select cast( id as varchar(65533)) from test_view_table;"
41-
41+
42+
qt_information_schema1 "select * from information_schema.views where TABLE_SCHEMA='regression_test_view_p0' and TABLE_NAME='test_varchar_view' order by table_catalog, table_schema, table_name;"
43+
qt_information_schema2 "select * from information_schema.views where TABLE_SCHEMA='regression_test_view_p0' and TABLE_NAME='test_view' order by table_catalog, table_schema, table_name;"
44+
4245
// array view
4346
sql """DROP TABLE IF EXISTS test_array_tbl_1"""
44-
47+
4548
sql """
4649
CREATE TABLE `test_array_tbl_1` (
4750
`id` int(11) NULL COMMENT "",
@@ -60,7 +63,7 @@ suite("view_p0") {
6063
"storage_format" = "V2"
6164
);
6265
"""
63-
66+
6467
sql """DROP TABLE IF EXISTS test_array_tbl_2"""
6568
sql """
6669
CREATE TABLE `test_array_tbl_2` (
@@ -81,11 +84,11 @@ suite("view_p0") {
8184
);
8285
"""
8386
sql """INSERT into test_array_tbl_1 values(1,'2023-08-01',"DORID_FIELD1","DORID_FIELD2",["cat","dog"],["cat","dog"])"""
84-
87+
8588
sql """INSERT into test_array_tbl_2 values(1,'2023-08-01',"DORID_FIELD1","DORID_FIELD2",["cat","dog"],["cat","dog"])"""
86-
89+
8790
sql """DROP VIEW IF EXISTS test_element_at_view"""
88-
91+
8992
sql """
9093
CREATE VIEW test_element_at_view AS
9194
SELECT id, dm, pn, field3, ms, ek[sm] AS ek
@@ -147,7 +150,7 @@ suite("view_p0") {
147150
sql "drop view if exists test_view_aes;"
148151

149152
sql """DROP TABLE IF EXISTS test_view_table2"""
150-
153+
151154
sql """
152155
CREATE TABLE test_view_table2 (
153156
c_date varchar(50)
@@ -172,3 +175,4 @@ suite("view_p0") {
172175
sql """ drop view if exists test_view_table2_view;"""
173176
sql """DROP TABLE IF EXISTS test_view_table2"""
174177
}
178+

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.