Wang-qing-yang commented on issue #24662:
URL: 
https://github.com/apache/shardingsphere/issues/24662#issuecomment-1539266691

   Hi, This is wangqingyang,  I would like to work on pg_catalog of PostgreSQL. 
After learning from PR above, I didn't see any related issues about *Implement 
PostgreSQL system database query*, so I am not sure if the work should be done 
like this:
   
   1. create a .yaml file for each table under 
`infra/common/src/main/resources/schema/postgresql/pg_catalog/.` like 
*pg_aggregate.yaml*
   
   2. update enmu type in 
`infra/common/src/main/java/org/apache/shardingsphere/infra/metadata/database/schema/builder/SystemSchemaBuilderRule.java`
   
      ```java
      POSTGRESQL_PG_CATALOG("PostgreSQL", "pg_catalog", new 
HashSet<>(Arrays.asList("pg_class", "pg_database", "pg_inherits", 
"pg_tablespace", "pg_trigger", "pg_namespace"))),
      ```
   
   3. add test cases under 
`infra/common/src/test/java/org/apache/shardingsphere/infra/metadata/database/schema/builder/SystemSchemaBuilderTest.java`
   
      ```java
          @Test
          void assertBuildForPostgreSQL() {
              Map<String, ShardingSphereSchema> actual = 
SystemSchemaBuilder.build("sharding_db", new PostgreSQLDatabaseType());
              assertThat(actual.size(), is(3));
              assertTrue(actual.containsKey("information_schema"));
              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("shardingsphere").getTables().size(), 
is(2));
          }
      ```
   
      
`infra/common/src/test/java/org/apache/shardingsphere/infra/metadata/database/schema/builder/SystemSchemaBuilderRuleTest.java`
   
      ```java
      @Test
      void assertValueOfSchemaPathSuccess() {
          SystemSchemaBuilderRule actualInformationSchema = 
SystemSchemaBuilderRule.valueOf(new MySQLDatabaseType().getType(), 
"information_schema");
          assertThat(actualInformationSchema, 
is(SystemSchemaBuilderRule.MYSQL_INFORMATION_SCHEMA));
          assertThat(actualInformationSchema.getTables().size(), is(61));
          SystemSchemaBuilderRule actualMySQLSchema = 
SystemSchemaBuilderRule.valueOf(new MySQLDatabaseType().getType(), "mysql");
          assertThat(actualMySQLSchema, 
is(SystemSchemaBuilderRule.MYSQL_MYSQL));
          assertThat(actualMySQLSchema.getTables().size(), is(31));
          SystemSchemaBuilderRule actualPerformanceSchema = 
SystemSchemaBuilderRule.valueOf(new MySQLDatabaseType().getType(), 
"performance_schema");
          assertThat(actualPerformanceSchema, 
is(SystemSchemaBuilderRule.MYSQL_PERFORMANCE_SCHEMA));
          assertThat(actualPerformanceSchema.getTables().size(), is(87));
      }
      ```
   
        4. add the assertion file of the query result in 
`test/e2e/sql/src/test/resources/cases/dql/dataset/db/dql-integration-select-system-schema.xml`
   
   ```
   <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>
   ```
   
   add  assertion file under `test/resources/cases/dql/dataset/db/` like this: 
*select_postgresql_pg_catalog_pg_aggregate.xml*


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to