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

ref: Move ScalarValue & downcast to sparrow-arrow #407

Merged
merged 2 commits into from
Jun 1, 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
18 changes: 11 additions & 7 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion crates/sparrow-api/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ prost-wkt.workspace = true
prost-wkt-types.workspace = true
serde.workspace = true
serde_yaml.workspace = true
sparrow-core = { path = "../sparrow-core" }
sparrow-arrow = { path = "../sparrow-arrow" }
sparrow-syntax = { path = "../sparrow-syntax" }
tempfile.workspace = true
thiserror.workspace = true
Expand Down
2 changes: 1 addition & 1 deletion crates/sparrow-api/src/kaskada/v1alpha/plan_impl.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use anyhow::Context;
use arrow::datatypes::{DataType, TimeUnit};
use itertools::Itertools;
use sparrow_core::{
use sparrow_arrow::scalar_value::{
timeunit_from_suffix, timeunit_suffix, ScalarRecord, ScalarTimestamp, ScalarValue,
};

Expand Down
4 changes: 4 additions & 0 deletions crates/sparrow-arrow/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,16 @@ avro = ["avro-schema"]

# This crate should not depend on any other Sparrow crates.
[dependencies]
anyhow.workspace = true
arrow.workspace = true
avro-schema = { workspace = true, optional = true }
avro-rs = { workspace = true }
chrono.workspace = true
decorum.workspace = true
derive_more.workspace = true
error-stack.workspace = true
itertools.workspace = true
num.workspace = true
serde.workspace = true
tracing.workspace = true

Expand Down
4 changes: 4 additions & 0 deletions crates/sparrow-arrow/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,7 @@ pub mod attachments;
pub mod avro;

pub mod serde;

pub mod downcast;
pub mod scalar_value;
pub mod utils;
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@ use decorum::Total;
use itertools::izip;
use num::{One, Signed, Zero};

use crate::utils::make_struct_array;
use crate::{
use crate::downcast::{
downcast_boolean_array, downcast_primitive_array, downcast_string_array, downcast_struct_array,
};
use crate::utils::make_struct_array;

/// Represents a single value of a given data type.
///
Expand Down
File renamed without changes.
1 change: 0 additions & 1 deletion crates/sparrow-catalog/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ similar.workspace = true
static_init.workspace = true
sparrow-api = { path = "../sparrow-api" }
sparrow-compiler = { path = "../sparrow-compiler" }
sparrow-core = { path = "../sparrow-core" }
sparrow-main = { path = "../sparrow-main" }
sparrow-syntax = { path = "../sparrow-syntax" }
sparrow-qfr = { path = "../sparrow-qfr" }
Expand Down
1 change: 1 addition & 0 deletions crates/sparrow-compiler/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ serde_yaml.workspace = true
sha2.workspace = true
smallvec.workspace = true
sparrow-api = { path = "../sparrow-api" }
sparrow-arrow = { path = "../sparrow-arrow" }
sparrow-core = { path = "../sparrow-core" }
sparrow-instructions = { path = "../sparrow-instructions" }
sparrow-kernels = { path = "../sparrow-kernels" }
Expand Down
2 changes: 1 addition & 1 deletion crates/sparrow-compiler/src/ast_to_dfg.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ use egg::Id;
use itertools::{izip, Itertools};
use record_ops_to_dfg::*;
use smallvec::{smallvec, SmallVec};
use sparrow_core::ScalarValue;
use sparrow_arrow::scalar_value::ScalarValue;
use sparrow_instructions::CastEvaluator;
use sparrow_plan::{GroupId, InstKind, InstOp};
use sparrow_syntax::{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use arrow::datatypes::{DataType, Field};
use hashbrown::HashSet;
use itertools::{izip, Itertools};
use smallvec::{smallvec, SmallVec};
use sparrow_core::ScalarValue;
use sparrow_arrow::scalar_value::ScalarValue;
use sparrow_plan::InstKind;
use sparrow_syntax::{ArgVec, FenlType, Located, Location, Resolved};

Expand Down
2 changes: 1 addition & 1 deletion crates/sparrow-compiler/src/dfg.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ use egg::{AstSize, Extractor, Id, Language};
use hashbrown::HashMap;
use itertools::{izip, Itertools};
pub(crate) use language::ChildrenVec;
use sparrow_core::ScalarValue;
use sparrow_arrow::scalar_value::ScalarValue;
use sparrow_plan::{InstKind, InstOp};
use sparrow_syntax::{FenlType, Location};
pub(crate) use step_kind::*;
Expand Down
2 changes: 1 addition & 1 deletion crates/sparrow-compiler/src/dfg/analysis.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ use egg::{Analysis, Id, Language};
use hashbrown::HashMap;
use itertools::Itertools;
use smallvec::smallvec;
use sparrow_core::ScalarValue;
use sparrow_arrow::scalar_value::ScalarValue;
use sparrow_plan::{InstKind, InstOp};

use super::{DfgGraph, DfgLang, StepKind};
Expand Down
4 changes: 2 additions & 2 deletions crates/sparrow-compiler/src/dfg/const_eval.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use anyhow::Context;
use itertools::Itertools;
use sparrow_core::ScalarValue;
use sparrow_arrow::scalar_value::ScalarValue;
use sparrow_instructions::{
ColumnarValue, ComputeStore, Evaluator, GroupingIndices, RuntimeInfo, StaticArg, StaticInfo,
};
Expand Down Expand Up @@ -204,7 +204,7 @@ impl RuntimeInfo for ConstEvaluator {

#[cfg(test)]
mod tests {
use sparrow_core::ScalarValue;
use sparrow_arrow::scalar_value::ScalarValue;
use sparrow_plan::{InstKind, InstOp};
use strum::IntoEnumIterator;

Expand Down
2 changes: 1 addition & 1 deletion crates/sparrow-compiler/src/dfg/language.rs
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ mod tests {

use egg::{EGraph, Pattern, Searcher, Var};
use smallvec::smallvec;
use sparrow_core::ScalarValue;
use sparrow_arrow::scalar_value::ScalarValue;
use sparrow_plan::{InstKind, InstOp};

use super::*;
Expand Down
2 changes: 1 addition & 1 deletion crates/sparrow-compiler/src/dfg/simplification.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use std::time::Duration;

use egg::{rewrite, Applier, Id, Rewrite, Runner, Subst};
use smallvec::smallvec;
use sparrow_core::ScalarValue;
use sparrow_arrow::scalar_value::ScalarValue;
use sparrow_syntax::LiteralValue;
use static_init::dynamic;
use tracing::{info, info_span, warn};
Expand Down
2 changes: 1 addition & 1 deletion crates/sparrow-compiler/src/dfg/step_kind.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use std::str::FromStr;
use anyhow::Context;
use sparrow_api::kaskada::v1alpha::operation_plan::tick_operation::TickBehavior;
use sparrow_api::kaskada::v1alpha::{slice_plan, LateBoundValue};
use sparrow_core::ScalarValue;
use sparrow_arrow::scalar_value::ScalarValue;
use sparrow_plan::{InstKind, InstOp, TableId};
use sparrow_syntax::WindowBehavior;
use uuid::Uuid;
Expand Down
2 changes: 1 addition & 1 deletion crates/sparrow-compiler/src/plan/expression_to_plan.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use anyhow::Context;
use sparrow_api::kaskada::v1alpha::DataType;
use sparrow_api::kaskada::v1alpha::{expression_plan, ExpressionPlan};
use sparrow_core::ScalarValue;
use sparrow_arrow::scalar_value::ScalarValue;
use sparrow_plan::{InstKind, Mode};
use sparrow_syntax::{ArgVec, FenlType};

Expand Down
2 changes: 1 addition & 1 deletion crates/sparrow-compiler/src/plan/operation_to_plan.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ use sparrow_api::kaskada::v1alpha::{
expression_plan, operation_plan, OperationInputRef, OperationPlan, SlicePlan,
};
use sparrow_api::kaskada::v1alpha::{DataType, Schema};
use sparrow_core::ScalarValue;
use sparrow_arrow::scalar_value::ScalarValue;

use super::transform_to_plan::TransformToPlan;
use crate::dfg::{DfgExpr, Expression, Operation, StepKind};
Expand Down
2 changes: 1 addition & 1 deletion crates/sparrow-compiler/src/types/instruction.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use std::borrow::Cow;
use anyhow::{anyhow, Context};
use arrow::datatypes::{DataType, Field};
use itertools::{izip, Itertools};
use sparrow_core::ScalarValue;
use sparrow_arrow::scalar_value::ScalarValue;
use sparrow_instructions::CastEvaluator;
use sparrow_plan::{InstKind, Mode};
use sparrow_syntax::{ArgVec, FenlType, Resolved};
Expand Down
1 change: 1 addition & 0 deletions crates/sparrow-core/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ num.workspace = true
owning_ref.workspace = true
parquet.workspace = true
serde.workspace = true
sparrow-arrow = { path = "../sparrow-arrow" }
static_init.workspace = true
tonic.workspace = true
tracing.workspace = true
Expand Down
2 changes: 1 addition & 1 deletion crates/sparrow-core/src/key_triple.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ use arrow::datatypes::{ArrowPrimitiveType, TimestampNanosecondType, UInt64Type};
use arrow::record_batch::RecordBatch;
use owning_ref::ArcRef;

use crate::arrow_downcast::downcast_primitive_array;
use crate::TableSchema;
use sparrow_arrow::downcast::downcast_primitive_array;

/// The key columns for a given batch.
///
Expand Down
5 changes: 0 additions & 5 deletions crates/sparrow-core/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,19 +9,14 @@
)]
use std::pin::Pin;

mod arrow_downcast;
mod context_code;
mod key_triple;
mod scalar_value;
mod table_schema;
pub mod utils;

use arrow::record_batch::RecordBatch;
pub use arrow_downcast::*;
pub use context_code::*;
use futures::Stream;
pub use key_triple::{KeyTriple, KeyTriples};
pub use scalar_value::*;
pub use table_schema::TableSchema;

// A stream of record batches (wrapped in anyhow::Result, boxed and pinned).
Expand Down
2 changes: 1 addition & 1 deletion crates/sparrow-instructions/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ serde.workspace = true
serde_json.workspace = true
smallvec.workspace = true
sparrow-api = { path = "../sparrow-api" }
sparrow-core = { path = "../sparrow-core" }
sparrow-arrow = { path = "../sparrow-arrow" }
sparrow-kernels = { path = "../sparrow-kernels" }
sparrow-plan = { path = "../sparrow-plan" }
sparrow-syntax = { path = "../sparrow-syntax" }
Expand Down
4 changes: 2 additions & 2 deletions crates/sparrow-instructions/src/columnar_value.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@ use arrow::array::{
};
use arrow::datatypes::*;
use owning_ref::ArcRef;
use sparrow_core::{
use sparrow_arrow::downcast::{
downcast_boolean_array, downcast_primitive_array, downcast_string_array, downcast_struct_array,
NativeFromScalar, ScalarValue,
};
use sparrow_arrow::scalar_value::{NativeFromScalar, ScalarValue};

/// The input to an instruction.
#[derive(Debug, Clone)]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use std::sync::Arc;

use arrow::array::{ArrayRef, BooleanArray, UInt32Array};
use itertools::izip;
use sparrow_core::downcast_boolean_array;
use sparrow_arrow::downcast::downcast_boolean_array;
use sparrow_kernels::BitBufferIterator;
use sparrow_plan::ValueRef;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use std::sync::Arc;

use arrow::array::{ArrayRef, BooleanArray, UInt32Array};
use itertools::izip;
use sparrow_core::downcast_boolean_array;
use sparrow_arrow::downcast::downcast_boolean_array;
use sparrow_kernels::BitBufferIterator;
use sparrow_plan::ValueRef;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use anyhow::anyhow;
use arrow::array::{ArrayRef, BooleanArray, UInt32Array};
use arrow::datatypes::Int64Type;
use itertools::izip;
use sparrow_core::downcast_boolean_array;
use sparrow_arrow::downcast::downcast_boolean_array;
use sparrow_kernels::BitBufferIterator;
use sparrow_plan::ValueRef;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use anyhow::anyhow;
use arrow::array::{ArrayRef, BooleanArray, UInt32Array};
use arrow::datatypes::Int64Type;
use itertools::izip;
use sparrow_core::downcast_boolean_array;
use sparrow_arrow::downcast::downcast_boolean_array;
use sparrow_kernels::BitBufferIterator;
use sparrow_plan::ValueRef;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use std::sync::Arc;
use arrow::array::{ArrayRef, BooleanArray, PrimitiveArray, UInt32Array};
use arrow::datatypes::UInt32Type;
use itertools::izip;
use sparrow_core::downcast_boolean_array;
use sparrow_arrow::downcast::downcast_boolean_array;
use sparrow_kernels::BitBufferIterator;
use sparrow_plan::ValueRef;

Expand Down Expand Up @@ -315,7 +315,7 @@ impl CountIfEvaluator {
mod tests {
use arrow::array::UInt32Array;
use arrow::datatypes::UInt32Type;
use sparrow_core::downcast_primitive_array;
use sparrow_arrow::downcast::downcast_primitive_array;

use super::*;

Expand Down
Loading