Skip to content

Repository files navigation

MatrixOne Git4Data Tutorial

Runnable companion code for the MatrixOne Git4Data Deep Dive article series — Git-style version control for data at scale (commit, branch, diff, merge, cherry-pick, time travel), built into MatrixOne.

What is Git4Data? If you treat a database as a Git repository and a table as a file in it, MatrixOne lets you run everyday Git operations — snapshot, clone, branch, diff, merge, cherry-pick, restore — over terabytes of data, almost instantly. It's the same workflow software engineers use on code, now on data.

The series

PartThemeTopicArticleCode
1ConceptThe Git moment for data at scaleBlog ↗
2ConceptHands on: every Git primitive, from zeroBlog ↗02-hands-on/
3ConceptUnder the hood: why snapshot/diff/merge are this fastBlog ↗
4ConceptThe data-versioning landscape: git4data vs lakeFS / Dolt / SnowflakeBlog ↗
5Data OpsIncident rescue: snapshot / DIFF investigation / PITRArticle05-incident-rescue/
6Data OpsCollaborative development: one branch per engineerArticle06-collaborative-dev/
7Data OpsWrite-Audit-Publish: a release gate for dataArticle07-write-audit-publish/
8AI TrainingML continuous learning: train only the deltaArticle08-ml-incremental/
9AI TrainingSFT curation: clean in place, with receiptsArticle09-sft-curation/
10AI TrainingCollaborative labeling: disagreement IS the conflictArticle10-labeling-collab/
11AI TrainingRLHF preference data: consensus, re-judging, reproducibilityArticle11-rlhf-preference/
12AI TrainingMultimodal × lakeFS: bytes there, catalog hereArticle12-multimodal-lakefs/
13AgentsAgent memory: versioned, branchable, rewindableArticle13-agent-memory/
14AgentsAgent traces: queryable, joinable, versionedArticle14-agent-trace/
15AgentsAgent self-evolution (finale): branch / evaluate / merge / roll backArticle15-agent-evolution/

Concept parts (1–4) link out to the published blog. Each practice part (5–15) ships its full article in-folder — article_en.md / article_zh.md — right next to the runnable SQL.

Quick start (5 minutes)

# 1. Run a local MatrixOne (open source, MySQL-compatible)
docker run -d -p 6001:6001 --name matrixone matrixorigin/matrixone:4.0.0-rc3
# 2. Run the Part 2 walkthrough — every Git primitive on 1,000,000 rows
mysql -h 127.0.0.1 -P 6001 -u root -p111 < 02-hands-on/git4data_primitives.sql

Default credentials: user root, password 111, port 6001.

What Part 2 covers

02-hands-on/git4data_primitives.sql is a single, copy-paste-runnable script (English comments) that walks through:

  • commit / tag / resetCREATE SNAPSHOT, time-travel SELECT … {snapshot=…}, RESTORE
  • clone — zero-copy CREATE TABLE … CLONE
  • branch — lineage-tracked DATA BRANCH CREATE
  • diff — row-level DATA BRANCH DIFF … OUTPUT SUMMARY / COUNT / LIMIT / FILE
  • merge — three-way DATA BRANCH MERGE … WHEN CONFLICT FAIL | SKIP | ACCEPT
  • cherry-pickDATA BRANCH PICK … KEYS(…)
  • point-in-time recoveryCREATE PITR + RESTORE … FROM PITR "…"
  • granularity — the same semantics at table / database / account / cluster levels
  • scale — measured numbers showing snapshot/clone/branch cost is independent of table size

It loads a million rows with a single generate_series statement (no external files needed) and cleans up after itself.

Measured: cost is independent of data size

Same table, same operations, on a single-node Docker MatrixOne (diff/merge each touch only 1,000 rows):

Steady-state, median of several runs (MatrixOne 4.0.0-rc3):

table sizeloadCREATE SNAPSHOTCLONEDATA BRANCH CREATEDIFF (1000)MERGE (1000)
1,000,0000.5 s6 ms6 ms7 ms13 ms64 ms
10,000,0005.3 s8 ms8 ms7 ms21 ms178 ms
100,000,00041 s5 ms25 ms19 ms23 ms189 ms

Snapshot is dead constant (it just names a metadata directory). Clone/branch copy the metadata directory, not the data — 100× the data, clone rises only 6 ms → 25 ms. Diff/merge scale with how many rows changed, not table size. (The first snapshot of a freshly loaded table is ~10–12 ms — a one-time flush of in-memory data — then drops to the steady-state numbers above.)

Links

License

Apache 2.0

About

Runnable companion code & SQL for the MatrixOne Git4Data tutorial series — Git-style version control for data at scale.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages