@@ -70,6 +70,17 @@ const (
7070 dontReadNonlocalTables readNonlocalTablesFlag = false
7171)
7272
73+ // TableIntegrator provides a hook for extensions to customize or wrap table implementations. This allows libraries like
74+ // Doltgres to intercept system table creation and apply type conversions, schema modifications, or other customizations
75+ // without modifying the core Dolt implementation.
76+ type TableIntegrator interface {
77+ // CreateTable creates or wraps a system table. The factory receives all necessary parameters to construct the table
78+ // and can either build it from scratch or call the default constructor and wrap it.
79+ CreateTable (ctx * sql.Context , tableName string , ddb * doltdb.DoltDB , ws * doltdb.WorkingSet , rp env.RootsProvider [* sql.Context ]) sql.Table
80+ }
81+
82+ var TableIntegrators map [string ]TableIntegrator
83+
7384// Database implements sql.Database for a dolt DB.
7485type Database struct {
7586 rsr env.RepoStateReader [* sql.Context ]
@@ -804,7 +815,11 @@ func (db Database) getTableInsensitiveWithRoot(ctx *sql.Context, head *doltdb.Co
804815 }
805816 }
806817
807- dt , found = dtables .NewStatusTable (ctx , lwrName , db .ddb , ws , rootsProvider ), true
818+ if systemTableFactory , ok := TableIntegrators [lwrName ]; ok {
819+ dt , found = systemTableFactory .CreateTable (ctx , lwrName , db .ddb , ws , rootsProvider ), true
820+ } else {
821+ dt , found = dtables .NewStatusTable (ctx , lwrName , db .ddb , ws , rootsProvider ), true
822+ }
808823 }
809824 case doltdb .MergeStatusTableName , doltdb .GetMergeStatusTableName ():
810825 isDoltgresSystemTable , err := resolve .IsDoltgresSystemTable (ctx , tname , root )
0 commit comments