diff --git a/Cargo.lock b/Cargo.lock index 8e22539..9f784d0 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1435,6 +1435,19 @@ dependencies = [ "regex-syntax", ] +[[package]] +name = "datafusion-pg-catalog" +version = "0.10.2" +dependencies = [ + "async-trait", + "datafusion", + "env_logger", + "futures", + "log", + "postgres-types", + "tokio", +] + [[package]] name = "datafusion-physical-expr" version = "50.0.0" @@ -1547,6 +1560,7 @@ dependencies = [ "bytes", "chrono", "datafusion", + "datafusion-pg-catalog", "env_logger", "futures", "getset", diff --git a/Cargo.toml b/Cargo.toml index 5ea5d75..65108a1 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [workspace] resolver = "2" -members = ["datafusion-postgres", "datafusion-postgres-cli", "arrow-pg"] +members = ["datafusion-postgres", "datafusion-postgres-cli", "arrow-pg", "datafusion-pg-catalog"] [workspace.package] version = "0.10.2" diff --git a/datafusion-pg-catalog/Cargo.toml b/datafusion-pg-catalog/Cargo.toml new file mode 100644 index 0000000..0cbc451 --- /dev/null +++ b/datafusion-pg-catalog/Cargo.toml @@ -0,0 +1,29 @@ +[package] +name = "datafusion-pg-catalog" +description = "pg_catalog compatibility for datafusion" +version.workspace = true +edition.workspace = true +license.workspace = true +authors.workspace = true +keywords.workspace = true +homepage.workspace = true +repository.workspace = true +documentation.workspace = true +readme = "../README.md" +rust-version.workspace = true +include = [ + "src/**/*", + "pg_catalog_arrow_exports/**/*", + "Cargo.toml" +] + +[dependencies] +async-trait = "0.1" +datafusion.workspace = true +futures.workspace = true +log = "0.4" +postgres-types.workspace = true +tokio = { version = "1.47", features = ["sync"] } + +[dev-dependencies] +env_logger = "0.11" diff --git a/datafusion-postgres/export_pg_catalog_arrow.sh b/datafusion-pg-catalog/export_pg_catalog_arrow.sh similarity index 100% rename from datafusion-postgres/export_pg_catalog_arrow.sh rename to datafusion-pg-catalog/export_pg_catalog_arrow.sh diff --git a/datafusion-postgres/pg_catalog_arrow_exports/pg_aggregate.feather b/datafusion-pg-catalog/pg_catalog_arrow_exports/pg_aggregate.feather similarity index 100% rename from datafusion-postgres/pg_catalog_arrow_exports/pg_aggregate.feather rename to datafusion-pg-catalog/pg_catalog_arrow_exports/pg_aggregate.feather diff --git a/datafusion-postgres/pg_catalog_arrow_exports/pg_am.feather b/datafusion-pg-catalog/pg_catalog_arrow_exports/pg_am.feather similarity index 100% rename from datafusion-postgres/pg_catalog_arrow_exports/pg_am.feather rename to datafusion-pg-catalog/pg_catalog_arrow_exports/pg_am.feather diff --git a/datafusion-postgres/pg_catalog_arrow_exports/pg_amop.feather b/datafusion-pg-catalog/pg_catalog_arrow_exports/pg_amop.feather similarity index 100% rename from datafusion-postgres/pg_catalog_arrow_exports/pg_amop.feather rename to datafusion-pg-catalog/pg_catalog_arrow_exports/pg_amop.feather diff --git a/datafusion-postgres/pg_catalog_arrow_exports/pg_amproc.feather b/datafusion-pg-catalog/pg_catalog_arrow_exports/pg_amproc.feather similarity index 100% rename from datafusion-postgres/pg_catalog_arrow_exports/pg_amproc.feather rename to datafusion-pg-catalog/pg_catalog_arrow_exports/pg_amproc.feather diff --git a/datafusion-postgres/pg_catalog_arrow_exports/pg_attrdef.feather b/datafusion-pg-catalog/pg_catalog_arrow_exports/pg_attrdef.feather similarity index 100% rename from datafusion-postgres/pg_catalog_arrow_exports/pg_attrdef.feather rename to datafusion-pg-catalog/pg_catalog_arrow_exports/pg_attrdef.feather diff --git a/datafusion-postgres/pg_catalog_arrow_exports/pg_attribute.feather b/datafusion-pg-catalog/pg_catalog_arrow_exports/pg_attribute.feather similarity index 100% rename from datafusion-postgres/pg_catalog_arrow_exports/pg_attribute.feather rename to datafusion-pg-catalog/pg_catalog_arrow_exports/pg_attribute.feather diff --git a/datafusion-postgres/pg_catalog_arrow_exports/pg_auth_members.feather b/datafusion-pg-catalog/pg_catalog_arrow_exports/pg_auth_members.feather similarity index 100% rename from datafusion-postgres/pg_catalog_arrow_exports/pg_auth_members.feather rename to datafusion-pg-catalog/pg_catalog_arrow_exports/pg_auth_members.feather diff --git a/datafusion-postgres/pg_catalog_arrow_exports/pg_authid.feather b/datafusion-pg-catalog/pg_catalog_arrow_exports/pg_authid.feather similarity index 100% rename from datafusion-postgres/pg_catalog_arrow_exports/pg_authid.feather rename to datafusion-pg-catalog/pg_catalog_arrow_exports/pg_authid.feather diff --git a/datafusion-postgres/pg_catalog_arrow_exports/pg_cast.feather b/datafusion-pg-catalog/pg_catalog_arrow_exports/pg_cast.feather similarity index 100% rename from datafusion-postgres/pg_catalog_arrow_exports/pg_cast.feather rename to datafusion-pg-catalog/pg_catalog_arrow_exports/pg_cast.feather diff --git a/datafusion-postgres/pg_catalog_arrow_exports/pg_class.feather b/datafusion-pg-catalog/pg_catalog_arrow_exports/pg_class.feather similarity index 100% rename from datafusion-postgres/pg_catalog_arrow_exports/pg_class.feather rename to datafusion-pg-catalog/pg_catalog_arrow_exports/pg_class.feather diff --git a/datafusion-postgres/pg_catalog_arrow_exports/pg_collation.feather b/datafusion-pg-catalog/pg_catalog_arrow_exports/pg_collation.feather similarity index 100% rename from datafusion-postgres/pg_catalog_arrow_exports/pg_collation.feather rename to datafusion-pg-catalog/pg_catalog_arrow_exports/pg_collation.feather diff --git a/datafusion-postgres/pg_catalog_arrow_exports/pg_constraint.feather b/datafusion-pg-catalog/pg_catalog_arrow_exports/pg_constraint.feather similarity index 100% rename from datafusion-postgres/pg_catalog_arrow_exports/pg_constraint.feather rename to datafusion-pg-catalog/pg_catalog_arrow_exports/pg_constraint.feather diff --git a/datafusion-postgres/pg_catalog_arrow_exports/pg_conversion.feather b/datafusion-pg-catalog/pg_catalog_arrow_exports/pg_conversion.feather similarity index 100% rename from datafusion-postgres/pg_catalog_arrow_exports/pg_conversion.feather rename to datafusion-pg-catalog/pg_catalog_arrow_exports/pg_conversion.feather diff --git a/datafusion-postgres/pg_catalog_arrow_exports/pg_database.feather b/datafusion-pg-catalog/pg_catalog_arrow_exports/pg_database.feather similarity index 100% rename from datafusion-postgres/pg_catalog_arrow_exports/pg_database.feather rename to datafusion-pg-catalog/pg_catalog_arrow_exports/pg_database.feather diff --git a/datafusion-postgres/pg_catalog_arrow_exports/pg_db_role_setting.feather b/datafusion-pg-catalog/pg_catalog_arrow_exports/pg_db_role_setting.feather similarity index 100% rename from datafusion-postgres/pg_catalog_arrow_exports/pg_db_role_setting.feather rename to datafusion-pg-catalog/pg_catalog_arrow_exports/pg_db_role_setting.feather diff --git a/datafusion-postgres/pg_catalog_arrow_exports/pg_default_acl.feather b/datafusion-pg-catalog/pg_catalog_arrow_exports/pg_default_acl.feather similarity index 100% rename from datafusion-postgres/pg_catalog_arrow_exports/pg_default_acl.feather rename to datafusion-pg-catalog/pg_catalog_arrow_exports/pg_default_acl.feather diff --git a/datafusion-postgres/pg_catalog_arrow_exports/pg_depend.feather b/datafusion-pg-catalog/pg_catalog_arrow_exports/pg_depend.feather similarity index 100% rename from datafusion-postgres/pg_catalog_arrow_exports/pg_depend.feather rename to datafusion-pg-catalog/pg_catalog_arrow_exports/pg_depend.feather diff --git a/datafusion-postgres/pg_catalog_arrow_exports/pg_description.feather b/datafusion-pg-catalog/pg_catalog_arrow_exports/pg_description.feather similarity index 100% rename from datafusion-postgres/pg_catalog_arrow_exports/pg_description.feather rename to datafusion-pg-catalog/pg_catalog_arrow_exports/pg_description.feather diff --git a/datafusion-postgres/pg_catalog_arrow_exports/pg_enum.feather b/datafusion-pg-catalog/pg_catalog_arrow_exports/pg_enum.feather similarity index 100% rename from datafusion-postgres/pg_catalog_arrow_exports/pg_enum.feather rename to datafusion-pg-catalog/pg_catalog_arrow_exports/pg_enum.feather diff --git a/datafusion-postgres/pg_catalog_arrow_exports/pg_event_trigger.feather b/datafusion-pg-catalog/pg_catalog_arrow_exports/pg_event_trigger.feather similarity index 100% rename from datafusion-postgres/pg_catalog_arrow_exports/pg_event_trigger.feather rename to datafusion-pg-catalog/pg_catalog_arrow_exports/pg_event_trigger.feather diff --git a/datafusion-postgres/pg_catalog_arrow_exports/pg_extension.feather b/datafusion-pg-catalog/pg_catalog_arrow_exports/pg_extension.feather similarity index 100% rename from datafusion-postgres/pg_catalog_arrow_exports/pg_extension.feather rename to datafusion-pg-catalog/pg_catalog_arrow_exports/pg_extension.feather diff --git a/datafusion-postgres/pg_catalog_arrow_exports/pg_foreign_data_wrapper.feather b/datafusion-pg-catalog/pg_catalog_arrow_exports/pg_foreign_data_wrapper.feather similarity index 100% rename from datafusion-postgres/pg_catalog_arrow_exports/pg_foreign_data_wrapper.feather rename to datafusion-pg-catalog/pg_catalog_arrow_exports/pg_foreign_data_wrapper.feather diff --git a/datafusion-postgres/pg_catalog_arrow_exports/pg_foreign_server.feather b/datafusion-pg-catalog/pg_catalog_arrow_exports/pg_foreign_server.feather similarity index 100% rename from datafusion-postgres/pg_catalog_arrow_exports/pg_foreign_server.feather rename to datafusion-pg-catalog/pg_catalog_arrow_exports/pg_foreign_server.feather diff --git a/datafusion-postgres/pg_catalog_arrow_exports/pg_foreign_table.feather b/datafusion-pg-catalog/pg_catalog_arrow_exports/pg_foreign_table.feather similarity index 100% rename from datafusion-postgres/pg_catalog_arrow_exports/pg_foreign_table.feather rename to datafusion-pg-catalog/pg_catalog_arrow_exports/pg_foreign_table.feather diff --git a/datafusion-postgres/pg_catalog_arrow_exports/pg_get_keywords.feather b/datafusion-pg-catalog/pg_catalog_arrow_exports/pg_get_keywords.feather similarity index 100% rename from datafusion-postgres/pg_catalog_arrow_exports/pg_get_keywords.feather rename to datafusion-pg-catalog/pg_catalog_arrow_exports/pg_get_keywords.feather diff --git a/datafusion-postgres/pg_catalog_arrow_exports/pg_index.feather b/datafusion-pg-catalog/pg_catalog_arrow_exports/pg_index.feather similarity index 100% rename from datafusion-postgres/pg_catalog_arrow_exports/pg_index.feather rename to datafusion-pg-catalog/pg_catalog_arrow_exports/pg_index.feather diff --git a/datafusion-postgres/pg_catalog_arrow_exports/pg_inherits.feather b/datafusion-pg-catalog/pg_catalog_arrow_exports/pg_inherits.feather similarity index 100% rename from datafusion-postgres/pg_catalog_arrow_exports/pg_inherits.feather rename to datafusion-pg-catalog/pg_catalog_arrow_exports/pg_inherits.feather diff --git a/datafusion-postgres/pg_catalog_arrow_exports/pg_init_privs.feather b/datafusion-pg-catalog/pg_catalog_arrow_exports/pg_init_privs.feather similarity index 100% rename from datafusion-postgres/pg_catalog_arrow_exports/pg_init_privs.feather rename to datafusion-pg-catalog/pg_catalog_arrow_exports/pg_init_privs.feather diff --git a/datafusion-postgres/pg_catalog_arrow_exports/pg_language.feather b/datafusion-pg-catalog/pg_catalog_arrow_exports/pg_language.feather similarity index 100% rename from datafusion-postgres/pg_catalog_arrow_exports/pg_language.feather rename to datafusion-pg-catalog/pg_catalog_arrow_exports/pg_language.feather diff --git a/datafusion-postgres/pg_catalog_arrow_exports/pg_largeobject.feather b/datafusion-pg-catalog/pg_catalog_arrow_exports/pg_largeobject.feather similarity index 100% rename from datafusion-postgres/pg_catalog_arrow_exports/pg_largeobject.feather rename to datafusion-pg-catalog/pg_catalog_arrow_exports/pg_largeobject.feather diff --git a/datafusion-postgres/pg_catalog_arrow_exports/pg_largeobject_metadata.feather b/datafusion-pg-catalog/pg_catalog_arrow_exports/pg_largeobject_metadata.feather similarity index 100% rename from datafusion-postgres/pg_catalog_arrow_exports/pg_largeobject_metadata.feather rename to datafusion-pg-catalog/pg_catalog_arrow_exports/pg_largeobject_metadata.feather diff --git a/datafusion-postgres/pg_catalog_arrow_exports/pg_namespace.feather b/datafusion-pg-catalog/pg_catalog_arrow_exports/pg_namespace.feather similarity index 100% rename from datafusion-postgres/pg_catalog_arrow_exports/pg_namespace.feather rename to datafusion-pg-catalog/pg_catalog_arrow_exports/pg_namespace.feather diff --git a/datafusion-postgres/pg_catalog_arrow_exports/pg_opclass.feather b/datafusion-pg-catalog/pg_catalog_arrow_exports/pg_opclass.feather similarity index 100% rename from datafusion-postgres/pg_catalog_arrow_exports/pg_opclass.feather rename to datafusion-pg-catalog/pg_catalog_arrow_exports/pg_opclass.feather diff --git a/datafusion-postgres/pg_catalog_arrow_exports/pg_operator.feather b/datafusion-pg-catalog/pg_catalog_arrow_exports/pg_operator.feather similarity index 100% rename from datafusion-postgres/pg_catalog_arrow_exports/pg_operator.feather rename to datafusion-pg-catalog/pg_catalog_arrow_exports/pg_operator.feather diff --git a/datafusion-postgres/pg_catalog_arrow_exports/pg_opfamily.feather b/datafusion-pg-catalog/pg_catalog_arrow_exports/pg_opfamily.feather similarity index 100% rename from datafusion-postgres/pg_catalog_arrow_exports/pg_opfamily.feather rename to datafusion-pg-catalog/pg_catalog_arrow_exports/pg_opfamily.feather diff --git a/datafusion-postgres/pg_catalog_arrow_exports/pg_parameter_acl.feather b/datafusion-pg-catalog/pg_catalog_arrow_exports/pg_parameter_acl.feather similarity index 100% rename from datafusion-postgres/pg_catalog_arrow_exports/pg_parameter_acl.feather rename to datafusion-pg-catalog/pg_catalog_arrow_exports/pg_parameter_acl.feather diff --git a/datafusion-postgres/pg_catalog_arrow_exports/pg_partitioned_table.feather b/datafusion-pg-catalog/pg_catalog_arrow_exports/pg_partitioned_table.feather similarity index 100% rename from datafusion-postgres/pg_catalog_arrow_exports/pg_partitioned_table.feather rename to datafusion-pg-catalog/pg_catalog_arrow_exports/pg_partitioned_table.feather diff --git a/datafusion-postgres/pg_catalog_arrow_exports/pg_policy.feather b/datafusion-pg-catalog/pg_catalog_arrow_exports/pg_policy.feather similarity index 100% rename from datafusion-postgres/pg_catalog_arrow_exports/pg_policy.feather rename to datafusion-pg-catalog/pg_catalog_arrow_exports/pg_policy.feather diff --git a/datafusion-postgres/pg_catalog_arrow_exports/pg_proc.feather b/datafusion-pg-catalog/pg_catalog_arrow_exports/pg_proc.feather similarity index 100% rename from datafusion-postgres/pg_catalog_arrow_exports/pg_proc.feather rename to datafusion-pg-catalog/pg_catalog_arrow_exports/pg_proc.feather diff --git a/datafusion-postgres/pg_catalog_arrow_exports/pg_publication.feather b/datafusion-pg-catalog/pg_catalog_arrow_exports/pg_publication.feather similarity index 100% rename from datafusion-postgres/pg_catalog_arrow_exports/pg_publication.feather rename to datafusion-pg-catalog/pg_catalog_arrow_exports/pg_publication.feather diff --git a/datafusion-postgres/pg_catalog_arrow_exports/pg_publication_namespace.feather b/datafusion-pg-catalog/pg_catalog_arrow_exports/pg_publication_namespace.feather similarity index 100% rename from datafusion-postgres/pg_catalog_arrow_exports/pg_publication_namespace.feather rename to datafusion-pg-catalog/pg_catalog_arrow_exports/pg_publication_namespace.feather diff --git a/datafusion-postgres/pg_catalog_arrow_exports/pg_publication_rel.feather b/datafusion-pg-catalog/pg_catalog_arrow_exports/pg_publication_rel.feather similarity index 100% rename from datafusion-postgres/pg_catalog_arrow_exports/pg_publication_rel.feather rename to datafusion-pg-catalog/pg_catalog_arrow_exports/pg_publication_rel.feather diff --git a/datafusion-postgres/pg_catalog_arrow_exports/pg_range.feather b/datafusion-pg-catalog/pg_catalog_arrow_exports/pg_range.feather similarity index 100% rename from datafusion-postgres/pg_catalog_arrow_exports/pg_range.feather rename to datafusion-pg-catalog/pg_catalog_arrow_exports/pg_range.feather diff --git a/datafusion-postgres/pg_catalog_arrow_exports/pg_replication_origin.feather b/datafusion-pg-catalog/pg_catalog_arrow_exports/pg_replication_origin.feather similarity index 100% rename from datafusion-postgres/pg_catalog_arrow_exports/pg_replication_origin.feather rename to datafusion-pg-catalog/pg_catalog_arrow_exports/pg_replication_origin.feather diff --git a/datafusion-postgres/pg_catalog_arrow_exports/pg_rewrite.feather b/datafusion-pg-catalog/pg_catalog_arrow_exports/pg_rewrite.feather similarity index 100% rename from datafusion-postgres/pg_catalog_arrow_exports/pg_rewrite.feather rename to datafusion-pg-catalog/pg_catalog_arrow_exports/pg_rewrite.feather diff --git a/datafusion-postgres/pg_catalog_arrow_exports/pg_seclabel.feather b/datafusion-pg-catalog/pg_catalog_arrow_exports/pg_seclabel.feather similarity index 100% rename from datafusion-postgres/pg_catalog_arrow_exports/pg_seclabel.feather rename to datafusion-pg-catalog/pg_catalog_arrow_exports/pg_seclabel.feather diff --git a/datafusion-postgres/pg_catalog_arrow_exports/pg_sequence.feather b/datafusion-pg-catalog/pg_catalog_arrow_exports/pg_sequence.feather similarity index 100% rename from datafusion-postgres/pg_catalog_arrow_exports/pg_sequence.feather rename to datafusion-pg-catalog/pg_catalog_arrow_exports/pg_sequence.feather diff --git a/datafusion-postgres/pg_catalog_arrow_exports/pg_shdepend.feather b/datafusion-pg-catalog/pg_catalog_arrow_exports/pg_shdepend.feather similarity index 100% rename from datafusion-postgres/pg_catalog_arrow_exports/pg_shdepend.feather rename to datafusion-pg-catalog/pg_catalog_arrow_exports/pg_shdepend.feather diff --git a/datafusion-postgres/pg_catalog_arrow_exports/pg_shdescription.feather b/datafusion-pg-catalog/pg_catalog_arrow_exports/pg_shdescription.feather similarity index 100% rename from datafusion-postgres/pg_catalog_arrow_exports/pg_shdescription.feather rename to datafusion-pg-catalog/pg_catalog_arrow_exports/pg_shdescription.feather diff --git a/datafusion-postgres/pg_catalog_arrow_exports/pg_shseclabel.feather b/datafusion-pg-catalog/pg_catalog_arrow_exports/pg_shseclabel.feather similarity index 100% rename from datafusion-postgres/pg_catalog_arrow_exports/pg_shseclabel.feather rename to datafusion-pg-catalog/pg_catalog_arrow_exports/pg_shseclabel.feather diff --git a/datafusion-postgres/pg_catalog_arrow_exports/pg_statistic.feather b/datafusion-pg-catalog/pg_catalog_arrow_exports/pg_statistic.feather similarity index 100% rename from datafusion-postgres/pg_catalog_arrow_exports/pg_statistic.feather rename to datafusion-pg-catalog/pg_catalog_arrow_exports/pg_statistic.feather diff --git a/datafusion-postgres/pg_catalog_arrow_exports/pg_statistic_ext.feather b/datafusion-pg-catalog/pg_catalog_arrow_exports/pg_statistic_ext.feather similarity index 100% rename from datafusion-postgres/pg_catalog_arrow_exports/pg_statistic_ext.feather rename to datafusion-pg-catalog/pg_catalog_arrow_exports/pg_statistic_ext.feather diff --git a/datafusion-postgres/pg_catalog_arrow_exports/pg_statistic_ext_data.feather b/datafusion-pg-catalog/pg_catalog_arrow_exports/pg_statistic_ext_data.feather similarity index 100% rename from datafusion-postgres/pg_catalog_arrow_exports/pg_statistic_ext_data.feather rename to datafusion-pg-catalog/pg_catalog_arrow_exports/pg_statistic_ext_data.feather diff --git a/datafusion-postgres/pg_catalog_arrow_exports/pg_subscription.feather b/datafusion-pg-catalog/pg_catalog_arrow_exports/pg_subscription.feather similarity index 100% rename from datafusion-postgres/pg_catalog_arrow_exports/pg_subscription.feather rename to datafusion-pg-catalog/pg_catalog_arrow_exports/pg_subscription.feather diff --git a/datafusion-postgres/pg_catalog_arrow_exports/pg_subscription_rel.feather b/datafusion-pg-catalog/pg_catalog_arrow_exports/pg_subscription_rel.feather similarity index 100% rename from datafusion-postgres/pg_catalog_arrow_exports/pg_subscription_rel.feather rename to datafusion-pg-catalog/pg_catalog_arrow_exports/pg_subscription_rel.feather diff --git a/datafusion-postgres/pg_catalog_arrow_exports/pg_tablespace.feather b/datafusion-pg-catalog/pg_catalog_arrow_exports/pg_tablespace.feather similarity index 100% rename from datafusion-postgres/pg_catalog_arrow_exports/pg_tablespace.feather rename to datafusion-pg-catalog/pg_catalog_arrow_exports/pg_tablespace.feather diff --git a/datafusion-postgres/pg_catalog_arrow_exports/pg_transform.feather b/datafusion-pg-catalog/pg_catalog_arrow_exports/pg_transform.feather similarity index 100% rename from datafusion-postgres/pg_catalog_arrow_exports/pg_transform.feather rename to datafusion-pg-catalog/pg_catalog_arrow_exports/pg_transform.feather diff --git a/datafusion-postgres/pg_catalog_arrow_exports/pg_trigger.feather b/datafusion-pg-catalog/pg_catalog_arrow_exports/pg_trigger.feather similarity index 100% rename from datafusion-postgres/pg_catalog_arrow_exports/pg_trigger.feather rename to datafusion-pg-catalog/pg_catalog_arrow_exports/pg_trigger.feather diff --git a/datafusion-postgres/pg_catalog_arrow_exports/pg_ts_config.feather b/datafusion-pg-catalog/pg_catalog_arrow_exports/pg_ts_config.feather similarity index 100% rename from datafusion-postgres/pg_catalog_arrow_exports/pg_ts_config.feather rename to datafusion-pg-catalog/pg_catalog_arrow_exports/pg_ts_config.feather diff --git a/datafusion-postgres/pg_catalog_arrow_exports/pg_ts_config_map.feather b/datafusion-pg-catalog/pg_catalog_arrow_exports/pg_ts_config_map.feather similarity index 100% rename from datafusion-postgres/pg_catalog_arrow_exports/pg_ts_config_map.feather rename to datafusion-pg-catalog/pg_catalog_arrow_exports/pg_ts_config_map.feather diff --git a/datafusion-postgres/pg_catalog_arrow_exports/pg_ts_dict.feather b/datafusion-pg-catalog/pg_catalog_arrow_exports/pg_ts_dict.feather similarity index 100% rename from datafusion-postgres/pg_catalog_arrow_exports/pg_ts_dict.feather rename to datafusion-pg-catalog/pg_catalog_arrow_exports/pg_ts_dict.feather diff --git a/datafusion-postgres/pg_catalog_arrow_exports/pg_ts_parser.feather b/datafusion-pg-catalog/pg_catalog_arrow_exports/pg_ts_parser.feather similarity index 100% rename from datafusion-postgres/pg_catalog_arrow_exports/pg_ts_parser.feather rename to datafusion-pg-catalog/pg_catalog_arrow_exports/pg_ts_parser.feather diff --git a/datafusion-postgres/pg_catalog_arrow_exports/pg_ts_template.feather b/datafusion-pg-catalog/pg_catalog_arrow_exports/pg_ts_template.feather similarity index 100% rename from datafusion-postgres/pg_catalog_arrow_exports/pg_ts_template.feather rename to datafusion-pg-catalog/pg_catalog_arrow_exports/pg_ts_template.feather diff --git a/datafusion-postgres/pg_catalog_arrow_exports/pg_type.feather b/datafusion-pg-catalog/pg_catalog_arrow_exports/pg_type.feather similarity index 100% rename from datafusion-postgres/pg_catalog_arrow_exports/pg_type.feather rename to datafusion-pg-catalog/pg_catalog_arrow_exports/pg_type.feather diff --git a/datafusion-postgres/pg_catalog_arrow_exports/pg_user_mapping.feather b/datafusion-pg-catalog/pg_catalog_arrow_exports/pg_user_mapping.feather similarity index 100% rename from datafusion-postgres/pg_catalog_arrow_exports/pg_user_mapping.feather rename to datafusion-pg-catalog/pg_catalog_arrow_exports/pg_user_mapping.feather diff --git a/datafusion-postgres/pg_to_arrow.py b/datafusion-pg-catalog/pg_to_arrow.py similarity index 100% rename from datafusion-postgres/pg_to_arrow.py rename to datafusion-pg-catalog/pg_to_arrow.py diff --git a/datafusion-pg-catalog/src/lib.rs b/datafusion-pg-catalog/src/lib.rs new file mode 100644 index 0000000..7648631 --- /dev/null +++ b/datafusion-pg-catalog/src/lib.rs @@ -0,0 +1,4 @@ +pub mod pg_catalog; +pub mod sql; + +pub use pg_catalog::setup_pg_catalog; diff --git a/datafusion-postgres/src/pg_catalog.rs b/datafusion-pg-catalog/src/pg_catalog.rs similarity index 100% rename from datafusion-postgres/src/pg_catalog.rs rename to datafusion-pg-catalog/src/pg_catalog.rs diff --git a/datafusion-postgres/src/pg_catalog/catalog_info.rs b/datafusion-pg-catalog/src/pg_catalog/catalog_info.rs similarity index 100% rename from datafusion-postgres/src/pg_catalog/catalog_info.rs rename to datafusion-pg-catalog/src/pg_catalog/catalog_info.rs diff --git a/datafusion-postgres/src/pg_catalog/context.rs b/datafusion-pg-catalog/src/pg_catalog/context.rs similarity index 88% rename from datafusion-postgres/src/pg_catalog/context.rs rename to datafusion-pg-catalog/src/pg_catalog/context.rs index 78c7de1..8b09e1a 100644 --- a/datafusion-postgres/src/pg_catalog/context.rs +++ b/datafusion-pg-catalog/src/pg_catalog/context.rs @@ -1,4 +1,4 @@ -use std::fmt::Debug; +use std::{fmt::Debug, sync::Arc}; use async_trait::async_trait; @@ -20,6 +20,22 @@ pub struct EmptyContextProvider; impl PgCatalogContextProvider for EmptyContextProvider {} +#[async_trait] +impl PgCatalogContextProvider for Arc +where + T: PgCatalogContextProvider, +{ + // retrieve all database role names + async fn roles(&self) -> Vec { + self.roles().await + } + + // retrieve database role information + async fn role(&self, name: &str) -> Option { + self.role(name).await + } +} + /// User information stored in the authentication system #[derive(Debug, Clone)] pub struct User { diff --git a/datafusion-postgres/src/pg_catalog/empty_table.rs b/datafusion-pg-catalog/src/pg_catalog/empty_table.rs similarity index 100% rename from datafusion-postgres/src/pg_catalog/empty_table.rs rename to datafusion-pg-catalog/src/pg_catalog/empty_table.rs diff --git a/datafusion-postgres/src/pg_catalog/format_type.rs b/datafusion-pg-catalog/src/pg_catalog/format_type.rs similarity index 100% rename from datafusion-postgres/src/pg_catalog/format_type.rs rename to datafusion-pg-catalog/src/pg_catalog/format_type.rs diff --git a/datafusion-postgres/src/pg_catalog/has_privilege_udf.rs b/datafusion-pg-catalog/src/pg_catalog/has_privilege_udf.rs similarity index 100% rename from datafusion-postgres/src/pg_catalog/has_privilege_udf.rs rename to datafusion-pg-catalog/src/pg_catalog/has_privilege_udf.rs diff --git a/datafusion-postgres/src/pg_catalog/pg_attribute.rs b/datafusion-pg-catalog/src/pg_catalog/pg_attribute.rs similarity index 100% rename from datafusion-postgres/src/pg_catalog/pg_attribute.rs rename to datafusion-pg-catalog/src/pg_catalog/pg_attribute.rs diff --git a/datafusion-postgres/src/pg_catalog/pg_class.rs b/datafusion-pg-catalog/src/pg_catalog/pg_class.rs similarity index 100% rename from datafusion-postgres/src/pg_catalog/pg_class.rs rename to datafusion-pg-catalog/src/pg_catalog/pg_class.rs diff --git a/datafusion-postgres/src/pg_catalog/pg_database.rs b/datafusion-pg-catalog/src/pg_catalog/pg_database.rs similarity index 100% rename from datafusion-postgres/src/pg_catalog/pg_database.rs rename to datafusion-pg-catalog/src/pg_catalog/pg_database.rs diff --git a/datafusion-postgres/src/pg_catalog/pg_get_expr_udf.rs b/datafusion-pg-catalog/src/pg_catalog/pg_get_expr_udf.rs similarity index 100% rename from datafusion-postgres/src/pg_catalog/pg_get_expr_udf.rs rename to datafusion-pg-catalog/src/pg_catalog/pg_get_expr_udf.rs diff --git a/datafusion-postgres/src/pg_catalog/pg_namespace.rs b/datafusion-pg-catalog/src/pg_catalog/pg_namespace.rs similarity index 100% rename from datafusion-postgres/src/pg_catalog/pg_namespace.rs rename to datafusion-pg-catalog/src/pg_catalog/pg_namespace.rs diff --git a/datafusion-postgres/src/pg_catalog/pg_replication_slot.rs b/datafusion-pg-catalog/src/pg_catalog/pg_replication_slot.rs similarity index 100% rename from datafusion-postgres/src/pg_catalog/pg_replication_slot.rs rename to datafusion-pg-catalog/src/pg_catalog/pg_replication_slot.rs diff --git a/datafusion-postgres/src/pg_catalog/pg_roles.rs b/datafusion-pg-catalog/src/pg_catalog/pg_roles.rs similarity index 100% rename from datafusion-postgres/src/pg_catalog/pg_roles.rs rename to datafusion-pg-catalog/src/pg_catalog/pg_roles.rs diff --git a/datafusion-postgres/src/pg_catalog/pg_settings.rs b/datafusion-pg-catalog/src/pg_catalog/pg_settings.rs similarity index 100% rename from datafusion-postgres/src/pg_catalog/pg_settings.rs rename to datafusion-pg-catalog/src/pg_catalog/pg_settings.rs diff --git a/datafusion-postgres/src/pg_catalog/pg_stat_gssapi.rs b/datafusion-pg-catalog/src/pg_catalog/pg_stat_gssapi.rs similarity index 100% rename from datafusion-postgres/src/pg_catalog/pg_stat_gssapi.rs rename to datafusion-pg-catalog/src/pg_catalog/pg_stat_gssapi.rs diff --git a/datafusion-postgres/src/pg_catalog/pg_tables.rs b/datafusion-pg-catalog/src/pg_catalog/pg_tables.rs similarity index 100% rename from datafusion-postgres/src/pg_catalog/pg_tables.rs rename to datafusion-pg-catalog/src/pg_catalog/pg_tables.rs diff --git a/datafusion-postgres/src/pg_catalog/pg_views.rs b/datafusion-pg-catalog/src/pg_catalog/pg_views.rs similarity index 100% rename from datafusion-postgres/src/pg_catalog/pg_views.rs rename to datafusion-pg-catalog/src/pg_catalog/pg_views.rs diff --git a/datafusion-postgres/src/sql.rs b/datafusion-pg-catalog/src/sql.rs similarity index 100% rename from datafusion-postgres/src/sql.rs rename to datafusion-pg-catalog/src/sql.rs diff --git a/datafusion-postgres/src/sql/parser.rs b/datafusion-pg-catalog/src/sql/parser.rs similarity index 100% rename from datafusion-postgres/src/sql/parser.rs rename to datafusion-pg-catalog/src/sql/parser.rs diff --git a/datafusion-postgres/src/sql/rules.rs b/datafusion-pg-catalog/src/sql/rules.rs similarity index 100% rename from datafusion-postgres/src/sql/rules.rs rename to datafusion-pg-catalog/src/sql/rules.rs diff --git a/datafusion-postgres-cli/src/main.rs b/datafusion-postgres-cli/src/main.rs index 3c6efe2..8792ce2 100644 --- a/datafusion-postgres-cli/src/main.rs +++ b/datafusion-postgres-cli/src/main.rs @@ -7,7 +7,7 @@ use datafusion::execution::options::{ }; use datafusion::prelude::{SessionConfig, SessionContext}; use datafusion_postgres::auth::AuthManager; -use datafusion_postgres::pg_catalog::setup_pg_catalog; +use datafusion_postgres::datafusion_pg_catalog::setup_pg_catalog; use datafusion_postgres::{serve, ServerOptions}; use env_logger::Env; use log::info; diff --git a/datafusion-postgres/Cargo.toml b/datafusion-postgres/Cargo.toml index d5fecce..57c3181 100644 --- a/datafusion-postgres/Cargo.toml +++ b/datafusion-postgres/Cargo.toml @@ -11,12 +11,6 @@ repository.workspace = true documentation.workspace = true readme = "../README.md" rust-version.workspace = true -include = [ - "src/**/*", - "pg_catalog_arrow_exports/**/*", - "Cargo.toml" -] - [dependencies] arrow-pg = { path = "../arrow-pg", version = "0.6.1", default-features = false, features = ["datafusion"] } @@ -24,6 +18,7 @@ bytes.workspace = true async-trait = "0.1" chrono.workspace = true datafusion.workspace = true +datafusion-pg-catalog = { path = "../datafusion-pg-catalog", version = "0.10.2" } futures.workspace = true getset = "0.1" log = "0.4" diff --git a/datafusion-postgres/src/auth.rs b/datafusion-postgres/src/auth.rs index f984183..c873d46 100644 --- a/datafusion-postgres/src/auth.rs +++ b/datafusion-postgres/src/auth.rs @@ -6,10 +6,10 @@ use pgwire::api::auth::{AuthSource, LoginInfo, Password}; use pgwire::error::{PgWireError, PgWireResult}; use tokio::sync::RwLock; -use crate::pg_catalog::context::*; +use datafusion_pg_catalog::pg_catalog::context::*; /// Authentication manager that handles users and roles -#[derive(Debug)] +#[derive(Debug, Clone)] pub struct AuthManager { users: Arc>>, roles: Arc>>, @@ -445,6 +445,19 @@ impl AuthManager { } } +#[async_trait] +impl PgCatalogContextProvider for AuthManager { + // retrieve all database role names + async fn roles(&self) -> Vec { + self.list_roles().await + } + + // retrieve database role information + async fn role(&self, name: &str) -> Option { + self.get_role(name).await + } +} + /// AuthSource implementation for integration with pgwire authentication /// Provides proper password-based authentication instead of custom startup handler #[derive(Clone)] @@ -547,19 +560,6 @@ impl SimpleAuthSource { } } -#[async_trait] -impl PgCatalogContextProvider for Arc { - // retrieve all database role names - async fn roles(&self) -> Vec { - self.list_roles().await - } - - // retrieve database role information - async fn role(&self, name: &str) -> Option { - self.role(name).await - } -} - #[async_trait] impl AuthSource for SimpleAuthSource { async fn get_password(&self, login: &LoginInfo) -> PgWireResult { diff --git a/datafusion-postgres/src/handlers.rs b/datafusion-postgres/src/handlers.rs index 0ee40cc..fcbded3 100644 --- a/datafusion-postgres/src/handlers.rs +++ b/datafusion-postgres/src/handlers.rs @@ -25,10 +25,10 @@ use pgwire::messages::response::TransactionStatus; use tokio::sync::Mutex; use crate::auth::AuthManager; -use crate::pg_catalog::context::{Permission, ResourceType}; -use crate::sql::PostgresCompatibilityParser; use arrow_pg::datatypes::df; use arrow_pg::datatypes::{arrow_schema_to_pg_fields, into_pg_type}; +use datafusion_pg_catalog::pg_catalog::context::{Permission, ResourceType}; +use datafusion_pg_catalog::sql::PostgresCompatibilityParser; // Metadata keys for session-level settings const METADATA_STATEMENT_TIMEOUT: &str = "statement_timeout_ms"; diff --git a/datafusion-postgres/src/lib.rs b/datafusion-postgres/src/lib.rs index 1161c50..4ed0a16 100644 --- a/datafusion-postgres/src/lib.rs +++ b/datafusion-postgres/src/lib.rs @@ -1,6 +1,4 @@ mod handlers; -pub mod pg_catalog; -pub mod sql; use std::fs::File; use std::io::{BufReader, Error as IOError, ErrorKind}; @@ -26,6 +24,7 @@ pub use handlers::{DfSessionService, Parser}; /// re-exports pub use arrow_pg; +pub use datafusion_pg_catalog; pub use pgwire; #[derive(Getters, Setters, WithSetters, Debug)] diff --git a/datafusion-postgres/tests/common/mod.rs b/datafusion-postgres/tests/common/mod.rs index 43e6cf3..054b38d 100644 --- a/datafusion-postgres/tests/common/mod.rs +++ b/datafusion-postgres/tests/common/mod.rs @@ -1,7 +1,8 @@ use std::{collections::HashMap, sync::Arc}; use datafusion::prelude::SessionContext; -use datafusion_postgres::{auth::AuthManager, pg_catalog::setup_pg_catalog, DfSessionService}; +use datafusion_pg_catalog::pg_catalog::setup_pg_catalog; +use datafusion_postgres::{auth::AuthManager, DfSessionService}; use futures::Sink; use pgwire::{ api::{ClientInfo, ClientPortalStore, PgWireConnectionState, METADATA_USER},