Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions datafusion-postgres/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,10 @@ use crate::auth::AuthManager;
use handlers::HandlerFactory;
pub use handlers::{DfSessionService, Parser};

/// re-exports
pub use arrow_pg;
pub use pgwire;

#[derive(Getters, Setters, WithSetters, Debug)]
#[getset(get = "pub", set = "pub", set_with = "pub")]
pub struct ServerOptions {
Expand Down
15 changes: 15 additions & 0 deletions datafusion-postgres/src/pg_catalog.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ const PG_CATALOG_TABLE_PG_PROC: &str = "pg_proc";
const PG_CATALOG_TABLE_PG_DATABASE: &str = "pg_database";
const PG_CATALOG_TABLE_PG_AM: &str = "pg_am";
const PG_CATALOG_TABLE_PG_RANGE: &str = "pg_range";
const PG_CATALOG_TABLE_PG_ENUM: &str = "pg_enum";

/// Determine PostgreSQL table type (relkind) from DataFusion TableProvider
fn get_table_type(table: &Arc<dyn TableProvider>) -> &'static str {
Expand Down Expand Up @@ -66,6 +67,7 @@ pub const PG_CATALOG_TABLES: &[&str] = &[
PG_CATALOG_TABLE_PG_DATABASE,
PG_CATALOG_TABLE_PG_AM,
PG_CATALOG_TABLE_PG_RANGE,
PG_CATALOG_TABLE_PG_ENUM,
];

// Data structure to hold pg_type table data
Expand Down Expand Up @@ -252,6 +254,7 @@ impl SchemaProvider for PgCatalogSchemaProvider {
}
PG_CATALOG_TABLE_PG_PROC => Ok(Some(self.create_pg_proc_table())),
PG_CATALOG_TABLE_PG_RANGE => Ok(Some(self.create_pg_range_table())),
PG_CATALOG_TABLE_PG_ENUM => Ok(Some(self.create_pg_enum_table())),
_ => Ok(None),
}
}
Expand Down Expand Up @@ -737,6 +740,18 @@ impl PgCatalogSchemaProvider {
Arc::new(provider)
}

/// Create a mock empty table for pg_enum
fn create_pg_enum_table(&self) -> Arc<dyn TableProvider> {
let schema = Arc::new(Schema::new(vec![
Field::new("oid", DataType::Int32, false), // Row identifier
Field::new("enumtypid", DataType::Int32, false), // The OID of the pg_type entry owning this enum value
Field::new("enumsortorder", DataType::Float32, false), // The sort position of this enum value within its enum type
Field::new("enumlabel", DataType::Utf8, false), // The textual label for this enum value
]));
let provider = MemTable::try_new(schema, vec![]).unwrap();
Arc::new(provider)
}

/// Create a populated pg_proc table with standard PostgreSQL functions
fn create_pg_proc_table(&self) -> Arc<dyn TableProvider> {
// Define complete schema for pg_proc (matching PostgreSQL)
Expand Down
Loading