Skip to content
Open
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
1,352 changes: 955 additions & 397 deletions Cargo.lock

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ arrow = "58"
arrow-schema = "58"
bytes = "1.11.1"
chrono = { version = "0.4", features = ["std"] }
datafusion = { version = "53" }
datafusion = { version = "54" }
futures = "0.3"
pgwire = { version = "0.40", default-features = false }
postgres-types = "0.2"
Expand Down
8 changes: 0 additions & 8 deletions datafusion-pg-catalog/src/pg_catalog.rs
Original file line number Diff line number Diff line change
Expand Up @@ -206,10 +206,6 @@ pub struct PgCatalogSchemaProvider<C, P> {

#[async_trait]
impl<C: CatalogInfo, P: PgCatalogContextProvider> SchemaProvider for PgCatalogSchemaProvider<C, P> {
fn as_any(&self) -> &dyn std::any::Any {
self
}

fn table_names(&self) -> Vec<String> {
PG_CATALOG_TABLES.iter().map(ToString::to_string).collect()
}
Expand Down Expand Up @@ -1369,10 +1365,6 @@ pub fn create_pg_get_constraintdef() -> ScalarUDF {
}

impl ScalarUDFImpl for GetConstraintDefUDF {
fn as_any(&self) -> &dyn std::any::Any {
self
}

fn name(&self) -> &str {
"pg_get_constraintdef"
}
Expand Down
4 changes: 0 additions & 4 deletions datafusion-pg-catalog/src/pg_catalog/format_type.rs
Original file line number Diff line number Diff line change
Expand Up @@ -267,10 +267,6 @@ impl ScalarUDFImpl for FormatTypeUDF {
fn invoke_with_args(&self, args: ScalarFunctionArgs) -> Result<ColumnarValue, DataFusionError> {
format_type_impl(&args.args)
}

fn as_any(&self) -> &dyn std::any::Any {
self
}
}

pub fn create_format_type_udf() -> ScalarUDF {
Expand Down
4 changes: 0 additions & 4 deletions datafusion-pg-catalog/src/pg_catalog/has_privilege_udf.rs
Original file line number Diff line number Diff line change
Expand Up @@ -60,10 +60,6 @@ impl ScalarUDFImpl for PgHasPrivilegeUDF {

Ok(ColumnarValue::Array(array))
}

fn as_any(&self) -> &dyn std::any::Any {
self
}
}

pub fn create_has_privilege_udf(name: &str) -> ScalarUDF {
Expand Down
4 changes: 0 additions & 4 deletions datafusion-pg-catalog/src/pg_catalog/pg_get_expr_udf.rs
Original file line number Diff line number Diff line change
Expand Up @@ -65,10 +65,6 @@ impl ScalarUDFImpl for PgGetExprUDF {

Ok(ColumnarValue::Array(array))
}

fn as_any(&self) -> &dyn std::any::Any {
self
}
}

pub fn create_pg_get_expr_udf() -> ScalarUDF {
Expand Down
4 changes: 0 additions & 4 deletions datafusion-pg-catalog/src/pg_catalog/quote_ident_udf.rs
Original file line number Diff line number Diff line change
Expand Up @@ -81,10 +81,6 @@ impl Default for ParseIdentUDF {
}

impl ScalarUDFImpl for ParseIdentUDF {
fn as_any(&self) -> &dyn std::any::Any {
self
}

fn signature(&self) -> &Signature {
&self.signature
}
Expand Down
1 change: 1 addition & 0 deletions datafusion-postgres/src/hooks/permissions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ impl PermissionsHook {
Statement::Set { .. }
| Statement::ShowVariable { .. }
| Statement::ShowStatus { .. }
| Statement::ShowCatalogs { .. }
| Statement::StartTransaction { .. }
| Statement::Commit { .. }
| Statement::Rollback { .. }
Expand Down
21 changes: 18 additions & 3 deletions datafusion-postgres/src/hooks/set_show.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,9 @@ impl QueryHook for SetShowHook {
Statement::Set { .. } => {
try_respond_set_statements(client, statement, session_context).await
}
Statement::ShowVariable { .. } | Statement::ShowStatus { .. } => {
Statement::ShowVariable { .. }
| Statement::ShowStatus { .. }
| Statement::ShowCatalogs { .. } => {
try_respond_show_statements(client, statement, session_context).await
}
_ => None,
Expand All @@ -64,7 +66,9 @@ impl QueryHook for SetShowHook {
.map_err(|e| PgWireError::ApiError(Box::new(e)));
Some(result)
}
Statement::ShowVariable { .. } | Statement::ShowStatus { .. } => {
Statement::ShowVariable { .. }
| Statement::ShowStatus { .. }
| Statement::ShowCatalogs { .. } => {
let show_schema =
Arc::new(Schema::new(vec![Field::new("show", DataType::Utf8, false)]));
let result = show_schema
Expand Down Expand Up @@ -94,7 +98,9 @@ impl QueryHook for SetShowHook {
Statement::Set { .. } => {
try_respond_set_statements(client, statement, session_context).await
}
Statement::ShowVariable { .. } | Statement::ShowStatus { .. } => {
Statement::ShowVariable { .. }
| Statement::ShowStatus { .. }
| Statement::ShowCatalogs { .. } => {
try_respond_show_statements(client, statement, session_context).await
}
_ => None,
Expand Down Expand Up @@ -279,6 +285,13 @@ async fn try_respond_show_statements(
statement: &Statement,
session_context: &SessionContext,
) -> Option<PgWireResult<Response>> {
// Handle SHOW CATALOGS separately since it's its own variant in sqlparser 0.62+
if let Statement::ShowCatalogs { .. } = statement {
let catalogs = session_context.catalog_names();
let value = catalogs.join(", ");
return Some(mock_show_response("Catalogs", &value).map(Response::Query));
}

let Statement::ShowVariable { variable } = statement else {
return None;
};
Expand Down Expand Up @@ -596,6 +609,8 @@ mod tests {
let show_response =
try_respond_show_statements(&client, &statement, &session_context).await;

dbg!(query);
dbg!(&show_response);
let Some(Ok(Response::Query(show_response))) = show_response else {
panic!("unexpected show response");
};
Expand Down
2 changes: 1 addition & 1 deletion datafusion-postgres/src/planner.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ fn extract_placeholder_cast_types(plan: &LogicalPlan) -> Result<HashMap<String,
if let Expr::Cast(cast) = e
&& let Expr::Placeholder(ph) = &*cast.expr
{
placeholder_types.insert(ph.id.clone(), Some(cast.data_type.clone()));
placeholder_types.insert(ph.id.clone(), Some(cast.field.data_type().clone()));
casted_placeholders.insert(ph.id.clone());
}

Expand Down
Loading