Skip to content

Commit

Permalink
Refactoring regexp_count
Browse files Browse the repository at this point in the history
  • Loading branch information
xinlifoobar committed Aug 28, 2024
1 parent 08343dd commit 218ff7b
Show file tree
Hide file tree
Showing 10 changed files with 418 additions and 270 deletions.
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ homepage = "https://datafusion.apache.org"
license = "Apache-2.0"
readme = "README.md"
repository = "https://github.com/apache/datafusion"
rust-version = "1.80"
rust-version = "1.76"
version = "41.0.0"

[workspace.dependencies]
Expand Down
2 changes: 1 addition & 1 deletion datafusion-cli/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ license = "Apache-2.0"
homepage = "https://datafusion.apache.org"
repository = "https://github.com/apache/datafusion"
# Specify MSRV here as `cargo msrv` doesn't support workspace version
rust-version = "1.80"
rust-version = "1.76"
readme = "README.md"

[dependencies]
Expand Down
33 changes: 33 additions & 0 deletions datafusion-examples/examples/regex_count.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
use datafusion::common::Result;
use datafusion::prelude::{CsvReadOptions, SessionContext};

#[tokio::main]
async fn main() -> Result<()> {
let ctx = SessionContext::new();
ctx.register_csv(
"examples",
"../../datafusion/physical-expr/tests/data/regex.csv",
CsvReadOptions::new(),
)
.await?;

//
//
//regexp_count examples
//
//
// regexp_count format is (regexp_count(text, regex[, flags])
//

// use sql and regexp_count function to test col 'values', against patterns in col 'patterns' without flags
let result = ctx
.sql("select regexp_count(values, patterns) from examples")
.await?
.collect()
.await?;

println!("{:?}", result);
assert_eq!(result.len(), 1);

Ok(())
}
2 changes: 1 addition & 1 deletion datafusion/core/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ authors = { workspace = true }
# Specify MSRV here as `cargo msrv` doesn't support workspace version and fails with
# "Unable to find key 'package.rust-version' (or 'package.metadata.msrv') in 'arrow-datafusion/Cargo.toml'"
# https://github.com/foresterre/cargo-msrv/issues/590
rust-version = "1.80"
rust-version = "1.76"

[lints]
workspace = true
Expand Down
Loading

0 comments on commit 218ff7b

Please sign in to comment.