Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(python): match Field signatures #1463

Merged
merged 1 commit into from
Jun 14, 2023
Merged
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
8 changes: 4 additions & 4 deletions python/src/schema.rs
Original file line number Diff line number Diff line change
Expand Up @@ -599,7 +599,7 @@ impl MapType {
/// Field("my_col", PrimitiveType("integer"), nullable=True, metadata={"custom_metadata": {"test": 2}})
#[pyclass(
module = "deltalake.schema",
text_signature = "(name, ty, nullable=True, metadata=None)"
text_signature = "(name, type, nullable=True, metadata=None)"
)]
#[derive(Clone)]
pub struct Field {
Expand All @@ -609,15 +609,15 @@ pub struct Field {
#[pymethods]
impl Field {
#[new]
#[pyo3(signature = (name, ty, nullable = true, metadata = None))]
#[pyo3(signature = (name, r#type, nullable = true, metadata = None))]
fn new(
name: String,
ty: PyObject,
r#type: PyObject,
nullable: bool,
metadata: Option<PyObject>,
py: Python,
) -> PyResult<Self> {
let ty = python_type_to_schema(ty, py)?;
let ty = python_type_to_schema(r#type, py)?;

// Serialize and de-serialize JSON (it needs to be valid JSON anyways)
let metadata: HashMap<String, serde_json::Value> = if let Some(ref json) = metadata {
Expand Down
2 changes: 1 addition & 1 deletion python/tests/test_schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ def test_delta_field():
# TODO: are there field names we should reject?

for name, ty, nullable, metadata in args:
field = Field(name, ty, nullable=nullable, metadata=metadata)
field = Field(name=name, type=ty, nullable=nullable, metadata=metadata)

assert field.name == name
assert field.type == (PrimitiveType(ty) if isinstance(ty, str) else ty)
Expand Down