Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/KipData/FnckSQL
Fast Insert lightweight embedded SQL database
https://github.com/KipData/FnckSQL
data database embeddings oltp query-engine rust sql
Last synced: 2 months ago
JSON representation
Fast Insert lightweight embedded SQL database
- Host: GitHub
- URL: https://github.com/KipData/FnckSQL
- Owner: KipData
- License: apache-2.0
- Created: 2023-06-05T03:53:10.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2024-01-28T19:30:19.000Z (12 months ago)
- Last Synced: 2024-01-28T20:29:06.633Z (12 months ago)
- Topics: data, database, embeddings, oltp, query-engine, rust, sql
- Language: Rust
- Homepage: http://www.kipdata.site/
- Size: 1.86 MB
- Stars: 122
- Watchers: 4
- Forks: 19
- Open Issues: 5
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
- awesome - KipData/FnckSQL - SQL as a Function for Rust (Rust)
- awesome-rust - FnckSQL
- awesome-rust - FnckSQL - SQL as a Function for Rust (Applications / Database)
- fucking-awesome-rust - FnckSQL - SQL as a Function for Rust (Applications / Database)
- fucking-awesome-rust - FnckSQL - SQL as a Function for Rust (Applications / Database)
README
Built by @KipData███████╗███╗ ██╗ ██████╗██╗ ██╗ ███████╗ ██████╗ ██╗
██╔════╝████╗ ██║██╔════╝██║ ██╔╝ ██╔════╝██╔═══██╗██║
█████╗ ██╔██╗ ██║██║ █████╔╝ ███████╗██║ ██║██║
██╔══╝ ██║╚██╗██║██║ ██╔═██╗ ╚════██║██║▄▄ ██║██║
██║ ██║ ╚████║╚██████╗██║ ██╗ ███████║╚██████╔╝███████╗
╚═╝ ╚═╝ ╚═══╝ ╚═════╝╚═╝ ╚═╝ ╚══════╝ ╚══▀▀═╝ ╚══════╝-----------------------------------
🖕
Lightweight DBMS
### What is FnckSQL
FnckSQL is a high-performance SQL database
that can be embedded in Rust code (based on RocksDB by default),
making it possible to call SQL just like calling a function.
It supports most of the syntax of SQL 2016.### Quick Started
Tips: Install rust toolchain and llvm first.Clone the repository
``` shell
git clone https://github.com/KipData/FnckSQL.git
```
#### Using FnckSQL in code
```rust
let fnck_sql = DataBaseBuilder::path("./data").build()?;
let tuples = fnck_sql.run("select * from t1")?;
```#### PG Wire Service
run `cargo run --features="net"` to start server
![start](./static/images/start.gif)
then use `psql` to enter sql
![pg](./static/images/pg.gif)Storage Support:
- RocksDB### Docker
#### Pull Image
```shell
docker pull kould23333/fncksql:latest
```
#### Build From Source
~~~shell
git clone https://github.com/KipData/FnckSQL.git
cd FnckSQL
docker build -t kould23333/fncksql:latest .
~~~#### Run
We installed the `psql` tool in the image for easy debug.You can use `psql -h 127.0.0.1 -p 5432` to do this.
~~~shell
docker run -d \
--name=fncksql \
-p 5432:5432 \
--restart=always \
-v fncksql-data:/fnck_sql/fncksql_data \
-v /etc/localtime:/etc/localtime:ro \
kould23333/fncksql:latest
~~~### Features
- ORM Mapping: `features = ["macros"]`
```rust
#[derive(Default, Debug, PartialEq)]
struct MyStruct {
c1: i32,
c2: String,
}implement_from_tuple!(
MyStruct, (
c1: i32 => |inner: &mut MyStruct, value| {
if let DataValue::Int32(Some(val)) = value {
inner.c1 = val;
}
},
c2: String => |inner: &mut MyStruct, value| {
if let DataValue::Utf8(Some(val)) = value {
inner.c2 = val;
}
}
)
);
```
- User-Defined Function: `features = ["macros"]`
```rust
scala_function!(TestFunction::test(LogicalType::Integer, LogicalType::Integer) -> LogicalType::Integer => |v1: ValueRef, v2: ValueRef| {
let plus_binary_evaluator = EvaluatorFactory::binary_create(LogicalType::Integer, BinaryOperator::Plus)?;
let value = plus_binary_evaluator.binary_eval(&v1, &v2);let plus_unary_evaluator = EvaluatorFactory::unary_create(LogicalType::Integer, UnaryOperator::Minus)?;
Ok(plus_unary_evaluator.unary_eval(&value))
});let fnck_sql = DataBaseBuilder::path("./data")
.register_scala_function(TestFunction::new())
.build()?;
```
- User-Defined Table Function: `features = ["macros"]`
```rust
table_function!(MyTableFunction::test_numbers(LogicalType::Integer) -> [c1: LogicalType::Integer, c2: LogicalType::Integer] => (|v1: ValueRef| {
let num = v1.i32().unwrap();Ok(Box::new((0..num)
.into_iter()
.map(|i| Ok(Tuple {
id: None,
values: vec![
Arc::new(DataValue::Int32(Some(i))),
Arc::new(DataValue::Int32(Some(i))),
]
}))) as Box>>)
}));
let fnck_sql = DataBaseBuilder::path("./data")
.register_table_function(MyTableFunction::new())
.build()?;
```
- Optimizer
- RBO
- CBO based on RBO(Physical Selection)
- Execute
- Volcano
- MVCC Transaction
- Optimistic
- Field options
- [not] null
- unique
- primary key
- SQL where options
- is [not] null
- [not] like
- [not] in
- Supports index type
- PrimaryKey
- Unique
- Normal
- Composite
- Supports multiple primary key types
- Tinyint
- UTinyint
- Smallint
- USmallint
- Integer
- UInteger
- Bigint
- UBigint
- Char
- Varchar
- DDL
- Begin (Server only)
- Commit (Server only)
- Rollback (Server only)
- Create
- [x] Table
- [x] Index: Unique\Normal\Composite
- [x] View
- Drop
- [x] Table
- [ ] Index
- [ ] View
- Alert
- [x] Add Column
- [x] Drop Column
- [x] Truncate
- DQL
- [x] Select
- SeqScan
- IndexScan
- [x] Where
- [x] Distinct
- [x] Alias
- [x] Aggregation: count()/sum()/avg()/min()/max()
- [x] SubQuery[select/from/where]
- [x] Join: Inner/Left/Right/Full/Cross (Natural\Using)
- [x] Group By
- [x] Having
- [x] Order By
- [x] Limit
- [x] Show Tables
- [x] Explain
- [x] Describe
- [x] Union
- DML
- [x] Insert
- [x] Insert Overwrite
- [x] Update
- [x] Delete
- [x] Analyze
- DataTypes
- Invalid
- SqlNull
- Boolean
- Tinyint
- UTinyint
- Smallint
- USmallint
- Integer
- UInteger
- Bigint
- UBigint
- Float
- Double
- Char
- Varchar
- Date
- DateTime
- Time
- Tuple## Roadmap
- SQL 2016## License
FnckSQL uses the [Apache 2.0 license][1] to strike a balance between
open contributions and allowing you to use the software however you want.[1]:
## Contributors
[![](https://opencollective.com/fncksql/contributors.svg?width=890&button=false)](https://github.com/KipData/FnckSQL/graphs/contributors)## Thanks For
- [Fedomn/sqlrs](https://github.com/Fedomn/sqlrs): Main reference materials, Optimizer and Executor all refer to the design of sqlrs
- [systemxlabs/bustubx](https://github.com/systemxlabs/bustubx)
- [duckdb/duckdb](https://github.com/duckdb/duckdb)