Skip to content

Commit

Permalink
Switch to one crate
Browse files Browse the repository at this point in the history
  • Loading branch information
dadepo committed Nov 19, 2023
1 parent bd7f798 commit d7b98e3
Show file tree
Hide file tree
Showing 19 changed files with 40 additions and 140 deletions.
19 changes: 1 addition & 18 deletions Cargo.lock

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

18 changes: 9 additions & 9 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
[workspace]
resolver = "2"
[package]
name = "df_extras"
version = "0.1.0"
edition = "2021"

members = [
"common",
"df_extras_postgres",
"df_extras_sqlite",
]

[workspace.dependencies]
[dependencies]
datafusion = "32.0.0"
ipnet = "2.7.2"
serde = "1.0.192"
serde_json = { version = "1.0.108", features = ["preserve_order"] }
tokio = { version = "1.25.0", features = ["macros", "rt", "parking_lot"] }

[features]
sqlite = []
postgres = []
12 changes: 10 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,14 @@

A collection of user defined functions, from your favourite databases, in DataFusion.

## Crates
## Road to 0.0.1

[df_extras_postgres](./df_postgres/README.md)
| **Postgres** | **[Details](supports/postgres.md)** |
|-----------------|-------------------------------------|
| Networking | ✅︎ Done |
| Maths | 🚧︎ Ongoing |
| JSON | ⭘ Not Started |
| **Sqlite** | **[Details](supports/sqlite.md)** |
| JSON | 🚧︎ Ongoing |
| Built-In Scalar | ⭘ Not Started |
| Maths | ⭘ Not Started |
8 changes: 0 additions & 8 deletions common/Cargo.toml

This file was deleted.

4 changes: 0 additions & 4 deletions df_extras_postgres/.gitignore

This file was deleted.

14 changes: 0 additions & 14 deletions df_extras_postgres/Cargo.toml

This file was deleted.

4 changes: 0 additions & 4 deletions df_extras_sqlite/.gitignore

This file was deleted.

15 changes: 0 additions & 15 deletions df_extras_sqlite/Cargo.toml

This file was deleted.

43 changes: 0 additions & 43 deletions df_extras_sqlite/README.md

This file was deleted.

File renamed without changes.
File renamed without changes.
3 changes: 3 additions & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
pub mod common;
pub mod postgres;
pub mod sqlite;
Original file line number Diff line number Diff line change
Expand Up @@ -39,12 +39,11 @@ pub fn div(args: &[ArrayRef]) -> Result<ArrayRef> {
#[cfg(feature = "postgres")]
#[cfg(test)]
mod tests {
use common::test_utils::set_up_network_data_test;
use crate::common::test_utils::set_up_network_data_test;
use crate::postgres::register_postgres_udfs;
use datafusion::assert_batches_sorted_eq;
use datafusion::prelude::SessionContext;

use crate::register_udfs;

use super::*;

#[tokio::test]
Expand Down Expand Up @@ -101,7 +100,7 @@ mod tests {

fn register_udfs_for_test() -> Result<SessionContext> {
let ctx = set_up_network_data_test()?;
register_udfs(&ctx)?;
register_postgres_udfs(&ctx)?;
Ok(ctx)
}
}
13 changes: 6 additions & 7 deletions df_extras_postgres/src/lib.rs → src/postgres/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,22 +2,21 @@

use std::sync::Arc;

use crate::postgres::math_udfs::{ceiling, div};
use crate::postgres::network_udfs::{
broadcast, family, host, hostmask, inet_merge, inet_same_family, masklen, netmask, network,
set_masklen,
};
use datafusion::arrow::datatypes::DataType::{Boolean, Float64, Int64, UInt8, Utf8};
use datafusion::error::Result;
use datafusion::logical_expr::{ReturnTypeFunction, ScalarUDF, Signature, Volatility};
use datafusion::physical_expr::functions::make_scalar_function;
use datafusion::prelude::SessionContext;

use crate::math_udfs::{ceiling, div};
use crate::network_udfs::{
broadcast, family, host, hostmask, inet_merge, inet_same_family, masklen, netmask, network,
set_masklen,
};

mod math_udfs;
mod network_udfs;

pub fn register_udfs(ctx: &SessionContext) -> Result<()> {
pub fn register_postgres_udfs(ctx: &SessionContext) -> Result<()> {
register_network_udfs(ctx)?;
register_math_udfs(ctx)?;
Ok(())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -420,13 +420,11 @@ fn bit_in_common(l: &[u8], r: &[u8], n: usize) -> usize {
#[cfg(feature = "postgres")]
#[cfg(test)]
mod tests {
use crate::common::test_utils::set_up_network_data_test;
use crate::postgres::register_postgres_udfs;
use datafusion::assert_batches_sorted_eq;
use datafusion::prelude::SessionContext;

use common::test_utils::set_up_network_data_test;

use crate::register_udfs;

use super::*;

#[tokio::test]
Expand Down Expand Up @@ -923,7 +921,7 @@ mod tests {

fn register_udfs_for_test() -> Result<SessionContext> {
let ctx = set_up_network_data_test()?;
register_udfs(&ctx)?;
register_postgres_udfs(&ctx)?;
Ok(ctx)
}
}
8 changes: 3 additions & 5 deletions df_extras_sqlite/src/json_udfs.rs → src/sqlite/json_udfs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -59,13 +59,11 @@ pub fn json_valid(args: &[ArrayRef]) -> Result<ArrayRef> {
#[cfg(feature = "sqlite")]
#[cfg(test)]
mod tests {
use crate::common::test_utils::set_up_json_data_test;
use crate::sqlite::register_sqlite_udfs;
use datafusion::assert_batches_sorted_eq;
use datafusion::prelude::SessionContext;

use common::test_utils::set_up_json_data_test;

use crate::register_udfs;

use super::*;

#[tokio::test]
Expand Down Expand Up @@ -150,7 +148,7 @@ mod tests {

fn register_udfs_for_test() -> Result<SessionContext> {
let ctx = set_up_json_data_test()?;
register_udfs(&ctx)?;
register_sqlite_udfs(&ctx)?;
Ok(ctx)
}
}
4 changes: 2 additions & 2 deletions df_extras_sqlite/src/lib.rs → src/sqlite/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@

mod json_udfs;

use crate::json_udfs::{json, json_valid};
use crate::sqlite::json_udfs::{json, json_valid};
use datafusion::arrow::datatypes::DataType::{UInt8, Utf8};
use datafusion::error::Result;
use datafusion::logical_expr::{ReturnTypeFunction, ScalarUDF, Signature, Volatility};
use datafusion::physical_expr::functions::make_scalar_function;
use datafusion::prelude::SessionContext;
use std::sync::Arc;

pub fn register_udfs(ctx: &SessionContext) -> Result<()> {
pub fn register_sqlite_udfs(ctx: &SessionContext) -> Result<()> {
register_json(ctx);
register_json_valid(ctx);
Ok(())
Expand Down
File renamed without changes.
Empty file added supports/sqlite.md
Empty file.

0 comments on commit d7b98e3

Please sign in to comment.