@@ -41,8 +41,19 @@ function apply(p::Parallel, table)
41
41
tables = first .(vals)
42
42
caches = last .(vals)
43
43
44
- # table with concatenated columns
45
- newtable = tablehcat (tables)
44
+ # features and metadata
45
+ splits = divide .(tables)
46
+ feats = first .(splits)
47
+ metas = last .(splits)
48
+
49
+ # table with concatenated features
50
+ newfeat = tablehcat (feats)
51
+
52
+ # propagate metadata
53
+ newmeta = first (metas)
54
+
55
+ # attach new features and metatada
56
+ newtable = attach (newfeat, newmeta)
46
57
47
58
# find first revertible transform
48
59
ind = findfirst (isrevertible, p. transforms)
@@ -51,9 +62,9 @@ function apply(p::Parallel, table)
51
62
rinfo = if isnothing (ind)
52
63
nothing
53
64
else
54
- tcols = Tables. columns .(tables )
55
- tnames = Tables. columnnames .(tcols )
56
- ncols = length .(tnames )
65
+ fcols = Tables. columns .(feats )
66
+ fnames = Tables. columnnames .(fcols )
67
+ ncols = length .(fnames )
57
68
nrcols = ncols[ind]
58
69
start = sum (ncols[1 : ind- 1 ]) + 1
59
70
finish = start + nrcols - 1
@@ -71,24 +82,32 @@ function revert(p::Parallel, newtable, cache)
71
82
72
83
@assert ! isnothing (rinfo) " transform is not revertible"
73
84
85
+ # features and metadata
86
+ newfeat, newmeta = divide (newtable)
87
+
74
88
# retrieve info to revert transform
75
89
ind = rinfo[1 ]
76
90
range = rinfo[2 ]
77
91
rtrans = p. transforms[ind]
78
92
rcache = caches[ind]
79
93
80
94
# columns of transformed table
81
- cols = Tables. columns (newtable )
82
- names = Tables. columnnames (cols )
95
+ fcols = Tables. columns (newfeat )
96
+ names = Tables. columnnames (fcols )
83
97
84
98
# retrieve subtable to revert
85
- rcols = [Tables. getcolumn (cols, j) for j in range]
86
99
rnames = names[range]
87
- 𝒯 = (; zip (rnames, rcols) ... )
88
- rtable = 𝒯 |> Tables. materializer (newtable )
100
+ rcols = [Tables . getcolumn (fcols, j) for j in range]
101
+ rfeat = (; zip (rnames, rcols) ... ) |> Tables. materializer (newfeat )
89
102
90
103
# revert transform on subtable
91
- revert (rtrans, rtable, rcache)
104
+ feat = revert (rtrans, rfeat, rcache)
105
+
106
+ # propagate metadata
107
+ meta = newmeta
108
+
109
+ # attach features and metadata
110
+ attach (feat, meta)
92
111
end
93
112
94
113
function reapply (p:: Parallel , table, cache)
@@ -100,8 +119,19 @@ function reapply(p::Parallel, table, cache)
100
119
itr = zip (p. transforms, caches)
101
120
tables = tcollect (f (t, c) for (t, c) in itr)
102
121
103
- # table with concatenated columns
104
- tablehcat (tables)
122
+ # features and metadata
123
+ splits = divide .(tables)
124
+ feats = first .(splits)
125
+ metas = last .(splits)
126
+
127
+ # table with concatenated features
128
+ newfeat = tablehcat (feats)
129
+
130
+ # metadata of the first table
131
+ newmeta = first (metas)
132
+
133
+ # attach new features and metatada
134
+ attach (newfeat, newmeta)
105
135
end
106
136
107
137
function tablehcat (tables)
0 commit comments