forked from risingwavelabs/risingwave
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(frontend): support
get_indexes
in sqlalchemy (risingwavelabs#6636
) * add indkey in pg_index * add pg_attribute * fix name of pg_matviews * fix dashboard * fix e2e * remove not related dashboard file * fix a slip and add e2e Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
- Loading branch information
1 parent
2ed9491
commit cded381
Showing
14 changed files
with
236 additions
and
28 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
statement ok | ||
create table tmp(id1 int, id2 int); | ||
|
||
query TIII | ||
select a.attname, a.atttypid, a.attlen, a.attnum from pg_catalog.pg_class t | ||
join pg_catalog.pg_attribute a on t.oid = a.attrelid | ||
where t.relname = 'tmp' order by a.attnum; | ||
---- | ||
id1 23 4 1 | ||
id2 23 4 2 | ||
|
||
statement ok | ||
create view view1 as select id2 from tmp; | ||
|
||
query TIII | ||
select a.attname, a.atttypid, a.attlen, a.attnum from pg_catalog.pg_class t | ||
join pg_catalog.pg_attribute a on t.oid = a.attrelid | ||
where t.relname = 'view1'; | ||
---- | ||
id2 23 4 1 | ||
|
||
|
||
statement ok | ||
drop view view1; | ||
|
||
statement ok | ||
drop table tmp; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
statement ok | ||
create table tmp(id1 int, id2 int); | ||
|
||
statement ok | ||
create index tmp_id2_idx on tmp(id2); | ||
|
||
query IT | ||
select ix.indnatts, ix.indkey from pg_catalog.pg_class t | ||
join pg_catalog.pg_index ix on t.oid = ix.indrelid | ||
join pg_catalog.pg_class i on i.oid = ix.indexrelid | ||
where t.relname = 'tmp' and i.relname = 'tmp_id2_idx'; | ||
---- | ||
1 {2} | ||
|
||
statement ok | ||
create index tmp_id2_idx_include_id1 on tmp(id2) include(id1); | ||
|
||
query IT | ||
select ix.indnatts, ix.indkey from pg_catalog.pg_class t | ||
join pg_catalog.pg_index ix on t.oid = ix.indrelid | ||
join pg_catalog.pg_class i on i.oid = ix.indexrelid | ||
where t.relname = 'tmp' and i.relname = 'tmp_id2_idx_include_id1'; | ||
---- | ||
2 {2,1} | ||
|
||
statement ok | ||
create index tmp_id1_id2_idx on tmp(id1, id2); | ||
|
||
query IT | ||
select ix.indnatts, ix.indkey from pg_catalog.pg_class t | ||
join pg_catalog.pg_index ix on t.oid = ix.indrelid | ||
join pg_catalog.pg_class i on i.oid = ix.indexrelid | ||
where t.relname = 'tmp' and i.relname = 'tmp_id1_id2_idx'; | ||
---- | ||
2 {1,2} | ||
|
||
statement ok | ||
drop table tmp; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
34 changes: 34 additions & 0 deletions
34
src/frontend/src/catalog/system_catalog/pg_catalog/pg_attribute.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
// Copyright 2022 Singularity Data | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
|
||
use risingwave_common::types::DataType; | ||
|
||
use crate::catalog::system_catalog::SystemCatalogColumnsDef; | ||
|
||
/// The catalog `pg_attribute` stores information about table columns. There will be exactly one | ||
/// `pg_attribute` row for every column in every table in the database. (There will also be | ||
/// attribute entries for indexes, and indeed all objects that have `pg_class` entries.) | ||
/// Ref: [`https://www.postgresql.org/docs/current/catalog-pg-attribute.html`] | ||
/// | ||
/// In RisingWave, we simply make it contain the columns of the view and all the columns of the | ||
/// tables that are not internal tables. | ||
pub const PG_ATTRIBUTE_TABLE_NAME: &str = "pg_attribute"; | ||
pub const PG_ATTRIBUTE_COLUMNS: &[SystemCatalogColumnsDef<'_>] = &[ | ||
(DataType::Int32, "attrelid"), | ||
(DataType::Varchar, "attname"), | ||
(DataType::Int32, "atttypid"), | ||
(DataType::Int16, "attlen"), | ||
(DataType::Int16, "attnum"), | ||
(DataType::Boolean, "attnotnull"), | ||
]; |
Oops, something went wrong.