Skip to content
Open
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
2 changes: 1 addition & 1 deletion .github/workflows/rust.yml
Original file line number Diff line number Diff line change
Expand Up @@ -579,7 +579,7 @@ jobs:
with:
rust-version: stable
- name: Run datafusion-common tests
run: cargo test --profile ci -p datafusion-common --features=pyarrow
run: cargo test --profile ci -p datafusion-common --features=pyarrow,sql
Copy link
Contributor

Choose a reason for hiding this comment

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

Should we extend the CI to also verify that ALL crates at least cargo check with and without sql support? This YAML file has a few examples/listings of feature tests with cargo check.


vendor:
name: Verify Vendored Code
Expand Down
13 changes: 2 additions & 11 deletions Cargo.lock

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

6 changes: 3 additions & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -121,14 +121,14 @@ datafusion-datasource-csv = { path = "datafusion/datasource-csv", version = "49.
datafusion-datasource-json = { path = "datafusion/datasource-json", version = "49.0.0", default-features = false }
datafusion-datasource-parquet = { path = "datafusion/datasource-parquet", version = "49.0.0", default-features = false }
datafusion-doc = { path = "datafusion/doc", version = "49.0.0" }
datafusion-execution = { path = "datafusion/execution", version = "49.0.0" }
datafusion-expr = { path = "datafusion/expr", version = "49.0.0" }
datafusion-execution = { path = "datafusion/execution", version = "49.0.0", default-features = false }
datafusion-expr = { path = "datafusion/expr", version = "49.0.0", default-features = false }
datafusion-expr-common = { path = "datafusion/expr-common", version = "49.0.0" }
datafusion-ffi = { path = "datafusion/ffi", version = "49.0.0" }
datafusion-functions = { path = "datafusion/functions", version = "49.0.0" }
datafusion-functions-aggregate = { path = "datafusion/functions-aggregate", version = "49.0.0" }
datafusion-functions-aggregate-common = { path = "datafusion/functions-aggregate-common", version = "49.0.0" }
datafusion-functions-nested = { path = "datafusion/functions-nested", version = "49.0.0" }
datafusion-functions-nested = { path = "datafusion/functions-nested", version = "49.0.0", default-features = false }
datafusion-functions-table = { path = "datafusion/functions-table", version = "49.0.0" }
datafusion-functions-window = { path = "datafusion/functions-window", version = "49.0.0" }
datafusion-functions-window-common = { path = "datafusion/functions-window-common", version = "49.0.0" }
Expand Down
3 changes: 2 additions & 1 deletion datafusion-cli/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ aws-credential-types = "1.2.6"
clap = { version = "4.5.47", features = ["derive", "cargo"] }
datafusion = { workspace = true, features = [
"avro",
"compression",
"crypto_expressions",
"datetime_expressions",
"encoding_expressions",
Expand All @@ -50,8 +51,8 @@ datafusion = { workspace = true, features = [
"parquet_encryption",
"recursive_protection",
"regex_expressions",
"sql",
"unicode_expressions",
"compression",
] }
dirs = "6.0.0"
env_logger = { workspace = true }
Expand Down
1 change: 0 additions & 1 deletion datafusion/catalog/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@ datafusion-expr = { workspace = true }
datafusion-physical-expr = { workspace = true }
datafusion-physical-plan = { workspace = true }
datafusion-session = { workspace = true }
datafusion-sql = { workspace = true }
futures = { workspace = true }
itertools = { workspace = true }
log = { workspace = true }
Expand Down
4 changes: 3 additions & 1 deletion datafusion/common/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ pyarrow = ["pyo3", "arrow/pyarrow", "parquet"]
force_hash_collisions = []
recursive_protection = ["dep:recursive"]
parquet = ["dep:parquet"]
sql = ["sqlparser"]

[dependencies]
ahash = { workspace = true }
Expand All @@ -73,7 +74,7 @@ parquet = { workspace = true, optional = true, default-features = true }
paste = "1.0.15"
pyo3 = { version = "0.25", optional = true }
recursive = { workspace = true, optional = true }
sqlparser = { workspace = true }
sqlparser = { workspace = true, optional = true }
tokio = { workspace = true }

[target.'cfg(target_family = "wasm")'.dependencies]
Expand All @@ -83,3 +84,4 @@ web-time = "1.1.0"
chrono = { workspace = true }
insta = { workspace = true }
rand = { workspace = true }
sqlparser = { workspace = true }
16 changes: 11 additions & 5 deletions datafusion/common/src/column.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,12 @@
//! Column

use crate::error::{_schema_err, add_possible_columns_to_diag};
use crate::utils::{parse_identifiers_normalized, quote_identifier};
use crate::utils::parse_identifiers_normalized;
use crate::utils::quote_identifier;
use crate::{DFSchema, Diagnostic, Result, SchemaError, Spans, TableReference};
use arrow::datatypes::{Field, FieldRef};
use std::collections::HashSet;
use std::convert::Infallible;
use std::fmt;
use std::str::FromStr;

/// A named reference to a qualified field in a schema.
#[derive(Clone, PartialEq, Eq, Hash, PartialOrd, Ord)]
Expand Down Expand Up @@ -140,6 +139,7 @@ impl Column {
}

/// Deserialize a fully qualified name string into a column preserving column text case
#[cfg(feature = "sql")]
pub fn from_qualified_name_ignore_case(flat_name: impl Into<String>) -> Self {
let flat_name = flat_name.into();
Self::from_idents(parse_identifiers_normalized(&flat_name, true)).unwrap_or_else(
Expand All @@ -151,6 +151,11 @@ impl Column {
)
}

#[cfg(not(feature = "sql"))]
pub fn from_qualified_name_ignore_case(flat_name: impl Into<String>) -> Self {
Self::from_qualified_name(flat_name)
}

/// return the column's name.
///
/// Note: This ignores the relation and returns the column name only.
Expand Down Expand Up @@ -356,8 +361,9 @@ impl From<(Option<&TableReference>, &FieldRef)> for Column {
}
}

impl FromStr for Column {
type Err = Infallible;
#[cfg(feature = "sql")]
impl std::str::FromStr for Column {
type Err = std::convert::Infallible;

fn from_str(s: &str) -> Result<Self, Self::Err> {
Ok(s.into())
Expand Down
4 changes: 3 additions & 1 deletion datafusion/common/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2671,9 +2671,11 @@ impl Display for OutputFormat {

#[cfg(test)]
mod tests {
#[cfg(feature = "parquet")]
use crate::config::TableParquetOptions;
use crate::config::{
ConfigEntry, ConfigExtension, ConfigField, ConfigFileType, ExtensionOptions,
Extensions, TableOptions, TableParquetOptions,
Extensions, TableOptions,
};
use std::any::Any;
use std::collections::HashMap;
Expand Down
6 changes: 6 additions & 0 deletions datafusion/common/src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ use apache_avro::Error as AvroError;
use arrow::error::ArrowError;
#[cfg(feature = "parquet")]
use parquet::errors::ParquetError;
#[cfg(feature = "sql")]
use sqlparser::parser::ParserError;
use tokio::task::JoinError;

Expand Down Expand Up @@ -68,6 +69,7 @@ pub enum DataFusionError {
/// Error when SQL is syntactically incorrect.
///
/// 2nd argument is for optional backtrace
#[cfg(feature = "sql")]
SQL(Box<ParserError>, Option<String>),
/// Error when a feature is not yet implemented.
///
Expand Down Expand Up @@ -329,6 +331,7 @@ impl From<object_store::path::Error> for DataFusionError {
}
}

#[cfg(feature = "sql")]
impl From<ParserError> for DataFusionError {
fn from(e: ParserError) -> Self {
DataFusionError::SQL(Box::new(e), None)
Expand Down Expand Up @@ -369,6 +372,7 @@ impl Error for DataFusionError {
#[cfg(feature = "object_store")]
DataFusionError::ObjectStore(e) => Some(e.as_ref()),
DataFusionError::IoError(e) => Some(e),
#[cfg(feature = "sql")]
DataFusionError::SQL(e, _) => Some(e.as_ref()),
DataFusionError::NotImplemented(_) => None,
DataFusionError::Internal(_) => None,
Expand Down Expand Up @@ -497,6 +501,7 @@ impl DataFusionError {
#[cfg(feature = "object_store")]
DataFusionError::ObjectStore(_) => "Object Store error: ",
DataFusionError::IoError(_) => "IO error: ",
#[cfg(feature = "sql")]
DataFusionError::SQL(_, _) => "SQL error: ",
DataFusionError::NotImplemented(_) => {
"This feature is not implemented: "
Expand Down Expand Up @@ -534,6 +539,7 @@ impl DataFusionError {
#[cfg(feature = "avro")]
DataFusionError::AvroError(ref desc) => Cow::Owned(desc.to_string()),
DataFusionError::IoError(ref desc) => Cow::Owned(desc.to_string()),
#[cfg(feature = "sql")]
DataFusionError::SQL(ref desc, ref backtrace) => {
let backtrace: String =
backtrace.clone().unwrap_or_else(|| "".to_owned());
Expand Down
8 changes: 4 additions & 4 deletions datafusion/common/src/parsers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
use std::fmt::Display;
use std::str::FromStr;

use sqlparser::parser::ParserError;
use crate::DataFusionError;

/// Readable file compression type
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
Expand All @@ -38,17 +38,17 @@ pub enum CompressionTypeVariant {
}

impl FromStr for CompressionTypeVariant {
type Err = ParserError;
type Err = DataFusionError;

fn from_str(s: &str) -> Result<Self, ParserError> {
fn from_str(s: &str) -> Result<Self, Self::Err> {
let s = s.to_uppercase();
match s.as_str() {
"GZIP" | "GZ" => Ok(Self::GZIP),
"BZIP2" | "BZ2" => Ok(Self::BZIP2),
"XZ" => Ok(Self::XZ),
"ZST" | "ZSTD" => Ok(Self::ZSTD),
"" | "UNCOMPRESSED" => Ok(Self::UNCOMPRESSED),
_ => Err(ParserError::ParserError(format!(
_ => Err(DataFusionError::NotImplemented(format!(
"Unsupported file compression type {s}"
))),
}
Expand Down
2 changes: 2 additions & 0 deletions datafusion/common/src/spans.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ impl fmt::Debug for Location {
}
}

#[cfg(feature = "sql")]
impl From<sqlparser::tokenizer::Location> for Location {
fn from(value: sqlparser::tokenizer::Location) -> Self {
Self {
Expand Down Expand Up @@ -70,6 +71,7 @@ impl Span {
/// Convert a [`Span`](sqlparser::tokenizer::Span) from the parser, into a
/// DataFusion [`Span`]. If the input span is empty (line 0 column 0, to
/// line 0 column 0), then [`None`] is returned.
#[cfg(feature = "sql")]
pub fn try_from_sqlparser_span(span: sqlparser::tokenizer::Span) -> Option<Span> {
if span == sqlparser::tokenizer::Span::empty() {
None
Expand Down
27 changes: 17 additions & 10 deletions datafusion/common/src/table_reference.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@
// specific language governing permissions and limitations
// under the License.

use crate::utils::{parse_identifiers_normalized, quote_identifier};
use crate::utils::parse_identifiers_normalized;
use crate::utils::quote_identifier;
use std::sync::Arc;

/// A fully resolved path to a table of the form "catalog.schema.table"
Expand Down Expand Up @@ -367,26 +368,32 @@ mod tests {
let actual = TableReference::from("TABLE");
assert_eq!(expected, actual);

// if fail to parse, take entire input string as identifier
let expected = TableReference::Bare {
table: "TABLE()".into(),
};
let actual = TableReference::from("TABLE()");
assert_eq!(expected, actual);
// Disable this test for non-sql features so that we don't need to reproduce
// things like table function upper case conventions, since those will not
// be used if SQL is not selected.
#[cfg(feature = "sql")]
{
// if fail to parse, take entire input string as identifier
let expected = TableReference::Bare {
table: "TABLE()".into(),
};
let actual = TableReference::from("TABLE()");
assert_eq!(expected, actual);
}
}

#[test]
fn test_table_reference_to_vector() {
let table_reference = TableReference::parse_str("table");
let table_reference = TableReference::from("table");
assert_eq!(vec!["table".to_string()], table_reference.to_vec());

let table_reference = TableReference::parse_str("schema.table");
let table_reference = TableReference::from("schema.table");
assert_eq!(
vec!["schema".to_string(), "table".to_string()],
table_reference.to_vec()
);

let table_reference = TableReference::parse_str("catalog.schema.table");
let table_reference = TableReference::from("catalog.schema.table");
assert_eq!(
vec![
"catalog".to_string(),
Expand Down
Loading