mirror of
https://github.com/lancedb/lancedb.git
synced 2026-08-18 12:08:35 +00:00
feat: add generated column Python API
This commit is contained in:
@@ -227,8 +227,7 @@ impl AuthoredFunctionCall {
|
||||
})
|
||||
}
|
||||
|
||||
/// Crate-private accessor for the later table-binding slice.
|
||||
#[allow(dead_code)]
|
||||
/// Crate-private accessor for the exact Function owned by this authored call.
|
||||
pub(crate) fn function(&self) -> &lancedb::function::Function {
|
||||
&self.function
|
||||
}
|
||||
@@ -243,9 +242,8 @@ impl AuthoredFunctionCall {
|
||||
///
|
||||
/// Calls [`lancedb::Table::generated_column_binding_snapshot`] once so the
|
||||
/// returned `source_table_version` and canonical [`FunctionCall`] share the
|
||||
/// same field identities and Arrow types. Source version stays outside the
|
||||
/// call for later Job envelope submit. Not yet wired to create/change submit.
|
||||
#[allow(dead_code)] // Bound by the immediately following create/change submit slice.
|
||||
/// same field identities and Arrow types. Source version remains outside the
|
||||
/// call for the create/change Job envelope.
|
||||
pub(crate) async fn bind_to_table(
|
||||
&self,
|
||||
table: &lancedb::Table,
|
||||
|
||||
@@ -930,6 +930,39 @@ impl Table {
|
||||
})
|
||||
}
|
||||
|
||||
/// Hidden bridge: bind an authored Function call once and submit create.
|
||||
///
|
||||
/// Private native path for Python ``table.add_generated_column``. Rejects an
|
||||
/// empty ``column_name`` before reading the table handle. Does not expose
|
||||
/// source version, stable field IDs, the operation spec, or request envelope.
|
||||
#[doc(hidden)]
|
||||
pub fn _add_generated_column<'a>(
|
||||
self_: PyRef<'a, Self>,
|
||||
column_name: String,
|
||||
call: Bound<'_, crate::function::AuthoredFunctionCall>,
|
||||
) -> PyResult<Bound<'a, PyAny>> {
|
||||
if column_name.is_empty() {
|
||||
return Err(PyValueError::new_err("column_name must be non-empty"));
|
||||
}
|
||||
let inner = self_.inner_ref()?.clone();
|
||||
let authored = call.get().clone();
|
||||
future_into_py(self_.py(), async move {
|
||||
let (source_table_version, bound_call) =
|
||||
authored.bind_to_table(&inner).await.infer_error()?;
|
||||
let spec = lancedb::function::CreateGeneratedColumnJobSpec::try_new(
|
||||
column_name,
|
||||
authored.function(),
|
||||
bound_call,
|
||||
)
|
||||
.infer_error()?;
|
||||
let job = inner
|
||||
.submit_create_generated_column(source_table_version, spec)
|
||||
.await
|
||||
.infer_error()?;
|
||||
Ok(crate::job::Job::new(job))
|
||||
})
|
||||
}
|
||||
|
||||
pub fn drop_index(self_: PyRef<'_, Self>, index_name: String) -> PyResult<Bound<'_, PyAny>> {
|
||||
let inner = self_.inner_ref()?.clone();
|
||||
future_into_py(self_.py(), async move {
|
||||
|
||||
Reference in New Issue
Block a user