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

Introduce JIT code generation #1849

Merged
merged 6 commits into from
Feb 24, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ members = [
"datafusion",
"datafusion-common",
"datafusion-expr",
"datafusion-jit",
"datafusion-physical-expr",
"datafusion-cli",
"datafusion-examples",
Expand Down
2 changes: 2 additions & 0 deletions datafusion-common/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ path = "src/lib.rs"
[features]
avro = ["avro-rs"]
pyarrow = ["pyo3"]
jit = ["cranelift-module"]

[dependencies]
arrow = { version = "9.0.0", features = ["prettyprint"] }
Expand All @@ -43,3 +44,4 @@ avro-rs = { version = "0.13", features = ["snappy"], optional = true }
pyo3 = { version = "0.15", optional = true }
sqlparser = "0.14"
ordered-float = "2.10"
cranelift-module = { version = "0.81.0", optional = true }
23 changes: 23 additions & 0 deletions datafusion-common/src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ use std::result;
use arrow::error::ArrowError;
#[cfg(feature = "avro")]
use avro_rs::Error as AvroError;
#[cfg(feature = "jit")]
use cranelift_module::ModuleError;
use parquet::errors::ParquetError;
use sqlparser::parser::ParserError;

Expand Down Expand Up @@ -69,6 +71,9 @@ pub enum DataFusionError {
/// Errors originating from outside DataFusion's core codebase.
/// For example, a custom S3Error from the crate datafusion-objectstore-s3
External(GenericError),
#[cfg(feature = "jit")]
/// Error occurs during code generation
JITError(ModuleError),
}

impl From<io::Error> for DataFusionError {
Expand Down Expand Up @@ -112,6 +117,13 @@ impl From<ParserError> for DataFusionError {
}
}

#[cfg(feature = "jit")]
impl From<ModuleError> for DataFusionError {
fn from(e: ModuleError) -> Self {
DataFusionError::JITError(e)
}
}

impl From<GenericError> for DataFusionError {
fn from(err: GenericError) -> Self {
DataFusionError::External(err)
Expand Down Expand Up @@ -152,6 +164,10 @@ impl Display for DataFusionError {
DataFusionError::External(ref desc) => {
write!(f, "External error: {}", desc)
}
#[cfg(feature = "jit")]
DataFusionError::JITError(ref desc) => {
write!(f, "JIT error: {}", desc)
}
}
}
}
Expand Down Expand Up @@ -196,3 +212,10 @@ mod test {
Ok(())
}
}

#[macro_export]
macro_rules! internal_err {
($($arg:tt)*) => {
Err(DataFusionError::Internal(format!($($arg)*)))
};
}
43 changes: 43 additions & 0 deletions datafusion-jit/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
# 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-jit"
description = "DataFusion is an in-memory query engine that uses Apache Arrow as the memory model"
version = "7.0.0"
homepage = "https://github.com/apache/arrow-datafusion"
repository = "https://github.com/apache/arrow-datafusion"
readme = "../README.md"
authors = ["Apache Arrow <dev@arrow.apache.org>"]
license = "Apache-2.0"
keywords = [ "arrow", "query", "sql" ]
edition = "2021"
rust-version = "1.58"

[lib]
name = "datafusion_jit"
path = "src/lib.rs"

[features]
jit = []

[dependencies]
datafusion-common = { path = "../datafusion-common", version = "7.0.0", features = ["jit"] }
cranelift = "0.81.0"
cranelift-module = "0.81.0"
cranelift-jit = "0.81.0"
parking_lot = "0.12"
Loading