Skip to content

World's most powerful open data catalog for building a high-performance, geo-distributed and federated metadata lake.

[#11] rfc: propose the metadata schema spec for Unified Catalog (#14)

Saisai Shao893d3ab8e7e9
diff --git a/rfc/rfc-1/rfc-1.md b/rfc/rfc-1/rfc-1.md
new file mode 100644
index 0000000000..fff705f3d3
--- /dev/null
+++ b/rfc/rfc-1/rfc-1.md
@@ -0,0 +1,144 @@
+# RFC-1: Metadata Spec Design
+
+| Revision | Owner |
+| :------- | ---------- |
+| v0.1 | Jerry Shao |
+
+## Design Prerequisites
+
+1. The metadata spec should be evolved, backward compatible, and possibly forward compatible (If possible and necessary).
+2. The on-wire protocol (user-faced interface) should be readable and debuggable by mainstream web-based tools.
+3. The storage layout should be concise and performant, also be backward compatible.
+4. The type and schema system should be generic enough to cover mainstream db/dws/dl’s schema system.
+5. The schema can be evolved to support non-table datasets (stream, model).
+6. The schema should be evolved to support Hive’s schema spec, so we could replace HMS later on.
+
+## Design choices
+
+1. We choose to leverage Substrait’s type system into our entities’ type system. The main considerations are here:
+ 1. The goal of Substrait is to build a generic intermediate layer, its type system is relatively complete.
+ 2. We will further use Substrait to represent our logical plans (for example, like view, function and others), so using Substrait’s type system will reduce some converting works later on.
+2. We choose JSON protocol as our user-faced protocol, which is easy to debug for users and systems.
+3. We choose Protobuf binary layout to store the schema, the main considerations are here:
+ 1. Binary layout is much more concise compared to HMS’s schema layout.
+ 2. A general-purpose NoSQL database can be used to store the schema, which will get better performance and scalability compared to Hive Metastore.
+
+## Type System
+
+We use Substrait’s type system to define our schema’s type, the advantages of using Substrait’s type system is that:
+
+1. Substrait’s type system is generic enough to cover major type kinds of DWS, DBS, and other type system.
+2. Substrait supports extending the type systems to user-defined types.
+3. Substrait support serializing and deserializing using Google protobuf.
+
+Disadvantages:
+
+1. Substrait is still in fast iteration, the spec is not fully defined yet, also the project is not mature enough. So we potentially have the risk of breaking backward compatibility.
+2. Also Substrait lacks best practices, the learning curve is relatively high.
+
+Substrait’s type system can be referred here https://substrait.io/types/type_system/.
+
+## Schema System
+
+### Prerequisites
+
+1. The field name of schema should use lowercase with "_" connecting different words, the name convention is `^[a-z](?:_?[a-z0-9]+)*$`.
+1. The schema system uses Google Protobuf to describe the structs.
+
+### Schema Entities
+
+#### SchemaVersion
+
+| Field Name | Field Type | Description | Optional |
+| ------------- | ---------- | ------------------------------------------------------------ | -------- |
+| major_version | uint32 | The major version of the schema system. Backward compatibility is guaranteed within the major version and is best-effort guaranteed between versions. | Required |
+| minor_version | uint32 | The minor version of the schema system. Backward compatibility is guaranteed between versions | Required |
+
+#### AuditInfo
+
+| Field Name | Field Type | Description | Optional |
+| ------------------ | ---------- | ------------------------------------------------------------ | -------- |
+| creator | string | The name of user who creates the schema entity | Required |
+| create_time | timestamp | Google Protobuf timestamp type to represent when entity is created | Required |
+| last_modifier | string | The name of user who modified the schema entity last time | Optional |
+| last_modified_time | timestamp | Google Protobuf timestamp type to represent when entity is modified | Optional |
+| last_access_user | string | The name of user who acecess the schema entity last time | Optional |
+| last_access_time | timestamp | Google Protobuf timestamp type to represent when entity is accessed | Optional |
+
+#### Tenant
+
+| Field Name | Field Type | Description | Optional |
+| ---------- | ------------- | ------------------------------------------------------------ | -------- |
+| id | uint32 | The unique identifier of the tenant, this is generated by the system | Required |
+| name | string | The name of the tenant | Required |
+| comment | string | The comment of the tenant | Optional |
+| audit_info | AuditInfo | The audit info of the tenant | Required |
+| version | SchemaVersion | The version info of the tenant | Required |
+
+#### Lakehouse
+
+| Field Name | Field Type | Description | Optional |
+| ---------- | ------------------- | ------------------------------------------------------------ | -------- |
+| id | uint64 | The unique identifier of the lakehouse, this is generated by the system | Required |
+| name | string | The name of the lakehouse | Required |
+| comment | string | The comment of the lakehouse | Optional |
+| properties | map<string, string> | The properties of the lakehouse | Optional |
+| audit_info | AuditInfo | The detailed audit info of lakehouse | Required |
+
+#### Zone
+
+| Field Name | Field Type | Description | Optional |
+| ------------ | ------------------- | ------------------------------------------------------------ | -------- |
+| id | uint64 | The unique identifier of the zone, this is generated by the system | Required |
+| lakehouse_id | uint64 | The unique identifier of the lakehouse which includes this zone | Required |
+| name | string | The name of the zone | Required |
+| comment | string | The comment of the Zone | Required |
+| properties | map<string, string> | The properties of the zone | Optional |
+| audit_info | AuditInfo | The audit info of the zone | Required |
+
+#### Entity
+
+##### Column
+
+| Field Name | Field Type | Description | Optional |
+| ------------------ | -------------- | ------------------------------------------------------------ | -------- |
+| id | uint32 | The unique identifier of the column | Required |
+| entity_id | uint64 | The unique identifier of the parent entity which this column belongs to | Required |
+| entity_snapshot_id | uint64 | The snapshot id of the parent entity which this column belongs to | Required |
+| name | string | The name of the column | Required |
+| type | Substrait Type | The type of the column | Required |
+| comment | string | The comment of the column | Optional |
+| position | uint32 | The position of the column | Required |
+| audit_info | AuditInfo | The audit info of the zone | Required |
+
+Note. The `type` field serialization and deserialization need to follow Substrait's way.
+
+##### Table
+
+**ExtraInfo - VirtualTableInfo**
+
+| Field Name | Field Type | Description | Optional |
+| ------------------- | --------------- | --------------------------------------- | -------- |
+| connection_id (TBD) | uint32 | The unique identifier of the connection | Required |
+| identifier | repeated string | The identifier of the physical table | Required |
+
+**ExtraInfo - ViewTableInfo**
+
+**ExtraInfo - ExternalTableInfo**
+
+**ExtraInfo - ManagedTableInfo**
+
+
+
+| Field Name | Field Type | Description | Optional |
+| ----------- | ------------------- | ------------------------------------------------------------ | -------- |
+| id | uint64 | The unique identifier of the table | Required |
+| zone_id | uint64 | The unique identifier of the zone which this table belongs to | Required |
+| name | string | The name of the table | Required |
+| comment | string | The comment of the table | Optional |
+| type | TableType enum | The type of table | Required |
+| snapshot_id | uint64 | The snapshot id of the table | Required |
+| properties | map<string, string> | The properties of the table | Optional |
+| audit_info | AuditInfo | The audit info of the table | Required |
+| extra_info | oneof ExtraInfo | The extra info of the table | Required |
+