Copilot commented on code in PR #1475:
URL:
https://github.com/apache/datafusion-python/pull/1475#discussion_r3034080639
##########
crates/core/src/context.rs:
##########
@@ -1050,6 +1052,45 @@ impl PySessionContext {
self.ctx.session_id()
}
+ pub fn session_start_time(&self) -> String {
+ self.ctx.session_start_time().to_rfc3339()
+ }
+
+ pub fn enable_ident_normalization(&self) -> bool {
+ self.ctx.enable_ident_normalization()
+ }
+
+ pub fn parse_sql_expr(&self, sql: &str, schema: PyDFSchema) ->
PyDataFusionResult<PyExpr> {
+ let df_schema: DFSchema = schema.into();
+ Ok(self.ctx.parse_sql_expr(sql, &df_schema)?.into())
+ }
+
+ pub fn execute_logical_plan(
+ &self,
+ plan: PyLogicalPlan,
+ py: Python,
+ ) -> PyDataFusionResult<PyDataFrame> {
+ let df = wait_for_future(
+ py,
+ self.ctx.execute_logical_plan(plan.plan.as_ref().clone()),
+ )??;
+ Ok(PyDataFrame::new(df))
+ }
+
+ pub fn refresh_catalogs(&self, py: Python) -> PyDataFusionResult<()> {
+ wait_for_future(py, self.ctx.refresh_catalogs())??;
+ Ok(())
+ }
+
+ pub fn remove_optimizer_rule(&self, name: &str) -> bool {
+ self.ctx.remove_optimizer_rule(name)
+ }
+
+ pub fn table_provider(&self, name: &str, py: Python) ->
PyDataFusionResult<PyTable> {
+ let provider = wait_for_future(py, self.ctx.table_provider(name))??;
+ Ok(PyTable { table: provider })
Review Comment:
`table_provider()` currently propagates DataFusion errors directly. For
consistency with `table()` (which maps missing-table errors to `KeyError`),
consider translating the “No table named …” / not-found case here to
`PyKeyError` as well so Python users get a consistent exception type when
looking up a non-existent table provider.
```suggestion
match wait_for_future(py, self.ctx.table_provider(name))? {
Ok(provider) => Ok(PyTable { table: provider }),
Err(err) => {
let err_msg = err.to_string();
if err_msg.contains("No table named") ||
err_msg.contains("not found") {
Err(pyo3::exceptions::PyKeyError::new_err(err_msg))
} else {
Err(err.into())
}
}
}
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]