Skip to content

Commit

Permalink
Automated commit of generated code
Browse files Browse the repository at this point in the history
  • Loading branch information
github-actions[bot] committed Jan 29, 2025
1 parent 3448fc9 commit c95438d
Show file tree
Hide file tree
Showing 5 changed files with 36 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -225,6 +225,7 @@ public class AddDsl<T>(
@AccessApiOverload
public fun group(column: AnyColumnGroupAccessor, body: AddDsl<T>.() -> Unit): Unit = group(column.name(), body)

@Interpretable("AddDslNamedGroup")
public fun group(name: String, body: AddDsl<T>.() -> Unit) {
val dsl = AddDsl(df)
body(dsl)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ public fun <T> InsertClause<T>.after(column: ColumnSelector<T, *>): DataFrame<T>

public fun <T> InsertClause<T>.after(column: String): DataFrame<T> = df.add(this.column).move(this.column).after(column)

@AccessApiOverload
public fun <T> InsertClause<T>.after(column: ColumnAccessor<*>): DataFrame<T> = after(column.path())

@AccessApiOverload
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,10 +53,13 @@ public fun <T> DataFrame<T>.moveTo(newColumnIndex: Int, vararg columns: KPropert

// region moveToLeft

@Refine
@Interpretable("MoveToLeft1")
public fun <T> DataFrame<T>.moveToLeft(columns: ColumnsSelector<T, *>): DataFrame<T> = move(columns).toLeft()

public fun <T> DataFrame<T>.moveToLeft(vararg columns: String): DataFrame<T> = moveToLeft { columns.toColumnSet() }

@AccessApiOverload
public fun <T> DataFrame<T>.moveToLeft(vararg columns: AnyColumnReference): DataFrame<T> =
moveToLeft { columns.toColumnSet() }

Expand All @@ -68,13 +71,17 @@ public fun <T> DataFrame<T>.moveToLeft(vararg columns: KProperty<*>): DataFrame<

// region moveToRight

@Refine
@Interpretable("MoveToRight1")
public fun <T> DataFrame<T>.moveToRight(columns: ColumnsSelector<T, *>): DataFrame<T> = move(columns).toRight()

public fun <T> DataFrame<T>.moveToRight(vararg columns: String): DataFrame<T> = moveToRight { columns.toColumnSet() }

@AccessApiOverload
public fun <T> DataFrame<T>.moveToRight(vararg columns: AnyColumnReference): DataFrame<T> =
moveToRight { columns.toColumnSet() }

@AccessApiOverload
public fun <T> DataFrame<T>.moveToRight(vararg columns: KProperty<*>): DataFrame<T> =
moveToRight { columns.toColumnSet() }

Expand All @@ -94,6 +101,11 @@ public fun <T, C> MoveClause<T, C>.into(
newPathExpression = column,
)

/**
* Move a single selected column to top level with a new name
*/
@Refine
@Interpretable("MoveInto0")
public fun <T, C> MoveClause<T, C>.into(column: String): DataFrame<T> = pathOf(column).let { path -> into { path } }

public fun <T, C> MoveClause<T, C>.intoIndexed(
Expand All @@ -109,11 +121,19 @@ public fun <T, C> MoveClause<T, C>.intoIndexed(

// region under

@Refine
@Interpretable("MoveUnder0")
public fun <T, C> MoveClause<T, C>.under(column: String): DataFrame<T> = pathOf(column).let { path -> under { path } }

@AccessApiOverload
public fun <T, C> MoveClause<T, C>.under(column: AnyColumnGroupAccessor): DataFrame<T> =
column.path().let { path -> under { path } }

/**
* Move selected columns under existing column group
*/
@Refine
@Interpretable("MoveUnder1")
public fun <T, C> MoveClause<T, C>.under(
column: ColumnsSelectionDsl<T>.(ColumnWithPath<C>) -> AnyColumnReference,
): DataFrame<T> =
Expand All @@ -138,10 +158,13 @@ public fun <T, C> MoveClause<T, C>.toTop(

// region after

@Refine
@Interpretable("MoveAfter0")
public fun <T, C> MoveClause<T, C>.after(column: ColumnSelector<T, *>): DataFrame<T> = afterOrBefore(column, true)

public fun <T, C> MoveClause<T, C>.after(column: String): DataFrame<T> = after { column.toColumnAccessor() }

@AccessApiOverload
public fun <T, C> MoveClause<T, C>.after(column: AnyColumnReference): DataFrame<T> = after { column }

@AccessApiOverload
Expand All @@ -157,8 +180,12 @@ fun <T, C> MoveColsClause<T, C>.before(column: String) = before { column.toColum
fun <T, C> MoveColsClause<T, C>.before(column: ColumnSelector<T, *>) = afterOrBefore(column, false)
*/

@Refine
@Interpretable("MoveToLeft0")
public fun <T, C> MoveClause<T, C>.toLeft(): DataFrame<T> = to(0)

@Refine
@Interpretable("MoveToRight0")
public fun <T, C> MoveClause<T, C>.toRight(): DataFrame<T> = to(df.ncol)

public class MoveClause<T, C>(internal val df: DataFrame<T>, internal val columns: ColumnsSelector<T, C>) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,7 @@ public abstract class CreateDataFrameDsl<T> : TraversePropertiesDsl {

public inline fun <reified R> inferType(noinline expression: (T) -> R): InferType<T, R> = InferType(expression)

@Interpretable("ToDataFrameDslStringInvoke")
public abstract operator fun String.invoke(builder: CreateDataFrameDsl<T>.() -> Unit)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -795,4 +795,10 @@ class DataFrameTreeTests : BaseTest() {
val df = typed2.convert { nameAndCity }.asFrame { it.remove { city } }
df.nameAndCity.columns() shouldBe typed2.nameAndCity.remove { city }.columns()
}

@Test
fun `move under existing group`() {
val df = typed2.move { age }.under { nameAndCity }
df.nameAndCity.columnNames() shouldBe listOf("name", "city", "age")
}
}

0 comments on commit c95438d

Please sign in to comment.