This is an automated email from the ASF dual-hosted git repository.

chengzhang pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/shardingsphere.git


The following commit(s) were added to refs/heads/master by this push:
     new bca571d9f17 add PostgreSQL pg_catalog table (#25752)
bca571d9f17 is described below

commit bca571d9f17ab8720f4eb057f030f64dd320e5a7
Author: qywang <[email protected]>
AuthorDate: Thu May 18 17:10:47 2023 +0800

    add PostgreSQL pg_catalog table (#25752)
    
    * add pg_aggregate
    
    * add pg_aggregate
---
 .../schema/builder/SystemSchemaBuilderRule.java    |   2 +-
 .../schema/postgresql/pg_catalog/pg_aggregate.yaml | 176 +++++++++++++++++++++
 .../builder/SystemSchemaBuilderRuleTest.java       |   5 +
 .../schema/builder/SystemSchemaBuilderTest.java    |   2 +-
 .../select_postgresql_pg_catalog_pg_aggregate.xml  |  43 +++++
 .../dql/dql-integration-select-system-schema.xml   |   4 +
 6 files changed, 230 insertions(+), 2 deletions(-)

diff --git 
a/infra/common/src/main/java/org/apache/shardingsphere/infra/metadata/database/schema/builder/SystemSchemaBuilderRule.java
 
b/infra/common/src/main/java/org/apache/shardingsphere/infra/metadata/database/schema/builder/SystemSchemaBuilderRule.java
index 2848826c0af..43cbd9c2167 100644
--- 
a/infra/common/src/main/java/org/apache/shardingsphere/infra/metadata/database/schema/builder/SystemSchemaBuilderRule.java
+++ 
b/infra/common/src/main/java/org/apache/shardingsphere/infra/metadata/database/schema/builder/SystemSchemaBuilderRule.java
@@ -76,7 +76,7 @@ public enum SystemSchemaBuilderRule {
     
     POSTGRESQL_INFORMATION_SCHEMA("PostgreSQL", "information_schema", new 
HashSet<>(Arrays.asList("columns", "tables", "views"))),
     
-    POSTGRESQL_PG_CATALOG("PostgreSQL", "pg_catalog", new 
HashSet<>(Arrays.asList("pg_class", "pg_database", "pg_inherits", 
"pg_tablespace", "pg_trigger", "pg_namespace"))),
+    POSTGRESQL_PG_CATALOG("PostgreSQL", "pg_catalog", new 
HashSet<>(Arrays.asList("pg_aggregate", "pg_class", "pg_database", 
"pg_inherits", "pg_tablespace", "pg_trigger", "pg_namespace"))),
     
     POSTGRESQL_SHARDING_SPHERE("PostgreSQL", "shardingsphere", new 
HashSet<>(Arrays.asList("sharding_table_statistics", "cluster_information"))),
     
diff --git 
a/infra/common/src/main/resources/schema/postgresql/pg_catalog/pg_aggregate.yaml
 
b/infra/common/src/main/resources/schema/postgresql/pg_catalog/pg_aggregate.yaml
new file mode 100644
index 00000000000..6d6be266cd2
--- /dev/null
+++ 
b/infra/common/src/main/resources/schema/postgresql/pg_catalog/pg_aggregate.yaml
@@ -0,0 +1,176 @@
+#
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements.  See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You 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.
+#
+
+name: pg_aggregate
+columns:
+  aggfnoid:
+    caseSensitive: true
+    dataType: 1111
+    generated: false
+    name: aggfnoid
+    primaryKey: false
+    visible: true
+  aggkind:
+    caseSensitive: true
+    dataType: 1
+    generated: false
+    name: aggkind
+    primaryKey: false
+    visible: true
+  aggnumdirectargs:
+    caseSensitive: true
+    dataType: 5
+    generated: false
+    name: aggnumdirectargs
+    primaryKey: false
+    visible: true
+  aggtransfn:
+    caseSensitive: true
+    dataType: 1111
+    generated: false
+    name: aggtransfn
+    primaryKey: false
+    visible: true
+  aggfinalfn:
+    caseSensitive: true
+    dataType: 1111
+    generated: false
+    name: aggfinalfn
+    primaryKey: false
+    visible: true
+  aggcombinefn:
+    caseSensitive: true
+    dataType: 1111
+    generated: false
+    name: aggcombinefn
+    primaryKey: false
+    visible: true
+  aggserialfn:
+    caseSensitive: true
+    dataType: 1111
+    generated: false
+    name: aggserialfn
+    primaryKey: false
+    visible: true
+  aggdeserialfn:
+    caseSensitive: true
+    dataType: 1111
+    generated: false
+    name: aggdeserialfn
+    primaryKey: false
+    visible: true
+  aggmtransfn:
+    caseSensitive: true
+    dataType: 1111
+    generated: false
+    name: aggmtransfn
+    primaryKey: false
+    visible: true
+  aggminvtransfn:
+    caseSensitive: true
+    dataType: 1111
+    generated: false
+    name: aggminvtransfn
+    primaryKey: false
+    visible: true
+  aggmfinalfn:
+    caseSensitive: true
+    dataType: 1111
+    generated: false
+    name: aggmfinalfn
+    primaryKey: false
+    visible: true
+  aggfinalextra:
+    caseSensitive: true
+    dataType: 16
+    generated: false
+    name: aggfinalextra
+    primaryKey: false
+    visible: true
+  aggmfinalextra:
+    caseSensitive: true
+    dataType: 16
+    generated: false
+    name: aggmfinalextra
+    primaryKey: false
+    visible: true
+  aggfinalmodify:
+    caseSensitive: true
+    dataType: 1
+    generated: false
+    name: aggfinalmodify
+    primaryKey: false
+    visible: true
+  aggmfinalmodify:
+    caseSensitive: true
+    dataType: 1
+    generated: false
+    name: aggmfinalmodify
+    primaryKey: false
+    visible: true
+  aggsortop:
+    caseSensitive: true
+    dataType: -5
+    generated: false
+    name: aggsortop
+    primaryKey: false
+    visible: true
+  aggtranstype:
+    caseSensitive: true
+    dataType: -5
+    generated: false
+    name: aggtranstype
+    primaryKey: false
+    visible: true
+  aggtransspace:
+    caseSensitive: true
+    dataType: 4
+    generated: false
+    name: aggtransspace
+    primaryKey: false
+    visible: true
+  aggmtranstype:
+    caseSensitive: true
+    dataType: -5
+    generated: false
+    name: aggmtranstype
+    primaryKey: false
+    visible: true
+  aggmtransspace:
+    caseSensitive: true
+    dataType: 4
+    generated: false
+    name: aggmtransspace
+    primaryKey: false
+    visible: true
+  agginitval:
+    caseSensitive: true
+    dataType: 12
+    generated: false
+    name: agginitval
+    primaryKey: false
+    visible: true
+  aggminitval:
+    caseSensitive: true
+    dataType: 12
+    generated: false
+    name: aggminitval
+    primaryKey: false
+    visible: true
+indexes:
+  pg_aggregate_fnoid_index:
+    name: pg_aggregate_fnoid_index
\ No newline at end of file
diff --git 
a/infra/common/src/test/java/org/apache/shardingsphere/infra/metadata/database/schema/builder/SystemSchemaBuilderRuleTest.java
 
b/infra/common/src/test/java/org/apache/shardingsphere/infra/metadata/database/schema/builder/SystemSchemaBuilderRuleTest.java
index 3f5613b70a4..96707963968 100644
--- 
a/infra/common/src/test/java/org/apache/shardingsphere/infra/metadata/database/schema/builder/SystemSchemaBuilderRuleTest.java
+++ 
b/infra/common/src/test/java/org/apache/shardingsphere/infra/metadata/database/schema/builder/SystemSchemaBuilderRuleTest.java
@@ -18,6 +18,7 @@
 package org.apache.shardingsphere.infra.metadata.database.schema.builder;
 
 import org.apache.shardingsphere.infra.database.type.dialect.MySQLDatabaseType;
+import 
org.apache.shardingsphere.infra.database.type.dialect.PostgreSQLDatabaseType;
 import org.junit.jupiter.api.Test;
 
 import static org.hamcrest.CoreMatchers.is;
@@ -39,6 +40,9 @@ class SystemSchemaBuilderRuleTest {
         SystemSchemaBuilderRule actualPerformanceSchema = 
SystemSchemaBuilderRule.valueOf(new MySQLDatabaseType().getType(), 
"performance_schema");
         assertThat(actualPerformanceSchema, 
is(SystemSchemaBuilderRule.MYSQL_PERFORMANCE_SCHEMA));
         assertThat(actualPerformanceSchema.getTables().size(), is(87));
+        SystemSchemaBuilderRule actualPgCatalog = 
SystemSchemaBuilderRule.valueOf(new PostgreSQLDatabaseType().getType(), 
"pg_catalog");
+        assertThat(actualPgCatalog, 
is(SystemSchemaBuilderRule.POSTGRESQL_PG_CATALOG));
+        assertThat(actualPgCatalog.getTables().size(), is(7));
     }
     
     @Test
@@ -50,6 +54,7 @@ class SystemSchemaBuilderRuleTest {
     void assertIsisSystemTable() {
         assertTrue(SystemSchemaBuilderRule.isSystemTable("information_schema", 
"columns"));
         assertTrue(SystemSchemaBuilderRule.isSystemTable("pg_catalog", 
"pg_database"));
+        assertTrue(SystemSchemaBuilderRule.isSystemTable("pg_catalog", 
"pg_aggregate"));
         assertFalse(SystemSchemaBuilderRule.isSystemTable("sharding_db", 
"t_order"));
     }
 }
diff --git 
a/infra/common/src/test/java/org/apache/shardingsphere/infra/metadata/database/schema/builder/SystemSchemaBuilderTest.java
 
b/infra/common/src/test/java/org/apache/shardingsphere/infra/metadata/database/schema/builder/SystemSchemaBuilderTest.java
index 78780e61ed3..ac140a4790b 100644
--- 
a/infra/common/src/test/java/org/apache/shardingsphere/infra/metadata/database/schema/builder/SystemSchemaBuilderTest.java
+++ 
b/infra/common/src/test/java/org/apache/shardingsphere/infra/metadata/database/schema/builder/SystemSchemaBuilderTest.java
@@ -55,7 +55,7 @@ class SystemSchemaBuilderTest {
         assertTrue(actual.containsKey("pg_catalog"));
         assertTrue(actual.containsKey("shardingsphere"));
         assertThat(actual.get("information_schema").getTables().size(), is(3));
-        assertThat(actual.get("pg_catalog").getTables().size(), is(6));
+        assertThat(actual.get("pg_catalog").getTables().size(), is(7));
         assertThat(actual.get("shardingsphere").getTables().size(), is(2));
     }
     
diff --git 
a/test/e2e/sql/src/test/resources/cases/dql/dataset/db/select_postgresql_pg_catalog_pg_aggregate.xml
 
b/test/e2e/sql/src/test/resources/cases/dql/dataset/db/select_postgresql_pg_catalog_pg_aggregate.xml
new file mode 100644
index 00000000000..b59569a8c04
--- /dev/null
+++ 
b/test/e2e/sql/src/test/resources/cases/dql/dataset/db/select_postgresql_pg_catalog_pg_aggregate.xml
@@ -0,0 +1,43 @@
+<!--
+  ~ Licensed to the Apache Software Foundation (ASF) under one or more
+  ~ contributor license agreements.  See the NOTICE file distributed with
+  ~ this work for additional information regarding copyright ownership.
+  ~ The ASF licenses this file to You 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.
+  -->
+
+<dataset>
+    <metadata>
+        <column name="aggfnoid" />
+        <column name="aggkind" />
+        <column name="aggnumdirectargs" />
+        <column name="aggtransfn" />
+        <column name="aggfinalfn" />
+        <column name="aggcombinefn" />
+        <column name="aggserialfn" />
+        <column name="aggdeserialfn" />
+        <column name="aggmtransfn" />
+        <column name="aggminvtransfn" />
+        <column name="aggmfinalfn" />
+        <column name="aggfinalextra" />
+        <column name="aggmfinalextra" />
+        <column name="aggfinalmodify" />
+        <column name="aggmfinalmodify" />
+        <column name="aggsortop" />
+        <column name="aggtranstype" />
+        <column name="aggtransspace" />
+        <column name="aggmtranstype" />
+        <column name="aggmtransspace" />
+        <column name="agginitval" />
+        <column name="aggminitval" />
+    </metadata>
+</dataset>
diff --git 
a/test/e2e/sql/src/test/resources/cases/dql/dql-integration-select-system-schema.xml
 
b/test/e2e/sql/src/test/resources/cases/dql/dql-integration-select-system-schema.xml
index 9ba7c7a251b..9714c8c12f3 100644
--- 
a/test/e2e/sql/src/test/resources/cases/dql/dql-integration-select-system-schema.xml
+++ 
b/test/e2e/sql/src/test/resources/cases/dql/dql-integration-select-system-schema.xml
@@ -716,4 +716,8 @@
     <test-case sql="SELECT * FROM performance_schema.variables_by_thread" 
db-types="MySQL" scenario-types="db">
         <assertion 
expected-data-file="select_mysql_performance_schema_variables_by_thread.xml" />
     </test-case>
+
+    <test-case sql="SELECT * FROM pg_catalog.pg_aggregate" 
db-types="PostgreSQL" scenario-types="db">
+        <assertion 
expected-data-file="select_postgresql_pg_catalog_pg_aggregate.xml" />
+    </test-case>
 </integration-test-cases>

Reply via email to