Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

K2 preparation #708

Merged
merged 11 commits into from
May 31, 2024
Merged
Show file tree
Hide file tree
Changes from 9 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -13,17 +13,19 @@ public interface ColumnsForAggregateSelectionDsl<out T> : ColumnsSelectionDsl<T>
ConfiguredAggregateColumn.withDefault(this, defaultValue)

public infix fun <C> SingleColumn<C>.default(defaultValue: C): SingleColumn<C> =
ConfiguredAggregateColumn.withDefault(this, defaultValue).single()
ConfiguredAggregateColumn.withDefault(this, defaultValue)

public fun path(vararg names: String): ColumnPath = ColumnPath(names.asList())

public infix fun <C> ColumnSet<C>.into(name: String): ColumnSet<C> = ConfiguredAggregateColumn.withPath(this, pathOf(name))
public infix fun <C> ColumnSet<C>.into(name: String): ColumnSet<C> =
ConfiguredAggregateColumn.withPath(this, pathOf(name))

public infix fun <C> SingleColumn<C>.into(name: String): SingleColumn<C> =
ConfiguredAggregateColumn.withPath(this, pathOf(name)).single()
ConfiguredAggregateColumn.withPath(this, pathOf(name))

public infix fun <C> ColumnSet<C>.into(path: ColumnPath): ColumnSet<C> = ConfiguredAggregateColumn.withPath(this, path)
public infix fun <C> ColumnSet<C>.into(path: ColumnPath): ColumnSet<C> =
ConfiguredAggregateColumn.withPath(this, path)

public infix fun <C> SingleColumn<C>.into(path: ColumnPath): SingleColumn<C> =
ConfiguredAggregateColumn.withPath(this, path).single()
ConfiguredAggregateColumn.withPath(this, path)
}
Original file line number Diff line number Diff line change
Expand Up @@ -82,16 +82,16 @@ public interface ColumnsSelectionDsl<out T> : /* SingleColumn<DataRow<T>> */
SingleColumnsSelectionDsl,

// col(name), col(5), [5]
ColColumnsSelectionDsl,
ColColumnsSelectionDsl<T>,
// valueCol(name), valueCol(5)
ValueColColumnsSelectionDsl,
ValueColColumnsSelectionDsl<T>,
// frameCol(name), frameCol(5)
FrameColColumnsSelectionDsl,
FrameColColumnsSelectionDsl<T>,
// colGroup(name), colGroup(5)
ColGroupColumnsSelectionDsl,
ColGroupColumnsSelectionDsl<T>,

// cols {}, cols(), cols(colA, colB), cols(1, 5), cols(1..5), [{}]
ColsColumnsSelectionDsl,
ColsColumnsSelectionDsl<T>,

// colA.."colB"
ColumnRangeColumnsSelectionDsl,
Expand All @@ -106,7 +106,7 @@ public interface ColumnsSelectionDsl<out T> : /* SingleColumn<DataRow<T>> */
ColsOfKindColumnsSelectionDsl,

// all(Cols), allAfter(colA), allBefore(colA), allFrom(colA), allUpTo(colA)
AllColumnsSelectionDsl,
AllColumnsSelectionDsl<T>,
// colsAtAnyDepth {}, colsAtAnyDepth()
ColsAtAnyDepthColumnsSelectionDsl,
// colsInGroups {}, colsInGroups()
Expand Down Expand Up @@ -494,58 +494,6 @@ public interface ColumnsSelectionDsl<out T> : /* SingleColumn<DataRow<T>> */
public operator fun <C, R> SingleColumn<DataRow<C>>.invoke(selector: ColumnsSelector<C, R>): ColumnSet<R> =
select(selector)

/**
* ## Select from [ColumnGroup][org.jetbrains.kotlinx.dataframe.columns.ColumnGroup]
*
* Perform a selection of columns using the [Columns Selection DSL][org.jetbrains.kotlinx.dataframe.api.ColumnsSelectionDsl] on
* any [ColumnGroup][org.jetbrains.kotlinx.dataframe.columns.ColumnGroup]. This is more powerful than the [cols][org.jetbrains.kotlinx.dataframe.api.ColumnsSelectionDsl.cols] filter, because now all
* operations of the DSL are at your disposal.
*
* The scope of the new DSL instance is relative to
* the [ColumnGroup][org.jetbrains.kotlinx.dataframe.columns.ColumnGroup] you are selecting from.
*
* The [invoke][org.jetbrains.kotlinx.dataframe.api.ColumnsSelectionDsl.invoke] operator is overloaded to work as a shortcut for this method.
*
* ### Check out: [Grammar][org.jetbrains.kotlinx.dataframe.api.SelectColumnsSelectionDsl.Grammar]
*
* #### For example:
*
* `df.`[select][org.jetbrains.kotlinx.dataframe.DataFrame.select]` { myColGroup.`[select][org.jetbrains.kotlinx.dataframe.columns.SingleColumn.select]` { someCol `[and][org.jetbrains.kotlinx.dataframe.api.AndColumnsSelectionDsl.and]` `[colsOf][org.jetbrains.kotlinx.dataframe.columns.SingleColumn.colsOf]`<`[String][String]`>() } }`
*
* `df.`[select][org.jetbrains.kotlinx.dataframe.DataFrame.select]` { "myGroupCol" `[{][kotlin.String.select]` "colA" and `[expr][org.jetbrains.kotlinx.dataframe.api.ColumnsSelectionDsl.expr]` { 0 } `[}][kotlin.String.select]` }`
*
* `df.`[select][org.jetbrains.kotlinx.dataframe.DataFrame.select]` { "pathTo"["myGroupCol"].`[select][org.jetbrains.kotlinx.dataframe.columns.ColumnPath.select]` { "colA" and "colB" } }`
*
* `df.`[select][org.jetbrains.kotlinx.dataframe.DataFrame.select]` { it["myGroupCol"].`[asColumnGroup][org.jetbrains.kotlinx.dataframe.DataColumn.asColumnGroup]`()`[() {][org.jetbrains.kotlinx.dataframe.columns.SingleColumn.select]` "colA" and "colB" `[}][org.jetbrains.kotlinx.dataframe.columns.SingleColumn.select]` }`
*
* #### Examples for this overload:
*
* `df.`[select][DataFrame.select]` { Type::myColGroup.`[`select`][KProperty.select]` { someCol `[`and`][ColumnsSelectionDsl.and]` `[`colsOf`][SingleColumn.colsOf]`<`[`String`][String]`>() } }`
*
* `df.`[select][DataFrame.select]` { DataSchemaType::myColGroup `[`{`][KProperty.select]` colA `[`and`][ColumnsSelectionDsl.and]` colB `[`}`][KProperty.select]` }`
*
* ## NOTE:
* If you get a warning `CANDIDATE_CHOSEN_USING_OVERLOAD_RESOLUTION_BY_LAMBDA_ANNOTATION`, you
* can safely ignore this. It is caused by a workaround for a bug in the Kotlin compiler
* ([KT-64092](https://youtrack.jetbrains.com/issue/KT-64092/OVERLOADRESOLUTIONAMBIGUITY-caused-by-lambda-argument)).
*
*
* &nbsp;&nbsp;&nbsp;&nbsp;
*
*
* See also [except][org.jetbrains.kotlinx.dataframe.api.ColumnsSelectionDsl.except]/[allExcept][org.jetbrains.kotlinx.dataframe.api.AllExceptColumnsSelectionDsl.allColsExcept] for the inverted operation of this function.
*
* @param [selector] The [ColumnsSelector][org.jetbrains.kotlinx.dataframe.ColumnsSelector] to use for the selection.
* @receiver The [ColumnGroup][org.jetbrains.kotlinx.dataframe.columns.ColumnGroup] to select from.
* @throws [IllegalArgumentException] If [this] is not a [ColumnGroup][org.jetbrains.kotlinx.dataframe.columns.ColumnGroup].
* @return A [ColumnSet][org.jetbrains.kotlinx.dataframe.columns.ColumnSet] containing the columns selected by [selector].
* @see [SingleColumn.except]
*/
@Suppress("INAPPLICABLE_JVM_NAME")
@JvmName("KPropertyDataRowInvoke")
public operator fun <C, R> KProperty<DataRow<C>>.invoke(selector: ColumnsSelector<C, R>): ColumnSet<R> =
select(selector)

/**
* ## Select from [ColumnGroup][org.jetbrains.kotlinx.dataframe.columns.ColumnGroup]
*
Expand Down Expand Up @@ -588,8 +536,6 @@ public interface ColumnsSelectionDsl<out T> : /* SingleColumn<DataRow<T>> */
* @return A [ColumnSet][org.jetbrains.kotlinx.dataframe.columns.ColumnSet] containing the columns selected by [selector].
* @see [SingleColumn.except]
*/
@OptIn(ExperimentalTypeInference::class)
@OverloadResolutionByLambdaReturnType
public operator fun <C, R> KProperty<C>.invoke(selector: ColumnsSelector<C, R>): ColumnSet<R> =
columnGroup(this).select(selector)

Expand Down
Loading