Skip to content

Commit cb4853f

Browse files
committed
add unit test for pg_catalog.pg_collation table
1 parent b2702cc commit cb4853f

File tree

3 files changed

+32
-3
lines changed

3 files changed

+32
-3
lines changed

rust/cubesql/cubesql/src/compile/engine/context_postgresql.rs

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,9 @@ use super::information_schema::postgres::{
1919
InfoSchemaTestingBlockingProvider, InfoSchemaTestingDatasetProvider, PgCatalogAmProvider,
2020
PgCatalogAttrdefProvider, PgCatalogAttributeProvider, PgCatalogAuthMembersProvider,
2121
PgCatalogAvailableExtensionVersionsProvider, PgCatalogCastProvider, PgCatalogClassProvider,
22-
PgCatalogConstraintProvider, PgCatalogDatabaseProvider, PgCatalogDependProvider,
23-
PgCatalogDescriptionProvider, PgCatalogEnumProvider, PgCatalogEventTriggerProvider,
24-
PgCatalogExtensionProvider, PgCatalogForeignDataWrapperProvider,
22+
PgCatalogCollationProvider, PgCatalogConstraintProvider, PgCatalogDatabaseProvider,
23+
PgCatalogDependProvider, PgCatalogDescriptionProvider, PgCatalogEnumProvider,
24+
PgCatalogEventTriggerProvider, PgCatalogExtensionProvider, PgCatalogForeignDataWrapperProvider,
2525
PgCatalogForeignServerProvider, PgCatalogForeignTableProvider, PgCatalogIndexProvider,
2626
PgCatalogInheritsProvider, PgCatalogLanguageProvider, PgCatalogLocksProvider,
2727
PgCatalogMatviewsProvider, PgCatalogNamespaceProvider, PgCatalogOperatorProvider,
@@ -99,6 +99,8 @@ impl DatabaseProtocol {
9999
"pg_catalog.pg_index".to_string()
100100
} else if let Some(_) = any.downcast_ref::<PgCatalogClassProvider>() {
101101
"pg_catalog.pg_class".to_string()
102+
} else if let Some(_) = any.downcast_ref::<PgCatalogCollationProvider>() {
103+
"pg_catalog.pg_collation".to_string()
102104
} else if let Some(_) = any.downcast_ref::<PgCatalogProcProvider>() {
103105
"pg_catalog.pg_proc".to_string()
104106
} else if let Some(_) = any.downcast_ref::<PgCatalogSettingsProvider>() {
@@ -377,6 +379,7 @@ impl DatabaseProtocol {
377379
"pg_class" => {
378380
return Some(Arc::new(PgCatalogClassProvider::new(&context.meta.tables)))
379381
}
382+
"pg_collation" => return Some(Arc::new(PgCatalogCollationProvider::new())),
380383
"pg_proc" => return Some(Arc::new(PgCatalogProcProvider::new())),
381384
"pg_settings" => {
382385
return Some(Arc::new(PgCatalogSettingsProvider::new(

rust/cubesql/cubesql/src/compile/mod.rs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17698,4 +17698,17 @@ LIMIT {{ limit }}{% endif %}"#.to_string(),
1769817698
}
1769917699
)
1770017700
}
17701+
17702+
#[tokio::test]
17703+
async fn test_pg_collation() -> Result<(), CubeError> {
17704+
insta::assert_snapshot!(
17705+
"pg_collation",
17706+
execute_query(
17707+
"SELECT * FROM pg_catalog.pg_collation".to_string(),
17708+
DatabaseProtocol::PostgreSQL
17709+
)
17710+
.await?
17711+
);
17712+
Ok(())
17713+
}
1770117714
}
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
---
2+
source: cubesql/src/compile/mod.rs
3+
expression: "execute_query(\"SELECT * FROM pg_catalog.pg_collation\".to_string(),\nDatabaseProtocol::PostgreSQL).await?"
4+
---
5+
+-----+-----------+---------------+-----------+--------------+---------------------+--------------+---------------+-------------+-----------+------------+--------------+-------------+
6+
| oid | collname | collnamespace | collowner | collprovider | collisdeterministic | collencoding | colliculocale | collcollate | collctype | colllocale | collicurules | collversion |
7+
+-----+-----------+---------------+-----------+--------------+---------------------+--------------+---------------+-------------+-----------+------------+--------------+-------------+
8+
| 100 | default | 11 | 10 | d | true | -1 | NULL | NULL | NULL | NULL | NULL | NULL |
9+
| 950 | C | 11 | 10 | c | true | -1 | C | C | C | NULL | NULL | NULL |
10+
| 951 | POSIX | 11 | 10 | c | true | -1 | POSIX | POSIX | POSIX | NULL | NULL | NULL |
11+
| 962 | usc_basic | 11 | 10 | c | true | 6 | C | C | C | NULL | NULL | NULL |
12+
| 963 | unicode | 11 | 10 | i | true | -1 | NULL | NULL | NULL | und | NULL | 153.121 |
13+
+-----+-----------+---------------+-----------+--------------+---------------------+--------------+---------------+-------------+-----------+------------+--------------+-------------+

0 commit comments

Comments
 (0)