Skip to content

Commit c669c06

Browse files
committed
working on kdocs, empty groups are now removed in new except functions
1 parent ee69a5d commit c669c06

File tree

17 files changed

+320
-149
lines changed

17 files changed

+320
-149
lines changed

core/generated-sources/src/main/kotlin/org/jetbrains/kotlinx/dataframe/api/ColumnsSelectionDsl.kt

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -195,6 +195,10 @@ public interface ColumnsSelectionDsl<out T> : /* SingleColumn<DataRow<T>> */
195195
*
196196
* &nbsp;&nbsp;&nbsp;&nbsp;
197197
*
198+
* `colsSelector: `[ColumnsSelector][org.jetbrains.kotlinx.dataframe.ColumnsSelector]
199+
*
200+
* &nbsp;&nbsp;&nbsp;&nbsp;
201+
*
198202
* `number: `[Int][Int]
199203
*
200204
* &nbsp;&nbsp;&nbsp;&nbsp;
@@ -454,9 +458,9 @@ public interface ColumnsSelectionDsl<out T> : /* SingleColumn<DataRow<T>> */
454458
*
455459
* &nbsp;&nbsp;&nbsp;&nbsp;`|` .[**and**][org.jetbrains.kotlinx.dataframe.api.AndColumnsSelectionDsl.and] **`(`**`|`**`{ `**[columnOrSet][org.jetbrains.kotlinx.dataframe.documentation.UsageTemplateColumnsSelectionDsl.UsageTemplate.ColumnOrColumnSetDef]**` }`**`|`**`)`**
456460
*
457-
* &nbsp;&nbsp;&nbsp;&nbsp;`|`.[**select**][org.jetbrains.kotlinx.dataframe.api.SelectColumnsSelectionDsl.select]**` {`** [colSelector][org.jetbrains.kotlinx.dataframe.documentation.UsageTemplateColumnsSelectionDsl.UsageTemplate.ColumnSelectorDef] **`}`**
461+
* &nbsp;&nbsp;&nbsp;&nbsp;`|`.[**select**][org.jetbrains.kotlinx.dataframe.api.SelectColumnsSelectionDsl.select]**` {`** [colsSelector][org.jetbrains.kotlinx.dataframe.documentation.UsageTemplateColumnsSelectionDsl.UsageTemplate.ColumnsSelectorDef] **`}`**
458462
*
459-
* &nbsp;&nbsp;&nbsp;&nbsp;`|`[**` {`**][ColumnsSelectionDsl.select] [colSelector][org.jetbrains.kotlinx.dataframe.documentation.UsageTemplateColumnsSelectionDsl.UsageTemplate.ColumnSelectorDef] [**`}`**][ColumnsSelectionDsl.select]
463+
* &nbsp;&nbsp;&nbsp;&nbsp;`|`[**` {`**][ColumnsSelectionDsl.select] [colsSelector][org.jetbrains.kotlinx.dataframe.documentation.UsageTemplateColumnsSelectionDsl.UsageTemplate.ColumnsSelectorDef] [**`}`**][ColumnsSelectionDsl.select]
460464
*
461465
*
462466
* &nbsp;&nbsp;&nbsp;&nbsp;

core/generated-sources/src/main/kotlin/org/jetbrains/kotlinx/dataframe/api/allExcept.kt

Lines changed: 95 additions & 63 deletions
Original file line numberDiff line numberDiff line change
@@ -2,32 +2,34 @@ package org.jetbrains.kotlinx.dataframe.api
22

33
import org.jetbrains.kotlinx.dataframe.ColumnsSelector
44
import org.jetbrains.kotlinx.dataframe.DataRow
5+
import org.jetbrains.kotlinx.dataframe.api.AllExceptColumnsSelectionDsl.Usage.PlainDslName
56
import org.jetbrains.kotlinx.dataframe.columns.ColumnPath
67
import org.jetbrains.kotlinx.dataframe.columns.ColumnSet
7-
import org.jetbrains.kotlinx.dataframe.columns.ColumnWithPath
88
import org.jetbrains.kotlinx.dataframe.columns.ColumnsResolver
99
import org.jetbrains.kotlinx.dataframe.columns.SingleColumn
1010
import org.jetbrains.kotlinx.dataframe.columns.toColumnSet
1111
import org.jetbrains.kotlinx.dataframe.documentation.LineBreak
1212
import org.jetbrains.kotlinx.dataframe.documentation.UsageTemplateColumnsSelectionDsl.UsageTemplate
1313
import org.jetbrains.kotlinx.dataframe.impl.aggregation.toColumns
14-
import org.jetbrains.kotlinx.dataframe.impl.columns.allColumnsExceptAndUnpack
1514
import org.jetbrains.kotlinx.dataframe.impl.columns.allColumnsExceptKeepingStructure
16-
import org.jetbrains.kotlinx.dataframe.impl.columns.changePath
1715
import org.jetbrains.kotlinx.dataframe.impl.columns.createColumnSet
18-
import org.jetbrains.kotlinx.dataframe.impl.columns.transformSingle
1916
import org.jetbrains.kotlinx.dataframe.util.ALL_COLS_EXCEPT
2017
import org.jetbrains.kotlinx.dataframe.util.ALL_COLS_REPLACE
2118
import org.jetbrains.kotlinx.dataframe.util.ALL_COLS_REPLACE_VARARG
19+
import org.jetbrains.kotlinx.dataframe.util.COL_SELECT_DSL_EXCEPT
20+
import org.jetbrains.kotlinx.dataframe.util.COL_SELECT_DSL_EXCEPT_REPLACE_RESOLVER
21+
import org.jetbrains.kotlinx.dataframe.util.COL_SELECT_DSL_EXCEPT_REPLACE_SELECTOR
22+
import org.jetbrains.kotlinx.dataframe.util.COL_SELECT_DSL_SINGLE_COL_EXCEPT
23+
import org.jetbrains.kotlinx.dataframe.util.COL_SELECT_DSL_SINGLE_COL_EXCEPT_REPLACE_OTHERS
24+
import org.jetbrains.kotlinx.dataframe.util.COL_SELECT_DSL_SINGLE_COL_EXCEPT_REPLACE_RESOLVER
25+
import org.jetbrains.kotlinx.dataframe.util.COL_SELECT_DSL_SINGLE_COL_EXCEPT_REPLACE_SELECTOR
2226
import kotlin.experimental.ExperimentalTypeInference
2327
import kotlin.reflect.KProperty
2428

2529
// region ColumnsSelectionDsl
2630

2731
public interface AllExceptColumnsSelectionDsl<out T> {
2832

29-
// region except
30-
3133
/**
3234
* ## All (Except) Usage
3335
*
@@ -47,6 +49,17 @@ public interface AllExceptColumnsSelectionDsl<out T> {
4749
* &nbsp;&nbsp;&nbsp;&nbsp;
4850
*
4951
* `condition: `[ColumnFilter][org.jetbrains.kotlinx.dataframe.ColumnFilter]
52+
*
53+
* &nbsp;&nbsp;&nbsp;&nbsp;
54+
*
55+
* `colsSelector: `[ColumnsSelector][org.jetbrains.kotlinx.dataframe.ColumnsSelector]
56+
*
57+
* &nbsp;&nbsp;&nbsp;&nbsp;
58+
*
59+
* `column: `[ColumnAccessor][org.jetbrains.kotlinx.dataframe.columns.ColumnAccessor]` | `[String][String]
60+
*
61+
* &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
62+
* `| `[KProperty][kotlin.reflect.KProperty]`<*> | `[ColumnPath][org.jetbrains.kotlinx.dataframe.columns.ColumnPath]
5063
*
5164
* &nbsp;&nbsp;&nbsp;&nbsp;
5265
*
@@ -55,7 +68,9 @@ public interface AllExceptColumnsSelectionDsl<out T> {
5568
*
5669
* &nbsp;&nbsp;&nbsp;&nbsp;
5770
*
58-
*
71+
* [**allExcept**][org.jetbrains.kotlinx.dataframe.api.ColumnsSelectionDsl.allExcept] **`{ `**[colsSelector][org.jetbrains.kotlinx.dataframe.documentation.UsageTemplateColumnsSelectionDsl.UsageTemplate.ColumnsSelectorDef]**` }`**
72+
*
73+
* `|` [**allExcept**][org.jetbrains.kotlinx.dataframe.api.ColumnsSelectionDsl.allExcept]**`(`**[column][org.jetbrains.kotlinx.dataframe.documentation.UsageTemplateColumnsSelectionDsl.UsageTemplate.ColumnDef]**`, ..)`**
5974
*
6075
* &nbsp;&nbsp;&nbsp;&nbsp;
6176
*
@@ -87,87 +102,102 @@ public interface AllExceptColumnsSelectionDsl<out T> {
87102
*
88103
*
89104
*
105+
*
106+
* TODO
107+
*
108+
*
90109
*/
91-
public interface Usage
110+
public interface Usage {
92111

93-
// /** TODO tbd */
94-
// @Suppress("UNCHECKED_CAST")
95-
// public fun <C> ColumnSet<C>.colsExcept(predicate: ColumnFilter<C>): TransformableColumnSet<C> =
96-
// colsInternal { !predicate(it as ColumnWithPath<C>) } as TransformableColumnSet<C>
97-
//
98-
// /** TODO tbd */
99-
// public fun SingleColumn<DataRow<*>>.colsExcept(predicate: ColumnFilter<*>): TransformableColumnSet<*> =
100-
// colsInternal { !predicate(it) }
112+
/** [**allExcept**][ColumnsSelectionDsl.allExcept] */
113+
public interface PlainDslName
101114

102-
// TODO Same as select and cols but then inverted
115+
/** [**except**][ColumnsSelectionDsl.except] */
116+
public interface ColumnSetName
103117

104-
// region deprecated and experiments
118+
/** [**allColsExcept**][ColumnsSelectionDsl.allColsExcept] */
119+
public interface ColumnGroupName
120+
}
105121

106-
// public operator fun ColumnReference<*>.not(): ColumnSet<Any?> =
107-
// with(this@AllExceptColumnsSelectionDsl as ColumnsSelectionDsl<T>) {
108-
// allExcept(this@not)
109-
// }
110-
//
111-
// public operator fun ColumnSet<*>.not(): ColumnSet<Any?> =
112-
// with(this@AllExceptColumnsSelectionDsl as ColumnsSelectionDsl<T>) {
113-
// allExcept(this@not)
114-
// }
115-
116-
public infix fun <C> ColumnSet<C>.oldExcept(other: ColumnsResolver<*>): ColumnSet<C> =
117-
createColumnSet { context ->
118-
val resolvedCols = this@oldExcept.resolve(context)
119-
val resolvedColsToExcept = other.resolve(context)
120-
resolvedCols.allColumnsExceptAndUnpack(resolvedColsToExcept)
121-
} as ColumnSet<C>
122-
123-
public infix fun <C> SingleColumn<DataRow<C>>.exceptNew(selector: ColumnsSelector<C, *>): SingleColumn<DataRow<*>> =
124-
this.ensureIsColumnGroup().transformSingle { singleCol ->
125-
126-
val columnsToExcept = singleCol.asColumnGroup().getColumnsWithPaths(selector)
127-
.map { it.changePath(singleCol.path + it.path) }
128-
129-
val newCols = listOf(singleCol).allColumnsExceptKeepingStructure(columnsToExcept)
130-
131-
newCols as List<ColumnWithPath<DataRow<*>>>
132-
}.singleInternal()
122+
// region deprecated and experiments
133123

134-
@Deprecated("Use allColsExcept instead", ReplaceWith("this.allColsExcept(selector)"))
124+
@Deprecated(
125+
message = COL_SELECT_DSL_SINGLE_COL_EXCEPT,
126+
replaceWith = ReplaceWith(COL_SELECT_DSL_SINGLE_COL_EXCEPT_REPLACE_SELECTOR),
127+
level = DeprecationLevel.WARNING,
128+
)
135129
public fun <C> SingleColumn<DataRow<C>>.except(selector: ColumnsSelector<C, *>): ColumnSet<*> =
136130
allColsExcept(selector)
137131

138-
@Deprecated("Use allColsExcept instead", ReplaceWith("this.allColsExcept { others.toColumnSet() } "))
132+
@Deprecated(
133+
message = COL_SELECT_DSL_SINGLE_COL_EXCEPT,
134+
replaceWith = ReplaceWith(COL_SELECT_DSL_SINGLE_COL_EXCEPT_REPLACE_RESOLVER),
135+
level = DeprecationLevel.WARNING,
136+
)
139137
public fun SingleColumn<DataRow<*>>.except(vararg others: ColumnsResolver<*>): ColumnSet<*> =
140138
allColsExcept { others.toColumnSet() }
141139

142-
@Deprecated("Use allColsExcept instead", ReplaceWith("this.allColsExcept(others)"))
140+
@Deprecated(
141+
message = COL_SELECT_DSL_SINGLE_COL_EXCEPT,
142+
replaceWith = ReplaceWith(COL_SELECT_DSL_SINGLE_COL_EXCEPT_REPLACE_OTHERS),
143+
level = DeprecationLevel.WARNING,
144+
)
143145
public fun SingleColumn<DataRow<*>>.except(vararg others: String): ColumnSet<*> =
144146
allColsExcept(*others)
145147

146-
@Deprecated("Use allColsExcept instead", ReplaceWith("this.allColsExcept(others)"))
148+
@Deprecated(
149+
message = COL_SELECT_DSL_SINGLE_COL_EXCEPT,
150+
replaceWith = ReplaceWith(COL_SELECT_DSL_SINGLE_COL_EXCEPT_REPLACE_OTHERS),
151+
level = DeprecationLevel.WARNING,
152+
)
147153
public fun SingleColumn<DataRow<*>>.except(vararg others: KProperty<*>): ColumnSet<*> =
148154
allColsExcept(*others)
149155

150-
@Deprecated("Use allColsExcept instead", ReplaceWith("this.allColsExcept(others)"))
156+
@Deprecated(
157+
message = COL_SELECT_DSL_SINGLE_COL_EXCEPT,
158+
replaceWith = ReplaceWith(COL_SELECT_DSL_SINGLE_COL_EXCEPT_REPLACE_OTHERS),
159+
level = DeprecationLevel.WARNING,
160+
)
151161
public fun SingleColumn<DataRow<*>>.except(vararg others: ColumnPath): ColumnSet<*> =
152162
allColsExcept(*others)
153163

154-
@Deprecated("Use allExcept instead", ReplaceWith("this.allExcept(others)"))
164+
@Deprecated(
165+
message = COL_SELECT_DSL_EXCEPT,
166+
replaceWith = ReplaceWith(COL_SELECT_DSL_EXCEPT_REPLACE_SELECTOR),
167+
level = DeprecationLevel.WARNING,
168+
)
155169
public fun <C> ColumnsSelectionDsl<C>.except(selector: ColumnsSelector<C, *>): ColumnSet<*> =
156170
allExcept(selector)
157171

158-
@Deprecated("Use allExcept instead", ReplaceWith("this.allExcept(others"))
172+
@Deprecated(
173+
message = COL_SELECT_DSL_EXCEPT,
174+
replaceWith = ReplaceWith(COL_SELECT_DSL_EXCEPT_REPLACE_RESOLVER),
175+
level = DeprecationLevel.WARNING,
176+
)
159177
public fun ColumnsSelectionDsl<*>.except(vararg others: ColumnsResolver<*>): ColumnSet<*> =
160178
allExcept(*others)
161179

162-
@Deprecated("Use allExcept instead", ReplaceWith("this.allExcept(others)"))
180+
@Deprecated(
181+
message = COL_SELECT_DSL_EXCEPT,
182+
replaceWith = ReplaceWith(COL_SELECT_DSL_EXCEPT_REPLACE_RESOLVER),
183+
level = DeprecationLevel.WARNING,
184+
)
163185
public fun ColumnsSelectionDsl<*>.except(vararg others: String): ColumnSet<*> =
164186
allExcept(*others)
165187

166-
@Deprecated("Use allExcept instead", ReplaceWith("this.allExcept(others)"))
188+
@Deprecated(
189+
message = COL_SELECT_DSL_EXCEPT,
190+
replaceWith = ReplaceWith(COL_SELECT_DSL_EXCEPT_REPLACE_RESOLVER),
191+
level = DeprecationLevel.WARNING,
192+
)
167193
public fun ColumnsSelectionDsl<*>.except(vararg others: KProperty<*>): ColumnSet<*> =
168194
allExcept(*others)
169195

170-
@Deprecated("Use allExcept instead", ReplaceWith("this.allExcept(others)"))
196+
@Deprecated(
197+
message = COL_SELECT_DSL_EXCEPT,
198+
replaceWith = ReplaceWith(COL_SELECT_DSL_EXCEPT_REPLACE_RESOLVER),
199+
level = DeprecationLevel.WARNING,
200+
)
171201
public fun ColumnsSelectionDsl<*>.except(vararg others: ColumnPath): ColumnSet<*> =
172202
allExcept(*others)
173203

@@ -179,11 +209,7 @@ public interface AllExceptColumnsSelectionDsl<out T> {
179209
except(selector())
180210

181211
public infix fun <C> ColumnSet<C>.except(other: ColumnsResolver<*>): ColumnSet<C> =
182-
createColumnSet { context ->
183-
val resolvedCols = this@except.resolve(context)
184-
val resolvedColsToExcept = other.resolve(context)
185-
resolvedCols.allColumnsExceptKeepingStructure(resolvedColsToExcept)
186-
} as ColumnSet<C>
212+
exceptInternal(other)
187213

188214
public fun <C> ColumnSet<C>.except(vararg other: ColumnsResolver<*>): ColumnSet<C> =
189215
except(other.toColumnSet())
@@ -334,10 +360,16 @@ public interface AllExceptColumnsSelectionDsl<out T> {
334360

335361
// endregion
336362

337-
// endregion
363+
@Suppress("UNCHECKED_CAST")
364+
private fun <C> ColumnSet<C>.exceptInternal(other: ColumnsResolver<*>): ColumnSet<C> =
365+
createColumnSet { context ->
366+
val resolvedCols = this.resolve(context)
367+
val resolvedColsToExcept = other.resolve(context)
368+
resolvedCols.allColumnsExceptKeepingStructure(resolvedColsToExcept)
369+
} as ColumnSet<C>
338370

339-
private fun SingleColumn<DataRow<*>>.allColsExceptInternal(other: ColumnsResolver<*>) =
340-
selectInternal { all() except other }
371+
private fun SingleColumn<DataRow<*>>.allColsExceptInternal(other: ColumnsResolver<*>): ColumnSet<Any?> =
372+
selectInternal { all().exceptInternal(other) }
341373
}
342374

343375
// endregion

core/generated-sources/src/main/kotlin/org/jetbrains/kotlinx/dataframe/api/select.kt

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,6 @@ public fun <T> DataFrame<T>.select(vararg columns: AnyColumnReference): DataFram
3636

3737
// region ColumnsSelectionDsl
3838
// NOTE: invoke overloads are inside ColumnsSelectionDsl.kt due to conflicts
39-
// TODO probably provide all overloads, similar to DataFrame.select in this file
40-
// TODO explore parallels with except {}
4139
public interface SelectColumnsSelectionDsl {
4240

4341
/**
@@ -57,7 +55,7 @@ public interface SelectColumnsSelectionDsl {
5755
*
5856
* &nbsp;&nbsp;&nbsp;&nbsp;
5957
*
60-
* `colSelector: `[ColumnSelector][org.jetbrains.kotlinx.dataframe.ColumnSelector]
58+
* `colsSelector: `[ColumnsSelector][org.jetbrains.kotlinx.dataframe.ColumnsSelector]
6159
*
6260
*
6361
*
@@ -72,9 +70,9 @@ public interface SelectColumnsSelectionDsl {
7270
*
7371
* [columnGroup][org.jetbrains.kotlinx.dataframe.documentation.UsageTemplateColumnsSelectionDsl.UsageTemplate.ColumnGroupDef]
7472
*
75-
* &nbsp;&nbsp;&nbsp;&nbsp;.[**select**][org.jetbrains.kotlinx.dataframe.api.SelectColumnsSelectionDsl.select]**` {`** [colSelector][org.jetbrains.kotlinx.dataframe.documentation.UsageTemplateColumnsSelectionDsl.UsageTemplate.ColumnSelectorDef] **`}`**
73+
* &nbsp;&nbsp;&nbsp;&nbsp;.[**select**][org.jetbrains.kotlinx.dataframe.api.SelectColumnsSelectionDsl.select]**` {`** [colsSelector][org.jetbrains.kotlinx.dataframe.documentation.UsageTemplateColumnsSelectionDsl.UsageTemplate.ColumnsSelectorDef] **`}`**
7674
*
77-
* &nbsp;&nbsp;&nbsp;&nbsp;`|`[**` {`**][ColumnsSelectionDsl.select] [colSelector][org.jetbrains.kotlinx.dataframe.documentation.UsageTemplateColumnsSelectionDsl.UsageTemplate.ColumnSelectorDef] [**`}`**][ColumnsSelectionDsl.select]
75+
* &nbsp;&nbsp;&nbsp;&nbsp;`|`[**` {`**][ColumnsSelectionDsl.select] [colsSelector][org.jetbrains.kotlinx.dataframe.documentation.UsageTemplateColumnsSelectionDsl.UsageTemplate.ColumnsSelectorDef] [**`}`**][ColumnsSelectionDsl.select]
7876
*
7977
*
8078
*

core/generated-sources/src/main/kotlin/org/jetbrains/kotlinx/dataframe/documentation/UsageTemplateColumnsSelectionDsl.kt

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ package org.jetbrains.kotlinx.dataframe.documentation
22

33
import org.jetbrains.kotlinx.dataframe.ColumnFilter
44
import org.jetbrains.kotlinx.dataframe.ColumnSelector
5+
import org.jetbrains.kotlinx.dataframe.ColumnsSelector
56
import org.jetbrains.kotlinx.dataframe.api.ColumnsSelectionDsl
67
import org.jetbrains.kotlinx.dataframe.columns.ColumnKind
78
import org.jetbrains.kotlinx.dataframe.columns.ColumnSet
@@ -147,6 +148,9 @@ public interface UsageTemplateColumnsSelectionDsl {
147148
/** `colSelector: `[ColumnSelector][ColumnSelector] */
148149
public interface ColumnSelectorDef
149150

151+
/** `colsSelector: `[ColumnsSelector][ColumnsSelector] */
152+
public interface ColumnsSelectorDef
153+
150154
/** `number: `[Int][Int] */
151155
public interface NumberDef
152156

@@ -211,6 +215,9 @@ public interface UsageTemplateColumnsSelectionDsl {
211215
/** [colSelector][ColumnSelectorDef] */
212216
public interface ColumnSelectorRef
213217

218+
/** [colsSelector][ColumnsSelectorDef] */
219+
public interface ColumnsSelectorRef
220+
214221
/** [number][NumberDef] */
215222
public interface NumberRef
216223

core/generated-sources/src/main/kotlin/org/jetbrains/kotlinx/dataframe/impl/columns/Utils.kt

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -407,10 +407,12 @@ internal fun List<ColumnWithPath<*>>.allColumnsExceptAndUnpack(columns: Iterable
407407
* Returns a new list of column paths, except the ones inside [columns].
408408
* NOTE: ColumnGroups are adapted to keep their structure. If a column inside a column group is excepted, it will
409409
* be removed from the group.
410-
*
411-
* TODO remove column group when it's empty?
410+
* Empty groups will be removed if [removeEmptyGroups]` == true`
412411
*/
413-
internal fun List<ColumnWithPath<*>>.allColumnsExceptKeepingStructure(columns: Iterable<ColumnWithPath<*>>): List<ColumnWithPath<*>> {
412+
internal fun List<ColumnWithPath<*>>.allColumnsExceptKeepingStructure(
413+
columns: Iterable<ColumnWithPath<*>>,
414+
removeEmptyGroups: Boolean = true,
415+
): List<ColumnWithPath<*>> {
414416
if (isEmpty()) return emptyList()
415417
val fullTree = collectTree()
416418
for (columnToExcept in columns) {
@@ -427,13 +429,23 @@ internal fun List<ColumnWithPath<*>>.allColumnsExceptKeepingStructure(columns: I
427429
// treat it as a DF to remove the column to except from it and
428430
// convert it back to a column group
429431
val current = nodeToExcept.parent.data as ColumnGroup<*>? ?: continue
430-
nodeToExcept.parent.data = current
432+
val adjustedCurrent = current
431433
.remove(nodeToExcept.name)
432434
.asColumnGroup(current.name)
433435
.addPath(current.path())
434436

437+
// remove the group if it's empty and removeEmptyGroups is true
438+
// else, simply update the parent's data with the adjusted column group
439+
nodeToExcept.parent.data =
440+
if (adjustedCurrent.cols().isEmpty() && removeEmptyGroups) {
441+
null
442+
} else {
443+
adjustedCurrent
444+
}
445+
435446
// now we update the parent's parents recursively with new column group instances
436447
var parent = nodeToExcept.parent.parent
448+
437449
@Suppress("UNNECESSARY_NOT_NULL_ASSERTION")
438450
var currentNode = nodeToExcept.parent!!
439451
while (parent != null) {

core/generated-sources/src/main/kotlin/org/jetbrains/kotlinx/dataframe/util/deprecationMessages.kt

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,16 @@ internal const val COL_SELECT_DSL_LIST_DATACOLUMN_GET_REPLACE = "this.toColumnSe
9393
internal const val COL_SELECT_DSL_SELECT_COLS = "Nested select is reserved for ColumnsSelector/ColumnsSelectionDsl behavior. Use myGroup.cols() to select columns by name from a ColumnGroup. $message_0_14"
9494
internal const val COL_SELECT_DSL_SELECT_COLS_REPLACE = "this.cols(*columns)"
9595

96+
internal const val COL_SELECT_DSL_SINGLE_COL_EXCEPT = "This function is replaced with allColsExcept. $message_0_14"
97+
internal const val COL_SELECT_DSL_SINGLE_COL_EXCEPT_REPLACE_SELECTOR = "this.allColsExcept(selector)"
98+
internal const val COL_SELECT_DSL_SINGLE_COL_EXCEPT_REPLACE_RESOLVER = "this.allColsExcept { others.toColumnSet() }"
99+
internal const val COL_SELECT_DSL_SINGLE_COL_EXCEPT_REPLACE_OTHERS = "this.allColsExcept(*others)"
100+
101+
internal const val COL_SELECT_DSL_EXCEPT = "This function is replaced with allExcept. $message_0_14"
102+
internal const val COL_SELECT_DSL_EXCEPT_REPLACE_SELECTOR = "this.allExcept(selector)"
103+
internal const val COL_SELECT_DSL_EXCEPT_REPLACE_RESOLVER = "this.allExcept(*others)"
104+
105+
96106
// endregion
97107

98108
// region WARNING in 0.14, ERROR in 0.15

0 commit comments

Comments
 (0)