@@ -26,7 +26,7 @@ type Transform func(table *Table) error
2626
2727type Tables []* Table
2828
29- // This is deprecated
29+ // Deprecated: SyncSummary is deprecated.
3030type SyncSummary struct {
3131 Resources uint64
3232 Errors uint64
9494 reValidColumnName = regexp .MustCompile (`^[a-z_][a-z\d_]*$` )
9595)
9696
97- // AddCqIds adds the cq_id and cq_parent_id columns to the table and all its relations
97+ // AddCqIDs adds the cq_id and cq_parent_id columns to the table and all its relations
9898// set cq_id as primary key if no other primary keys
9999func AddCqIDs (table * Table ) {
100100 havePks := len (table .PrimaryKeys ()) > 0
@@ -126,9 +126,9 @@ func NewTablesFromArrowSchemas(schemas []*arrow.Schema) (Tables, error) {
126126 return tables , nil
127127}
128128
129- // Create a CloudQuery Table abstraction from an arrow schema
130- // arrow schema is a low level representation of a table that can be sent
131- // over the wire in a cross-language way
129+ // NewTableFromArrowSchema creates a CloudQuery Table abstraction from an Arrow schema.
130+ // The Arrow schema is a low level representation of a table that can be sent
131+ // over the wire in a cross-language way.
132132func NewTableFromArrowSchema (sc * arrow.Schema ) (* Table , error ) {
133133 tableMD := sc .Metadata ()
134134 name , found := tableMD .GetValue (MetadataTableName )
@@ -137,6 +137,12 @@ func NewTableFromArrowSchema(sc *arrow.Schema) (*Table, error) {
137137 }
138138 description , _ := tableMD .GetValue (MetadataTableDescription )
139139 constraintName , _ := tableMD .GetValue (MetadataConstraintName )
140+ title , _ := tableMD .GetValue (MetadataTableTitle )
141+ dependsOn , _ := tableMD .GetValue (MetadataTableDependsOn )
142+ var parent * Table
143+ if dependsOn != "" {
144+ parent = & Table {Name : dependsOn }
145+ }
140146 fields := sc .Fields ()
141147 columns := make (ColumnList , len (fields ))
142148 for i , field := range fields {
@@ -147,6 +153,8 @@ func NewTableFromArrowSchema(sc *arrow.Schema) (*Table, error) {
147153 Description : description ,
148154 PkConstraintName : constraintName ,
149155 Columns : columns ,
156+ Title : title ,
157+ Parent : parent ,
150158 }
151159 if isIncremental , found := tableMD .GetValue (MetadataIncremental ); found {
152160 table .IsIncremental = isIncremental == MetadataTrue
@@ -391,20 +399,23 @@ func (t *Table) ToArrowSchema() *arrow.Schema {
391399 md := map [string ]string {
392400 MetadataTableName : t .Name ,
393401 MetadataTableDescription : t .Description ,
402+ MetadataTableTitle : t .Title ,
394403 MetadataConstraintName : t .PkConstraintName ,
395- MetadataIncremental : MetadataFalse ,
396404 }
397405 if t .IsIncremental {
398406 md [MetadataIncremental ] = MetadataTrue
399407 }
408+ if t .Parent != nil {
409+ md [MetadataTableDependsOn ] = t .Parent .Name
410+ }
400411 schemaMd := arrow .MetadataFrom (md )
401412 for i , c := range t .Columns {
402413 fields [i ] = c .ToArrowField ()
403414 }
404415 return arrow .NewSchema (fields , & schemaMd )
405416}
406417
407- // Get Changes returns changes between two tables when t is the new one and old is the old one.
418+ // GetChanges returns changes between two tables when t is the new one and old is the old one.
408419func (t * Table ) GetChanges (old * Table ) []TableColumnChange {
409420 var changes []TableColumnChange
410421 for _ , c := range t .Columns {
@@ -475,6 +486,7 @@ func (t *Table) Column(name string) *Column {
475486 return nil
476487}
477488
489+ // OverwriteOrAddColumn overwrites or adds columns.
478490// If the column with the same name exists, overwrites it.
479491// Otherwise, adds the column to the beginning of the table.
480492func (t * Table ) OverwriteOrAddColumn (column * Column ) {
0 commit comments