Skip to content

Add WAL TypeSpec generation#568

Merged
adsharma merged 1 commit into
mainfrom
ladybug-wal-codegen
Jun 5, 2026
Merged

Add WAL TypeSpec generation#568
adsharma merged 1 commit into
mainfrom
ladybug-wal-codegen

Conversation

@adsharma

@adsharma adsharma commented Jun 5, 2026

Copy link
Copy Markdown
Contributor

Fixes: #404

Summary

  • add a TypeSpec/Jinja-based WAL record generation scaffold
  • add one TypeSpec declaration per WAL record plus shared generator templates
  • document ValueVector and manual-record handling

Manual Generation

  • AlterTableEntryRecord

    • src/include/storage/wal/record/alter_table_entry_record.h
    • src/storage/wal/records/alter_table_entry_record.cpp
  • CreateCatalogEntryRecord

    • src/include/storage/wal/record/create_catalog_entry_record.h
    • src/storage/wal/records/create_catalog_entry_record.cpp

Their polymorphic payload serialization is emitted from special branches in wal_record_header.h.j2 and wal_record_source.cpp.j2

Validation

  • make shell
  • wal_test and transaction_test

@adsharma adsharma force-pushed the ladybug-wal-codegen branch 3 times, most recently from f6c239f to 8874036 Compare June 5, 2026 02:33
@adsharma adsharma marked this pull request as ready for review June 5, 2026 02:34
@adsharma

adsharma commented Jun 5, 2026

Copy link
Copy Markdown
Contributor Author

For our WAL case, generalizing polymorphic payload serialization would take three pieces:

  1. Describe the variant payloads in TypeSpec:
  @discriminated(#{ discriminatorPropertyName: "alterType" })
  union AlterExtraInfo {
    addProperty: AddPropertyInfo,
    dropProperty: DropPropertyInfo,
    renameProperty: RenamePropertyInfo,
  }
  1. Teach generate_wal_typespec.py / templates how to map that union to C++:
  switch (alterInfo->alterType) {
  case AlterType::ADD_PROPERTY:
      ...
  }
  1. Add serialization policies for non-regular fields:
  • how to serialize variant tags as existing C++ enums, not strings
  • how to serialize payload fields that call custom methods, e.g. PropertyDefinition::serialize
  • how to deserialize into std::unique_ptr
  • how to map variants to concrete C++ classes like BoundExtraAddPropertyInfo

So TypeSpec can represent the shape, but it won’t automatically know Ladybug’s C++ factory/ownership conventions. The useful next step would be adding a small WAL-specific metadata layer for discriminated payloads rather than hardcoding AlterTableEntryRecord and CreateCatalogEntryRecord branches by record name.

@adsharma adsharma force-pushed the ladybug-wal-codegen branch 4 times, most recently from 3b2a1ad to 9bc1b58 Compare June 5, 2026 16:37
@adsharma adsharma force-pushed the ladybug-wal-codegen branch from 9bc1b58 to 5d2f343 Compare June 5, 2026 16:41
@adsharma adsharma merged commit bb2c605 into main Jun 5, 2026
4 checks passed
@adsharma adsharma deleted the ladybug-wal-codegen branch June 5, 2026 17:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

WAL: generate headers and source files from record definition

1 participant