Skip to content

Commit

Permalink
Update README
Browse files Browse the repository at this point in the history
  • Loading branch information
dadepo committed Nov 19, 2023
1 parent d6271cf commit 232595d
Showing 1 changed file with 45 additions and 0 deletions.
45 changes: 45 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,48 @@ A collection of user defined functions, from your favourite databases, in DataFu
| JSON | 🚧︎ Ongoing |
| Built-In Scalar | ⭘ Not Started |
| Maths | ⭘ Not Started |

## How to use

Since `df_extras` is not published to crates.io yet, directly specify the git repository link
as a dependency.

```toml
// In Cargo.toml
[dependencies]
datafusion = "33.0.0"
df_extras = { features = ["postgres"], git = "https://github.com/dadepo/df_extras" }
tokio = "1.34.0"
```

Then in code:

```rust
use datafusion::prelude::SessionContext;
use df_extras::postgres::register_postgres_udfs;

#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let ctx = SessionContext::new();

register_postgres_udfs(&ctx)?;

let df = ctx
.sql("select inet_merge('192.168.1.5/24', '192.168.2.5/24') as result")
.await?;

df.show().await?;

Ok(())
}
```

The above will print out

```
+----------------+
| result |
+----------------+
| 192.168.0.0/22 |
+----------------+
```

0 comments on commit 232595d

Please sign in to comment.