MoonBit-native Delta Lake table-format kernel: transaction log replay, snapshots, time travel, scan planning and append writes.
Dependencies
生态里已经有 Parquet 编解码、DataFrame、对 Parquet 跑 SQL 的查询引擎、Iceberg 只读——缺的是"带事务日志的表"这一层。本项目补这一层。参赛申报书:申报书.md | 第三方声明:THIRD_PARTY_NOTICES.md已发布:mooncakes.io/docs/xiguaAp6y3/moondelta-core(moon add xiguaAp6y3/moondelta-core)
# 从 mooncakes.io 安装(v0.1.0 已发布)
moon add xiguaAp6y3/moondelta-core
# 或从源码构建
moon check --target native
moon test --target native
# CLI(源码根目录为 src/,因此包路径带 src/ 前缀)
moon run --target native src/cmd/delta -- inspect fixtures/delta/table_a
moon run --target native src/cmd/delta -- history fixtures/delta/table_a
moon run --target native src/cmd/delta -- scan fixtures/delta/table_a --where "id>=60"
moon run --target native src/cmd/delta -- read fixtures/delta/covid --limit 5table : fixtures/delta/table_a
current version : 12 (log versions: 13)
files : 120 rows: 120 bytes: 54232
protocol : reader=1 writer=1
format : parquet
partition columns: (none)
schema:
id: int
last checkpoint : version=10
note : checkpoint files exist; checkpoint-only tables are not readable by this kernellet table = @delta.DeltaTable::open("path/to/table")
let snapshot = table.snapshot() // 最新版本
let old = table.snapshot_at(1) // 时间旅行
let report = @delta.scan(snapshot, {
partitions: [("dt", "2026-10-18")],
predicate: Some({ column: "id", op: GeV, value: 60.0 }),
})
let rows = @delta.read_snapshot("path/to/table", snapshot, Some(100))
for c in rows.columns {
println(c.name + " : " + @delta.delta_type_name(c.type_))
}@delta.create_table(root, schema_json, [])
let columns : Array[@delta.ReadColumn] = [
{ name: "id", type_: Int64Type, cells: [CellI64(1L), CellI64(2L)] },
{ name: "name", type_: StringType, cells: [CellStr("a"), CellStr("b")] },
]
@delta.append_rows(root, columns, 1750000000000L) // 写 parquet + 提交新版本| 维度 | 支持 | 不支持 |
|---|---|---|
| schema | flat 原始类型 | 嵌套 struct / list / map |
| 压缩 | UNCOMPRESSED、SNAPPY | ZSTD、GZIP、BROTLI、LZ4 |
| 逻辑类型 | string、int、long、float、double、boolean、date、timestamp(INT96) | decimal、uuid 等(会丢语义) |
| 表 | 日志完整、可从头回放的本地表 | checkpoint-only / 日志被截断的表 |
| 写入类型 | Int32 / Int64 / String / Binary / Boolean / Double(Required/Optional) | Float / Timestamp / Repeated |
| 写入表 | 非分区表 | 分区表 append(MVP 明确拒绝) |
| 存储 | 本地文件系统 | 对象存储(S3/R2)、删除向量、列映射 |
moon check --target native
moon test --target native
moon fmtpub(all) enum Action {
ProtocolAction(Protocol)
MetaDataAction(TableInfo)
AddAction(AddFile)
RemoveAction(RemoveFile)
CommitInfoAction(CommitInfo)
UnknownAction(String)
} derive(Eq, Debug)pub(all) enum Cell {
CellI32(Int)
CellI64(Int64)
CellF32(Float)
CellF64(Double)
CellBool(Bool)
CellStr(String)
CellBin(Bytes)
CellTs(Int64)
CellNull
} derive(Debug)pub(all) struct DeltaTable {
root : String
}pub(all) struct ReadResult {
columns : Array[ReadColumn]
row_count : Int
files_read : Int
} derive(Debug)pub(all) struct ScanFilter {
partitions : Array[(String, String)]
predicate : ColumnPredicate?
} derive(Eq, Debug)pub(all) struct TableInfo {
id : String
name : String?
schema : DeltaSchema
partition_columns : Array[String]
format_provider : String
configuration : Array[(String, String)]
} derive(Eq, Debug)fn append_rows(root : String, columns : Array[ReadColumn], timestamp : Int64) -> Int raise DeltaErrorfn create_table(root : String, schema_json : String, partition_columns : Array[String]) -> Int raise DeltaErrorfn has_checkpoint_file(root : String) -> BoolInstall
Download zipMoonBit-native Delta Lake table-format kernel: transaction log replay, snapshots, time travel, scan planning and append writes.
Dependencies