{"id":15041129,"url":"https://github.com/theshubhamp/fetadb","last_synced_at":"2025-08-21T09:32:00.145Z","repository":{"id":243117889,"uuid":"811516413","full_name":"theshubhamp/fetadb","owner":"theshubhamp","description":"FetaDB is a Work-In-Progress SQL Database backed by a KV store (Badger)","archived":false,"fork":false,"pushed_at":"2024-08-01T12:58:27.000Z","size":131,"stargazers_count":8,"open_issues_count":1,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-04-08T07:42:48.750Z","etag":null,"topics":["database","databases","diy-project","kev-value","kv"],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/theshubhamp.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-06-06T18:44:22.000Z","updated_at":"2024-08-01T12:58:31.000Z","dependencies_parsed_at":"2024-12-19T21:41:56.425Z","dependency_job_id":null,"html_url":"https://github.com/theshubhamp/fetadb","commit_stats":{"total_commits":107,"total_committers":1,"mean_commits":107.0,"dds":0.0,"last_synced_commit":"e5f8244d398f25d490a442a1bb0dfc2b5203f174"},"previous_names":["theshubhamp/fetadb"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/theshubhamp/fetadb","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/theshubhamp%2Ffetadb","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/theshubhamp%2Ffetadb/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/theshubhamp%2Ffetadb/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/theshubhamp%2Ffetadb/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/theshubhamp","download_url":"https://codeload.github.com/theshubhamp/fetadb/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/theshubhamp%2Ffetadb/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":271455599,"owners_count":24762753,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-08-21T02:00:08.990Z","response_time":74,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["database","databases","diy-project","kev-value","kv"],"created_at":"2024-09-24T20:45:38.165Z","updated_at":"2025-08-21T09:31:59.828Z","avatar_url":"https://github.com/theshubhamp.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"### FetaDB\nFetaDB is a Work-In-Progress SQL Database backed by a KV store (Badger). It talks the PostgreSQL Wire Protocol but doesn't promise drop-in compatibility.\n\nThis is a small attempt to learn database internals!\n\n### Overall Architecture\n```mermaid\ngraph TD;\n    client[Client: Anything that can speak PostgreSQL wire protocol]\n    handler[Protocol Handler]\n    pg_parser[Parser: PostgreSQL Parser]\n    ast_transform[Transformer: PostgreSQL Nodes to AST Nodes]\n    planner[Planner: AST Nodes to Planner Nodes]\n    execute[Execution: Planner Nodes evalauted bottom up to yield result]\n\n    client--\u003ehandler;\n    handler--\u003epg_parser;\n    pg_parser--\u003east_transform;\n    ast_transform--\u003eplanner;\n    planner--\u003eexecute\n```\n\n#### Supported Datatypes\nGolang primitive types are supported but not enforced: bool, string, unit*, int*, float*\n\n#### Supported Column Constraints\nPrimary Key and Not-Null\n\n#### Supported Features\n* In-Memory \u0026 Disk Mode. Add option `-dbpath memory` or `-dbpath path/to/dir`\n* Non Indexed Table Scan\n* Joins (Nested Loop)\n* Limited support for select, create table, insert into table. For example select does not support where filers\n* Operator dispatch, supported `=`, `+`, `-`, `*`, `/` and `||`\n* Functions dispatch, supported `lower`, `upper`, `md5`\n* Sort (In-Memory)\n* Group By, supported aggregations `sum`, `min`, `max`, `count`\n\n#### Unsupported Features (Current)\n* Non-trivial select, create, insert\n* Scan Filter, Index Scan Filter\n* Join (Hash \u0026 Merge)\n* Secondary Indexes\n* Type Checking on Insert\n\n### Getting Started\n#### Install PostgresSQL Client (MacOS)\n```shell\nbrew install libpq\n```\n\n#### Run\n```shell\ngo run fetadb\n```\n\n### Code Coverage\n```shell\ngo test ./...  -coverpkg=./... -coverprofile ./coverage.out\ngo tool cover -func ./coverage.out\n```\n\n### SQL Logic Test (included in go tests \u0026 coverage)\nSee [sqllogictest](https://www.sqlite.org/sqllogictest/doc/trunk/about.wiki)\n\nSqllogictest is a program designed to verify that an SQL database engine computes correct results by comparing the results to identical queries from other SQL database engines.\n\nSetup\n```shell\nrustup update stable\ncargo install sqllogictest-bin\n```\n\nTests are run via go automatically. Alternatively they can be run manually:\n```shell\nsqllogictest './test/**/*.slt'\n```\n\n### References\n- [MyRocks (Facebook's Storage Engine based on RocksDB) KV Encoding](https://github.com/facebook/mysql-5.6/wiki/MyRocks-record-format)\n- [CockroachDB KV Encoding (New)](https://github.com/cockroachdb/cockroach/blob/master/docs/tech-notes/encoding.md)\n- [CockroachDB KV Encoding (Old)](https://www.cockroachlabs.com/blog/sql-in-cockroachdb-mapping-table-data-to-key-value-storage/)\n- [PostgreSQL Frontend/Backend Protocol](https://www.postgresql.org/docs/current/protocol.html)\n\n### Connect via Client\n```shell\n# /usr/local/opt/libpq/bin/psql -h localhost\npsql (16.3, server 16.0)\nType \"help\" for help.\n\nmac=\u003e CREATE TABLE Departments(DepartmentID uint64 PRIMARY KEY, DepartmentName string NOT NULL);\n\nmac=\u003e CREATE TABLE Employees(EmployeeID uint64 PRIMARY KEY, FirstName string NOT NULL, LastName string NOT NULL, DepartmentID uint64, Salary float64);\n\nmac=\u003e INSERT INTO Departments (DepartmentID, DepartmentName) \n      VALUES (1, 'HR'), (2, 'IT'), (3, 'Finance'), (4, 'Marketing'), (5, 'Operations', 6, 'Research');\n      \nmac=\u003e INSERT INTO Employees (EmployeeID, FirstName, LastName, DepartmentID, Salary)\n      VALUES  (1, 'John', 'Doe', 1, 60000),\n              (2, 'Jane', 'Smith', 2, 75000),\n              (3, 'Mike', 'Johnson', 3, 65000),\n              (4, 'Emily', 'Brown', 2, 72000),\n              (5, 'David', 'Lee', 4, 68000),\n              (6, 'Sarah', 'Wilson', 1, 62000),\n              (7, 'Tom', 'Davis', NULL, 55000),\n              (8, 'Anna', 'Taylor', 3, 70000),\n              (9, 'Chris', 'Anderson', 5, 58000),\n              (10, 'Lisa', 'Thomas', NULL, 59000);\n\nmac=\u003e select Employees.EmployeeID, Employees.FirstName, Employees.LastName, Employees.DepartmentID, Employees.Salary \n      FROM Employees\n      ORDER BY Employees.departmentid DESC, Employees.salary ASC;\n employees.employeeid | employees.firstname | employees.lastname | employees.departmentid | employees.salary\n----------------------+---------------------+--------------------+------------------------+------------------\n 9                    | \"Chris\"             | \"Anderson\"         | 5                      | 58000\n 5                    | \"David\"             | \"Lee\"              | 4                      | 68000\n 3                    | \"Mike\"              | \"Johnson\"          | 3                      | 65000\n 8                    | \"Anna\"              | \"Taylor\"           | 3                      | 70000\n 4                    | \"Emily\"             | \"Brown\"            | 2                      | 72000\n 2                    | \"Jane\"              | \"Smith\"            | 2                      | 75000\n 1                    | \"John\"              | \"Doe\"              | 1                      | 60000\n 6                    | \"Sarah\"             | \"Wilson\"           | 1                      | 62000\n 7                    | \"Tom\"               | \"Davis\"            | null                   | 55000\n 10                   | \"Lisa\"              | \"Thomas\"           | null                   | 59000\n(10 rows)\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftheshubhamp%2Ffetadb","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftheshubhamp%2Ffetadb","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftheshubhamp%2Ffetadb/lists"}