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

[POC] Try to plan ast::Expr::CompoundFieldAccess syntax #13734

Draft
wants to merge 9 commits into
base: main
Choose a base branch
from
Draft
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
4 changes: 4 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -177,3 +177,7 @@ large_futures = "warn"
[workspace.lints.rust]
unexpected_cfgs = { level = "warn", check-cfg = ["cfg(tarpaulin)"] }
unused_qualifications = "deny"

## Temp patch for sqlparser
[patch.crates-io]
sqlparser = { git = "https://github.com/apache/datafusion-sqlparser-rs.git", rev = "d6743e924c99cebaa1f065eb721ae085f9f0116f" }
30 changes: 14 additions & 16 deletions datafusion-cli/Cargo.lock

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

4 changes: 4 additions & 0 deletions datafusion-cli/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -67,3 +67,7 @@ assert_cmd = "2.0"
ctor = "0.2.0"
predicates = "3.0"
rstest = "0.22"

## Temp patch for sqlparser
[patch.crates-io]
sqlparser = { git = "https://github.com/apache/datafusion-sqlparser-rs.git", rev = "d6743e924c99cebaa1f065eb721ae085f9f0116f" }
5 changes: 3 additions & 2 deletions datafusion/common/src/utils/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -887,10 +887,10 @@ pub fn get_available_parallelism() -> usize {

#[cfg(test)]
mod tests {
use super::*;
use crate::ScalarValue::Null;
use arrow::array::Float64Array;

use super::*;
use sqlparser::tokenizer::Span;

#[test]
fn test_bisect_linear_left_and_right() -> Result<()> {
Expand Down Expand Up @@ -1118,6 +1118,7 @@ mod tests {
let expected_parsed = vec![Ident {
value: identifier.to_string(),
quote_style,
span: Span::empty(),
}];

assert_eq!(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,6 @@ use arrow_array::{
Array, ArrayRef, Float32Array, Float64Array, Int32Array, RecordBatch, StringArray,
};
use arrow_schema::{DataType, Field, Schema};
use parking_lot::Mutex;
use regex::Regex;
use sqlparser::ast::Ident;

use datafusion::execution::context::{FunctionFactory, RegisterFunction, SessionState};
use datafusion::prelude::*;
use datafusion::{execution::registry::FunctionRegistry, test_util};
Expand All @@ -48,6 +44,10 @@ use datafusion_expr::{
Volatility,
};
use datafusion_functions_nested::range::range_udf;
use parking_lot::Mutex;
use regex::Regex;
use sqlparser::ast::Ident;
use sqlparser::tokenizer::Span;

/// test that casting happens on udfs.
/// c11 is f32, but `custom_sqrt` requires f64. Casting happens but the logical plan and
Expand Down Expand Up @@ -1187,6 +1187,7 @@ async fn create_scalar_function_from_sql_statement_postgres_syntax() -> Result<(
name: Some(Ident {
value: "name".into(),
quote_style: None,
span: Span::empty(),
}),
data_type: DataType::Utf8,
default_expr: None,
Expand All @@ -1196,6 +1197,7 @@ async fn create_scalar_function_from_sql_statement_postgres_syntax() -> Result<(
language: Some(Ident {
value: "plrust".into(),
quote_style: None,
span: Span::empty(),
}),
behavior: None,
function_body: Some(lit(body)),
Expand Down
2 changes: 2 additions & 0 deletions datafusion/expr/src/expr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -222,6 +222,8 @@ use sqlparser::ast::{
/// // to 42 = 5 AND b = 6
/// assert_eq!(rewritten.data, lit(42).eq(lit(5)).and(col("b").eq(lit(6))));
#[derive(Clone, PartialEq, Eq, PartialOrd, Hash, Debug)]
// TODO make the enum smaller with more boxing (looks like Wildcard is now bigger)
#[allow(clippy::large_enum_variant)]
pub enum Expr {
/// An expression with a specific name.
Alias(Alias),
Expand Down
5 changes: 5 additions & 0 deletions datafusion/sql/src/expr/function.rs
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,11 @@ impl FunctionArgs {
"Calling {name}: SEPARATOR not supported in function arguments: {sep}"
)
}
FunctionArgumentClause::JsonNullClause(jn) => {
return not_impl_err!(
"Calling {name}: JSON NULL clause not supported in function arguments: {jn}"
)
}
}
}

Expand Down
Loading
Loading