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

Split out arrow-schema (#2594) #2711

Merged
merged 20 commits into from Sep 21, 2022
Merged
Show file tree
Hide file tree
Changes from 9 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions Cargo.toml
Expand Up @@ -18,6 +18,7 @@
[workspace]
members = [
"arrow",
"arrow-schema",
"parquet",
"parquet_derive",
"parquet_derive_test",
Expand Down
31 changes: 18 additions & 13 deletions arrow-pyarrow-integration-testing/src/lib.rs
Expand Up @@ -28,7 +28,7 @@ use arrow::compute::kernels;
use arrow::datatypes::{DataType, Field, Schema};
use arrow::error::ArrowError;
use arrow::ffi_stream::ArrowArrayStreamReader;
use arrow::pyarrow::PyArrowConvert;
use arrow::pyarrow::{PyArrowConvert, PyArrowType};
use arrow::record_batch::RecordBatch;

/// Returns `array + array` of an int64 array.
Expand Down Expand Up @@ -66,20 +66,23 @@ fn double_py(lambda: &PyAny, py: Python) -> PyResult<bool> {

/// Returns the substring
#[pyfunction]
fn substring(array: ArrayData, start: i64) -> PyResult<ArrayData> {
fn substring(
array: PyArrowType<ArrayData>,
start: i64,
) -> PyResult<PyArrowType<ArrayData>> {
// import
let array = ArrayRef::from(array);
let array = ArrayRef::from(array.0);

// substring
let array = kernels::substring::substring(array.as_ref(), start, None)?;

Ok(array.data().to_owned())
Ok(array.data().to_owned().into())
}

/// Returns the concatenate
#[pyfunction]
fn concatenate(array: ArrayData, py: Python) -> PyResult<PyObject> {
let array = ArrayRef::from(array);
fn concatenate(array: PyArrowType<ArrayData>, py: Python) -> PyResult<PyObject> {
let array = ArrayRef::from(array.0);

// concat
let array = kernels::concat::concat(&[array.as_ref(), array.as_ref()])?;
Expand All @@ -88,34 +91,36 @@ fn concatenate(array: ArrayData, py: Python) -> PyResult<PyObject> {
}

#[pyfunction]
fn round_trip_type(obj: DataType) -> PyResult<DataType> {
fn round_trip_type(obj: PyArrowType<DataType>) -> PyResult<PyArrowType<DataType>> {
Ok(obj)
}

#[pyfunction]
fn round_trip_field(obj: Field) -> PyResult<Field> {
fn round_trip_field(obj: PyArrowType<Field>) -> PyResult<PyArrowType<Field>> {
Ok(obj)
}

#[pyfunction]
fn round_trip_schema(obj: Schema) -> PyResult<Schema> {
fn round_trip_schema(obj: PyArrowType<Schema>) -> PyResult<PyArrowType<Schema>> {
Ok(obj)
}

#[pyfunction]
fn round_trip_array(obj: ArrayData) -> PyResult<ArrayData> {
fn round_trip_array(obj: PyArrowType<ArrayData>) -> PyResult<PyArrowType<ArrayData>> {
Ok(obj)
}

#[pyfunction]
fn round_trip_record_batch(obj: RecordBatch) -> PyResult<RecordBatch> {
fn round_trip_record_batch(
obj: PyArrowType<RecordBatch>,
) -> PyResult<PyArrowType<RecordBatch>> {
Ok(obj)
}

#[pyfunction]
fn round_trip_record_batch_reader(
obj: ArrowArrayStreamReader,
) -> PyResult<ArrowArrayStreamReader> {
obj: PyArrowType<ArrowArrayStreamReader>,
) -> PyResult<PyArrowType<ArrowArrayStreamReader>> {
Ok(obj)
}

Expand Down
52 changes: 52 additions & 0 deletions arrow-schema/Cargo.toml
@@ -0,0 +1,52 @@
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.

[package]
name = "arrow-schema"
version = "22.0.0"
description = "Defines the logical types for arrow arrays"
homepage = "https://github.com/apache/arrow-rs"
repository = "https://github.com/apache/arrow-rs"
authors = ["Apache Arrow <dev@arrow.apache.org>"]
license = "Apache-2.0"
keywords = ["arrow"]
include = [
"benches/*.rs",
"src/**/*.rs",
"Cargo.toml",
]
edition = "2021"
rust-version = "1.62"

[lib]
name = "arrow_schema"
path = "src/lib.rs"
bench = false

[dependencies]
serde = { version = "1.0", default-features = false, features = ["derive"], optional = true }
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is somewhat annoying, but the orphan rule means serde needs to tag along for the ride

serde_json = { version = "1.0", default-features = false, features = ["std"], optional = true }

[package.metadata.docs.rs]
features = ["json"]

[features]
default = []
json = ["serde", "serde_json"]

[dev-dependencies]