-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Make row its crate to make it accessible from physical-expr #2283
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
Changes from 2 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,108 @@ | ||
| // 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. | ||
|
|
||
| use datafusion::datasource::file_format::parquet::ParquetFormat; | ||
| use datafusion::datasource::file_format::FileFormat; | ||
| use datafusion::datasource::listing::local_unpartitioned_file; | ||
| use datafusion::error::Result; | ||
| use datafusion::physical_plan::file_format::FileScanConfig; | ||
| use datafusion::physical_plan::{collect, ExecutionPlan}; | ||
| use datafusion::prelude::SessionContext; | ||
| use datafusion_data_access::object_store::local::LocalFileSystem; | ||
| use datafusion_data_access::object_store::local::{ | ||
| local_object_reader, local_object_reader_stream, | ||
| }; | ||
| use datafusion_row::layout::RowType::{Compact, WordAligned}; | ||
| use datafusion_row::reader::read_as_batch; | ||
| use datafusion_row::writer::write_batch_unchecked; | ||
| use std::sync::Arc; | ||
|
|
||
| #[tokio::test] | ||
| async fn test_with_parquet() -> Result<()> { | ||
| let session_ctx = SessionContext::new(); | ||
| let task_ctx = session_ctx.task_ctx(); | ||
| let projection = Some(vec![0, 1, 2, 3, 4, 5, 6, 7, 8, 9]); | ||
| let exec = get_exec("alltypes_plain.parquet", &projection, None).await?; | ||
| let schema = exec.schema().clone(); | ||
|
|
||
| let batches = collect(exec, task_ctx).await?; | ||
| assert_eq!(1, batches.len()); | ||
| let batch = &batches[0]; | ||
|
|
||
| let mut vector = vec![0; 20480]; | ||
| let row_offsets = | ||
| { write_batch_unchecked(&mut vector, 0, batch, 0, schema.clone(), Compact) }; | ||
| let output_batch = { read_as_batch(&vector, schema, &row_offsets, Compact)? }; | ||
| assert_eq!(*batch, output_batch); | ||
|
|
||
| Ok(()) | ||
| } | ||
|
|
||
| #[tokio::test] | ||
| async fn test_with_parquet_word_aligned() -> Result<()> { | ||
| let session_ctx = SessionContext::new(); | ||
| let task_ctx = session_ctx.task_ctx(); | ||
| let projection = Some(vec![0, 1, 2, 3, 4, 5, 6, 7]); | ||
| let exec = get_exec("alltypes_plain.parquet", &projection, None).await?; | ||
| let schema = exec.schema().clone(); | ||
|
|
||
| let batches = collect(exec, task_ctx).await?; | ||
| assert_eq!(1, batches.len()); | ||
| let batch = &batches[0]; | ||
|
|
||
| let mut vector = vec![0; 20480]; | ||
| let row_offsets = | ||
| { write_batch_unchecked(&mut vector, 0, batch, 0, schema.clone(), WordAligned) }; | ||
| let output_batch = { read_as_batch(&vector, schema, &row_offsets, WordAligned)? }; | ||
| assert_eq!(*batch, output_batch); | ||
|
|
||
| Ok(()) | ||
| } | ||
|
|
||
| async fn get_exec( | ||
| file_name: &str, | ||
| projection: &Option<Vec<usize>>, | ||
| limit: Option<usize>, | ||
| ) -> Result<Arc<dyn ExecutionPlan>> { | ||
| let testdata = datafusion::test_util::parquet_test_data(); | ||
| let filename = format!("{}/{}", testdata, file_name); | ||
| let format = ParquetFormat::default(); | ||
| let file_schema = format | ||
| .infer_schema(local_object_reader_stream(vec![filename.clone()])) | ||
| .await | ||
| .expect("Schema inference"); | ||
| let statistics = format | ||
| .infer_stats(local_object_reader(filename.clone()), file_schema.clone()) | ||
| .await | ||
| .expect("Stats inference"); | ||
| let file_groups = vec![vec![local_unpartitioned_file(filename.clone())]]; | ||
| let exec = format | ||
| .create_physical_plan( | ||
| FileScanConfig { | ||
| object_store: Arc::new(LocalFileSystem {}), | ||
| file_schema, | ||
| file_groups, | ||
| statistics, | ||
| projection: projection.clone(), | ||
| limit, | ||
| table_partition_cols: vec![], | ||
| }, | ||
| &[], | ||
| ) | ||
| .await?; | ||
| Ok(exec) | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,45 @@ | ||
| # 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 = "datafusion-row" | ||
| description = "Row backed by raw bytes for DataFusion query engine" | ||
| version = "7.0.0" | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Do we really want to start with version 7.0.0 for this crate?
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. or 0.1.0 ?
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think this is following the model of the other datafusion sub crates (which are all versioned the same -- 7.0.0).
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ok, that makes sense |
||
| homepage = "https://github.com/apache/arrow-datafusion" | ||
| repository = "https://github.com/apache/arrow-datafusion" | ||
| readme = "../README.md" | ||
| authors = ["Apache Arrow <[email protected]>"] | ||
| license = "Apache-2.0" | ||
| keywords = [ "arrow", "query", "sql" ] | ||
| edition = "2021" | ||
| rust-version = "1.59" | ||
|
|
||
| [lib] | ||
| name = "datafusion_row" | ||
| path = "src/lib.rs" | ||
|
|
||
| [features] | ||
| # Used to enable JIT code generation | ||
| jit = ["datafusion-jit"] | ||
|
|
||
| [dependencies] | ||
| arrow = { version = "12" } | ||
| datafusion-common = { path = "../common", version = "7.0.0" } | ||
| datafusion-expr = { path = "../expr", version = "7.0.0" } | ||
| datafusion-jit = { path = "../jit", version = "7.0.0", optional = true } | ||
| paste = "^1.0" | ||
| rand = "0.8" | ||
Uh oh!
There was an error while loading. Please reload this page.