Skip to content
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
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ regex = "1.8"
rstest = "0.24.0"
serde_json = "1"
sqlparser = { git = "https://github.com/Embucket/datafusion-sqlparser-rs.git", rev = "ed416548dcfe4a73a3240bbf625fb9010a4925c8", features = [
"visitor",
"visitor",
] }
tempfile = "3"
tokio = { version = "1.44", features = ["macros", "rt", "sync"] }
Expand Down
28 changes: 21 additions & 7 deletions datafusion/ffi/src/udtf.rs
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,11 @@ unsafe extern "C" fn call_fn_wrapper(
let args =
rresult_return!(parse_exprs(proto_filters.expr.iter(), &default_ctx, &codec));

let table_provider = rresult_return!(udtf.call(&args));
let args_with_names = args
.into_iter()
.map(|expr| (expr, None))
.collect::<Vec<_>>();
let table_provider = rresult_return!(udtf.call(&args_with_names));
RResult::ROk(FFI_TableProvider::new(table_provider, false, runtime))
}

Expand Down Expand Up @@ -176,10 +180,13 @@ impl From<FFI_TableFunction> for ForeignTableFunction {
}

impl TableFunctionImpl for ForeignTableFunction {
fn call(&self, args: &[Expr]) -> Result<Arc<dyn TableProvider>> {
fn call(&self, args: &[(Expr, Option<String>)]) -> Result<Arc<dyn TableProvider>> {
let codec = DefaultLogicalExtensionCodec {};
let expr_list = LogicalExprList {
expr: serialize_exprs(args, &codec)?,
expr: serialize_exprs(
args.iter().map(|(expr, _)| expr).collect::<Vec<_>>(),
&codec,
)?,
};
let filters_serialized = expr_list.encode_to_vec().into();

Expand Down Expand Up @@ -210,10 +217,13 @@ mod tests {
struct TestUDTF {}

impl TableFunctionImpl for TestUDTF {
fn call(&self, args: &[Expr]) -> Result<Arc<dyn TableProvider>> {
fn call(
&self,
args: &[(Expr, Option<String>)],
) -> Result<Arc<dyn TableProvider>> {
let args = args
.iter()
.map(|arg| {
.map(|(arg, _)| {
if let Expr::Literal(scalar) = arg {
Ok(scalar)
} else {
Expand Down Expand Up @@ -293,8 +303,12 @@ mod tests {

let foreign_udf: ForeignTableFunction = local_udtf.into();

let table =
foreign_udf.call(&vec![lit(6_u64), lit("one"), lit(2.0), lit(3_u64)])?;
let table = foreign_udf.call(&vec![
(lit(6_u64), None),
(lit("one"), None),
(lit(2.0), None),
(lit(3_u64), None),
])?;

let ctx = SessionContext::default();
let _ = ctx.register_table("test-table", table)?;
Expand Down
8 changes: 6 additions & 2 deletions datafusion/functions/src/datetime/to_date.rs
Original file line number Diff line number Diff line change
Expand Up @@ -455,8 +455,12 @@ mod tests {
ScalarValue::TimestampNanosecond(Some(1736782134736782134), None),
];
for scalar in test_cases {
let timestamp_to_date_result = ToDateFunc::new()
.invoke_batch(&[ColumnarValue::Scalar(scalar.clone())], 1);
let timestamp_to_date_result =
ToDateFunc::new().invoke_with_args(datafusion_expr::ScalarFunctionArgs {
args: vec![ColumnarValue::Scalar(scalar.clone())],
number_rows: 1,
return_type: &DataType::Date32,
});

match timestamp_to_date_result {
Ok(ColumnarValue::Scalar(ScalarValue::Date32(date_val))) => {
Expand Down
2 changes: 1 addition & 1 deletion datafusion/functions/src/regex/regexplike.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ use datafusion_expr::{
use datafusion_macros::user_doc;

use std::any::Any;
use std::sync::{Arc, OnceLock};
use std::sync::Arc;

#[user_doc(
doc_section(label = "Regular Expression Functions"),
Expand Down
2 changes: 1 addition & 1 deletion datafusion/sql/src/parser.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1070,7 +1070,7 @@ mod tests {
}

#[test]
fn skip_create_stage_snowflake() -> Result<(), ParserError> {
fn skip_create_stage_snowflake() -> Result<(), DataFusionError> {
let sql =
"CREATE OR REPLACE STAGE stage URL='s3://data.csv' FILE_FORMAT=(TYPE=csv)";
let dialect = Box::new(SnowflakeDialect);
Expand Down
2 changes: 1 addition & 1 deletion docs/source/user-guide/sql/scalar_functions.md
Original file line number Diff line number Diff line change
Expand Up @@ -1956,7 +1956,7 @@ Additional examples can be found [here](https://github.com/apache/datafusion/blo

Returns the substring that matches a [regular expression](https://docs.rs/regex/latest/regex/#syntax) within a string.

```
```sql
regexp_substr(str, regexp[, position[, occurrence[, flags[, group_num]]]])
```

Expand Down
Loading