mirror of
https://github.com/lancedb/lancedb.git
synced 2026-10-14 07:42:28 +00:00
feat: independent property graphs and graph writes from the client
A property graph definition now carries its mode. Independent graphs are defined by node and edge types with Arrow schemas and take rows through insert_into_property_graph; materialized view graphs are defined over tables as before and brought up to them with refresh_property_graph. rollback_property_graph returns either to its previous commit, and descriptions report the mode and the current and previous commits.
This commit is contained in:
@@ -0,0 +1,27 @@
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
// SPDX-FileCopyrightText: Copyright The LanceDB Authors
|
||||
|
||||
//! Property graph schemas, between pyarrow and the JSON form a graph's
|
||||
//! definition carries.
|
||||
|
||||
use arrow::{datatypes::Schema, pyarrow::PyArrowType};
|
||||
use lance_namespace::models::JsonArrowSchema;
|
||||
use pyo3::{PyResult, exceptions::PyValueError, pyfunction};
|
||||
|
||||
/// A pyarrow schema as the JSON Arrow schema of a node or edge type.
|
||||
#[pyfunction]
|
||||
pub fn graph_schema_to_json(schema: PyArrowType<Schema>) -> PyResult<String> {
|
||||
let json = lance_namespace::schema::arrow_schema_to_json(&schema.0)
|
||||
.map_err(|error| PyValueError::new_err(error.to_string()))?;
|
||||
serde_json::to_string(&json).map_err(|error| PyValueError::new_err(error.to_string()))
|
||||
}
|
||||
|
||||
/// A node or edge type's JSON Arrow schema as a pyarrow schema.
|
||||
#[pyfunction]
|
||||
pub fn graph_schema_from_json(json: String) -> PyResult<PyArrowType<Schema>> {
|
||||
let json: JsonArrowSchema =
|
||||
serde_json::from_str(&json).map_err(|error| PyValueError::new_err(error.to_string()))?;
|
||||
let schema = lance_namespace::schema::convert_json_arrow_schema(&json)
|
||||
.map_err(|error| PyValueError::new_err(error.to_string()))?;
|
||||
Ok(PyArrowType(schema))
|
||||
}
|
||||
Reference in New Issue
Block a user