Skip to content

Commit 12a6d2e

Browse files
add pg_enum table (#108)
* feat: add empty pg_range table to pg_catalog * chore: re-export arrow_pg and pgwire to simplify dependency management * fmt (#3) * pg_enum --------- Co-authored-by: madesroches <[email protected]>
1 parent dc66b5a commit 12a6d2e

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

datafusion-postgres/src/pg_catalog.rs

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ const PG_CATALOG_TABLE_PG_PROC: &str = "pg_proc";
2525
const PG_CATALOG_TABLE_PG_DATABASE: &str = "pg_database";
2626
const PG_CATALOG_TABLE_PG_AM: &str = "pg_am";
2727
const PG_CATALOG_TABLE_PG_RANGE: &str = "pg_range";
28+
const PG_CATALOG_TABLE_PG_ENUM: &str = "pg_enum";
2829

2930
/// Determine PostgreSQL table type (relkind) from DataFusion TableProvider
3031
fn get_table_type(table: &Arc<dyn TableProvider>) -> &'static str {
@@ -66,6 +67,7 @@ pub const PG_CATALOG_TABLES: &[&str] = &[
6667
PG_CATALOG_TABLE_PG_DATABASE,
6768
PG_CATALOG_TABLE_PG_AM,
6869
PG_CATALOG_TABLE_PG_RANGE,
70+
PG_CATALOG_TABLE_PG_ENUM,
6971
];
7072

7173
// Data structure to hold pg_type table data
@@ -252,6 +254,7 @@ impl SchemaProvider for PgCatalogSchemaProvider {
252254
}
253255
PG_CATALOG_TABLE_PG_PROC => Ok(Some(self.create_pg_proc_table())),
254256
PG_CATALOG_TABLE_PG_RANGE => Ok(Some(self.create_pg_range_table())),
257+
PG_CATALOG_TABLE_PG_ENUM => Ok(Some(self.create_pg_enum_table())),
255258
_ => Ok(None),
256259
}
257260
}
@@ -737,6 +740,18 @@ impl PgCatalogSchemaProvider {
737740
Arc::new(provider)
738741
}
739742

743+
/// Create a mock empty table for pg_enum
744+
fn create_pg_enum_table(&self) -> Arc<dyn TableProvider> {
745+
let schema = Arc::new(Schema::new(vec![
746+
Field::new("oid", DataType::Int32, false), // Row identifier
747+
Field::new("enumtypid", DataType::Int32, false), // The OID of the pg_type entry owning this enum value
748+
Field::new("enumsortorder", DataType::Float32, false), // The sort position of this enum value within its enum type
749+
Field::new("enumlabel", DataType::Utf8, false), // The textual label for this enum value
750+
]));
751+
let provider = MemTable::try_new(schema, vec![]).unwrap();
752+
Arc::new(provider)
753+
}
754+
740755
/// Create a populated pg_proc table with standard PostgreSQL functions
741756
fn create_pg_proc_table(&self) -> Arc<dyn TableProvider> {
742757
// Define complete schema for pg_proc (matching PostgreSQL)

0 commit comments

Comments
 (0)