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

ColumnsSelection DSL overhaul #372

Merged
merged 169 commits into from
Jan 30, 2024
Merged
Show file tree
Hide file tree
Changes from 167 commits
Commits
Show all changes
169 commits
Select commit Hold shift + click to select a range
6511a50
valueColumn concept start
Jolanrensen May 9, 2023
65fbbb6
Merge branch 'dfs-rename3' into continued-columnsselectiondsl
Jolanrensen May 10, 2023
fb37b27
valueCols, frameCols and tests with recursively
Jolanrensen May 10, 2023
b60f1fd
updating docs processor version. colsOfKind test, writing docs for co…
Jolanrensen May 11, 2023
a7fa80b
col(index) now also throws IndexOutOfBoundsException, working on docs
Jolanrensen May 11, 2023
4440d20
cols(indices) docs finished
Jolanrensen May 12, 2023
e1095de
docs for valueCols, colGroups, frameCols
Jolanrensen May 15, 2023
8da2fe2
added missing overloads for all flavors
Jolanrensen May 15, 2023
1cbc563
added docs for allFrom, allAfter, allBefore, allUpTo
Jolanrensen May 16, 2023
9273479
added check function to provide helpful error messages when using non…
Jolanrensen May 16, 2023
1069b08
universal columnGroup check for SingleColumn
Jolanrensen May 17, 2023
2bc3902
added more colGroup checks, working on select
Jolanrensen May 23, 2023
efc5a48
new parent for ColumnSet and SingleColumn: ColumnsResolver. So, SingC…
Jolanrensen May 23, 2023
478485b
added missing docs for ColumnPath overloads, docs for select {}
Jolanrensen May 24, 2023
1d04d28
overloads for roots, children, take, drop (and variants)
Jolanrensen May 24, 2023
3ac16ae
children {}
Jolanrensen May 25, 2023
592d060
start with `and`, added invoke overloads for select {} tbd
Jolanrensen May 25, 2023
4892851
updated select docs, "and" docs
Jolanrensen May 26, 2023
fb19a4e
drop(Last) and take(Last) docs
Jolanrensen May 26, 2023
2eec84a
fixed some usages of KProperty api in docs. added docs for take/drop(…
Jolanrensen May 30, 2023
2d8887b
overhaul for references in csdsl. Always specifiying receiver type if…
Jolanrensen May 30, 2023
4d996bb
updated doc processor version, tests, filter {}, overloads for nameCo…
Jolanrensen May 31, 2023
8a322af
tests and docs for nameContains
Jolanrensen Jun 1, 2023
e603e4d
updated docs for first, single, last. Added firstChild etc. overloads…
Jolanrensen Jun 1, 2023
357c6f1
overloads for except and allExcept, WIP
Jolanrensen Jun 1, 2023
4faa62c
docs for nameStartsWith/nameEndsWith, distinct, overloads and docs fo…
Jolanrensen Jun 5, 2023
deedcad
named/into docs and overloads
Jolanrensen Jun 5, 2023
ab56cf8
asColumnGroup() overloads, expanded * imports across the library
Jolanrensen Jun 6, 2023
d9f4026
untyped String.invoke(), fixed allColumnsExceptKeepingStructure
Jolanrensen Jun 7, 2023
4d1d440
linting
Jolanrensen Jun 8, 2023
33e41db
added selection notebook to ask for feedback
Jolanrensen Jun 9, 2023
9799143
added selection notebook to ask for feedback
Jolanrensen Jun 9, 2023
3100845
small notebook update
Jolanrensen Jun 13, 2023
59f618b
small doc fix
Jolanrensen Jun 13, 2023
a3c703c
Merge branch 'master' into continued-columnsselectiondsl
Jolanrensen Jun 13, 2023
67e1dfe
initial ColumnsSelectionDsl/SingleColumn split. Needs more tests and …
Jolanrensen Jun 15, 2023
073c196
moved first, single, last to their own files
Jolanrensen Jun 15, 2023
e48d072
split off all, children, colGroups, cols, colsOfKind, constructors, f…
Jolanrensen Jun 19, 2023
5ca56fe
split off drop and take functions, fixed linting
Jolanrensen Jun 21, 2023
36ba0a7
split off except, withoutNulls, column name filters
Jolanrensen Jun 23, 2023
f1a2569
split off and, colsOf, range of columns, ColumnSelectionDsl, asColumn…
Jolanrensen Jun 26, 2023
4ebea6f
Merge branch 'master' into continued-columnsselectiondsl
Jolanrensen Jun 27, 2023
436dcd2
update version
Jolanrensen Jun 27, 2023
b2bc962
readying first, last, and single for reviews
Jolanrensen Jun 29, 2023
5ebe712
processing review, renamed Child to Col for first, last, and single
Jolanrensen Jul 20, 2023
5c5751c
added todo message for allExcept in this PR
Jolanrensen Jul 24, 2023
b202ad1
Merge branch 'master' into continued-columnsselectiondsl
Jolanrensen Jul 25, 2023
8d86761
update from master
Jolanrensen Jul 25, 2023
a5fd642
moved col() from constructors to its own file, expanded and added ove…
Jolanrensen Jul 27, 2023
28e0134
fixed col on singleColumn, added new tests for col
Jolanrensen Jul 27, 2023
620f577
fixed col on singleColumn, added new tests for col
Jolanrensen Jul 27, 2023
ae2acd5
Merge remote-tracking branch 'origin/continued-columnsselectiondsl' i…
Jolanrensen Jul 27, 2023
bfb2348
fixed bug where columnGroup("nonGroup").column("something") would be …
Jolanrensen Jul 28, 2023
caefdf3
exception tests for col
Jolanrensen Jul 28, 2023
ffeba3e
valueCol overloads and moved into its own file
Jolanrensen Jul 28, 2023
d24ef2f
performCheck function for ColumnAccessors. valueCol tests
Jolanrensen Jul 28, 2023
1129fbb
frameCol overloads and tests
Jolanrensen Jul 31, 2023
e6bc06a
colGroup overloads and tests, removed interface from constructors.kt
Jolanrensen Jul 31, 2023
053155f
updates were made to the documentation in the constructors.kt file. T…
Jolanrensen Aug 1, 2023
9766997
updated cols.kt file with overloads. still need to check and remove s…
Jolanrensen Aug 2, 2023
cd828a9
moved some get operator functions to extension functions for DataFram…
Jolanrensen Aug 2, 2023
70e9c8d
removed cols get operations with indices on non-columnSets. fixed col…
Jolanrensen Aug 3, 2023
096d32c
Merge branch 'master' into continued-columnsselectiondsl
Jolanrensen Aug 9, 2023
f24d8b8
updating from master, replacing deprecated @tags
Jolanrensen Aug 9, 2023
1a39e46
updating some ? notation based on feedback
Jolanrensen Aug 10, 2023
c57e9ee
updating columnRange and its tests
Jolanrensen Aug 10, 2023
2edf8ef
changing ensureIsX() error messages.
Jolanrensen Aug 11, 2023
c284c2a
working on DSL grammars
Jolanrensen Aug 14, 2023
50d2063
updating DSL grammars with **bold** notation
Jolanrensen Aug 16, 2023
bb6da80
DSL grammar up till col done
Jolanrensen Aug 17, 2023
b1ef8cf
DSL grammar up till colGroup done
Jolanrensen Aug 17, 2023
af7dce7
a bit of structure in dsl grammars
Jolanrensen Aug 17, 2023
74fc3dd
DSL grammar up till cols done
Jolanrensen Aug 21, 2023
403a9b4
removed asColumnGroup overloads except for SingleColumn which was mov…
Jolanrensen Aug 21, 2023
0f4539f
column range done, expanded usage template
Jolanrensen Aug 21, 2023
e1abe4a
added recursively to dsl grammars where missing, fixed cols grammar, …
Jolanrensen Aug 22, 2023
3569f57
removed unnecessary KProperty receiver overloads
Jolanrensen Aug 23, 2023
f548cd9
added column path overloads for cols and optional typing for string-a…
Jolanrensen Aug 23, 2023
6383d64
moved usageTemplate, done until colGroups
Jolanrensen Aug 23, 2023
aae13c4
done up until frameCols, also update DSL grammar in ColumnsSelectionDsl
Jolanrensen Aug 24, 2023
e25e799
colsOfKind done
Jolanrensen Aug 25, 2023
eb8b761
reworking all-family of functions CS-DSL
Jolanrensen Aug 26, 2023
cb9d80b
added deprecated all-family functions
Jolanrensen Aug 26, 2023
1100d93
continuing all-family of functions CS-DSL, started writing tests, add…
Jolanrensen Aug 28, 2023
dea2241
renamed performCheck to onResolve. added and fixed overloads for all-…
Jolanrensen Aug 29, 2023
e85b75c
updated cs-dsl usage
Jolanrensen Aug 29, 2023
8fcec64
finished all functions, moved logic to single place, fixed references…
Jolanrensen Aug 29, 2023
d8e2cf6
renamed recursively/rec to atAnyDepth and deprecated original
Jolanrensen Aug 29, 2023
02391a4
experimenting with scope-notation atAnyDepth
Jolanrensen Sep 1, 2023
8e1b7c0
children->colsInGroups. Avoiding parent/child names in column groups.…
Jolanrensen Sep 13, 2023
a8d332d
operation.atAnyDepth() -> colsAtAnyDepth().operation, for simplicity,…
Jolanrensen Sep 14, 2023
464b413
colsAtAnyDepth {} kdocs updates and references to the old name
Jolanrensen Sep 19, 2023
100e145
removing references to .atAnyDepth() in examples in kdocs
Jolanrensen Sep 19, 2023
cb8a51c
updated docs with korro
Jolanrensen Sep 20, 2023
92b6d87
more renaming of public `children()` functions to `cols()` to drop an…
Jolanrensen Sep 22, 2023
bf93dbe
take(Last)(Cols)(While) done
Jolanrensen Oct 3, 2023
6e03cfa
Merge branch 'master' into continued-columnsselectiondsl
Jolanrensen Oct 3, 2023
beb48cf
drop(Last)(Cols)(While) done
Jolanrensen Oct 3, 2023
7e14263
Extra information for Column not found error in DataFrameReceiver. Cl…
Jolanrensen Oct 9, 2023
2d09166
removed references to transformable columnsets
Jolanrensen Oct 19, 2023
71dc5b0
done with refactoring ColumnNameFilters
Jolanrensen Oct 19, 2023
7b3f476
Merge branch 'master' into continued-columnsselectiondsl
Jolanrensen Oct 19, 2023
677c3bf
Merge branch 'master' into continued-columnsselectiondsl
Jolanrensen Oct 20, 2023
3122362
updated from master post 0.12 release
Jolanrensen Oct 24, 2023
0c6069c
moved new deprecated methods to 0.13 warning region
Jolanrensen Oct 24, 2023
5d3eaae
Merge branch 'master' into continued-columnsselectiondsl
Jolanrensen Oct 24, 2023
50112fc
bumping simple-git version
Jolanrensen Oct 24, 2023
aec1386
moved select functions outside of the ColumnsSelectionDsl where possible
Jolanrensen Oct 25, 2023
9f82253
withoutNulls, renamed, added usage, tests
Jolanrensen Oct 25, 2023
c5f34e0
distinct, added usage and tests. Added example for CS dsl UsageTemplate
Jolanrensen Oct 26, 2023
dbaa5a9
none, added usage and tests.
Jolanrensen Oct 26, 2023
abfb528
reworked colsOf, added tests and usage
Jolanrensen Oct 31, 2023
6bf8a04
added transformSingleWithContext, experiments for except. renamed roo…
Jolanrensen Nov 2, 2023
1452405
added usage for simplify and moved some experiments
Jolanrensen Nov 7, 2023
ff15430
removed testing notebooks
Jolanrensen Nov 7, 2023
eff8fbb
improve none() test
Jolanrensen Nov 8, 2023
658f0e8
and function docs, usage, tests
Jolanrensen Nov 8, 2023
8a242c8
rename/into added usage and tests
Jolanrensen Nov 10, 2023
349c356
Deprecated List<DataColumn<C>>[IntRange] because there were no usages…
Jolanrensen Nov 10, 2023
381d514
moved expr {} and started with Usage and tests
Jolanrensen Nov 10, 2023
ed40fa2
weakened type in mapToColumn from ColumnAccessor to ColumnReference s…
Jolanrensen Nov 13, 2023
e536b48
finished tests for expr in selection dsl
Jolanrensen Nov 13, 2023
0764e48
Changed ColumnSet.allX() functions to take ColumnFilter instead of Co…
Jolanrensen Nov 16, 2023
5820e40
removed overloads for filter aside from ColumnSet, wrote tests and Usage
Jolanrensen Nov 29, 2023
5979821
updating from master
Jolanrensen Nov 30, 2023
9113dc1
fixing linting
Jolanrensen Nov 30, 2023
0c8ad63
Added @DslMarker for CS-DSL such that accessors work better across sc…
Jolanrensen Dec 4, 2023
7453335
"fixed" KProperty<DataRow<T>>.select {} and KProperty<T>.select clash…
Jolanrensen Dec 5, 2023
bff2089
added select usage
Jolanrensen Dec 5, 2023
d9c6948
kdoc updates
Jolanrensen Dec 6, 2023
a0c33ba
added ! to DataColumnArithmetics.kt
Jolanrensen Dec 6, 2023
04c0e56
cols(vararg) can now throw IllegalArgumentException for non-existing …
Jolanrensen Dec 6, 2023
022e7b1
wip allColsExcept and fixing errors which show ColumnPaths
Jolanrensen Dec 6, 2023
9e433d5
wip allExcept. Added helper function for ColumnPath to drop its start…
Jolanrensen Dec 6, 2023
c4b3da7
removed allColsExcept infix overloads
Jolanrensen Dec 6, 2023
9ed12ed
Applying KT-64092 temp-fix to all(Cols)X functions as well
Jolanrensen Dec 11, 2023
35e4e19
Applying KT-64092 temp-fix to all(Cols)X functions as well
Jolanrensen Dec 11, 2023
681be27
updating error messages with column paths
Jolanrensen Dec 11, 2023
7f96d6f
improving except api and writing tests
Jolanrensen Dec 11, 2023
ee69a5d
improving except api and writing tests
Jolanrensen Dec 11, 2023
c669c06
working on kdocs, empty groups are now removed in new except functions
Jolanrensen Dec 12, 2023
8c81454
except usage grammar
Jolanrensen Dec 13, 2023
796f74d
small `and` changes simplifying scopes. WIP kdocs for except
Jolanrensen Dec 13, 2023
21bbbed
simplifying `and`, continuing kdocs `except`, adding experimental `ex…
Jolanrensen Dec 14, 2023
af637fb
minor doc fix
Jolanrensen Dec 15, 2023
d6a2d1c
working on except docs
Jolanrensen Jan 2, 2024
6fac7f1
finished non-experimental except docs
Jolanrensen Jan 3, 2024
87356c0
except kdocs done
Jolanrensen Jan 3, 2024
8bd09c9
sorted CSDSL
Jolanrensen Jan 4, 2024
4945870
updated Usage links across CsDSL
Jolanrensen Jan 4, 2024
4180389
updating kdocs
Jolanrensen Jan 4, 2024
18c5db4
fixed documentation urls
Jolanrensen Jan 5, 2024
25e1b56
kdocs created for DataFrame.select.
Jolanrensen Jan 5, 2024
8a1b557
dsl grammars fixed and added explanation with links to it
Jolanrensen Jan 8, 2024
17def06
linting
Jolanrensen Jan 8, 2024
fc83336
KType type def fixed in kdoc
Jolanrensen Jan 8, 2024
b439919
comment fix
Jolanrensen Jan 10, 2024
050f794
Merge branch 'master' into continued-columnsselectiondsl
Jolanrensen Jan 12, 2024
9590e3b
update from master
Jolanrensen Jan 12, 2024
94e6f87
Merge branch 'master' into continued-columnsselectiondsl
Jolanrensen Jan 15, 2024
be1e9e9
improving kdocs all across the CS DSL: simplifying first line for cla…
Jolanrensen Jan 22, 2024
f228165
improving kdocs for typealiases for lambdas, linting
Jolanrensen Jan 22, 2024
12f620a
renaming all "Usage" docs to "Grammar"
Jolanrensen Jan 23, 2024
721b390
adding note regarding return type of lambda CS-DSL
Jolanrensen Jan 23, 2024
46a18d5
adding something to each CS dsl interface
Jolanrensen Jan 25, 2024
7b54184
Merge branch 'master' into continued-columnsselectiondsl
Jolanrensen Jan 25, 2024
b99f3f4
updating from master
Jolanrensen Jan 25, 2024
9450590
fixed documentation notes based on review
Jolanrensen Jan 29, 2024
31c71c3
Merge branch 'master' into continued-columnsselectiondsl
Jolanrensen Jan 30, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
3 changes: 2 additions & 1 deletion build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,8 @@ allprojects {
"filename",
"comment-spacing",
"curly-spacing",
"experimental:annotation-spacing"
"experimental:annotation-spacing",
"no-unused-imports", // broken
)
}
} catch (_: UnknownDomainObjectException) {
Expand Down
1 change: 1 addition & 0 deletions core/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,7 @@ val processKDocsMain by creatingProcessDocTask(
ARG_DOC_PROCESSOR,
COMMENT_DOC_PROCESSOR,
SAMPLE_DOC_PROCESSOR,
// REMOVE_ESCAPE_CHARS_PROCESSOR,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

will be in the next release of the doc preprocessor, I must not forget to enable it then :)

)

arguments += ARG_DOC_PROCESSOR_LOG_NOT_FOUND to false
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ public interface ColumnsContainer<out T> {
public operator fun <R> get(column: KProperty<DataFrame<R>>): FrameColumn<R> = get(column.columnName).asAnyFrameColumn().castFrameColumn()

public fun <C> get(columns: ColumnsSelector<T, C>): List<DataColumn<C>>
public operator fun <C> get(column: ColumnSelector<T, C>): DataColumn<C> = get(column as ColumnsSelector<T, C>).single()
public fun <C> get(column: ColumnSelector<T, C>): DataColumn<C> = get(column as ColumnsSelector<T, C>).single()

// endregion
}
Original file line number Diff line number Diff line change
@@ -1,8 +1,28 @@
package org.jetbrains.kotlinx.dataframe

import org.jetbrains.kotlinx.dataframe.api.*
import org.jetbrains.kotlinx.dataframe.columns.*
import org.jetbrains.kotlinx.dataframe.impl.columns.*
import org.jetbrains.kotlinx.dataframe.api.Infer
import org.jetbrains.kotlinx.dataframe.api.asDataColumn
import org.jetbrains.kotlinx.dataframe.api.cast
import org.jetbrains.kotlinx.dataframe.api.concat
import org.jetbrains.kotlinx.dataframe.api.filter
import org.jetbrains.kotlinx.dataframe.api.map
import org.jetbrains.kotlinx.dataframe.api.schema
import org.jetbrains.kotlinx.dataframe.api.take
import org.jetbrains.kotlinx.dataframe.api.type
import org.jetbrains.kotlinx.dataframe.columns.BaseColumn
import org.jetbrains.kotlinx.dataframe.columns.ColumnGroup
import org.jetbrains.kotlinx.dataframe.columns.ColumnKind
import org.jetbrains.kotlinx.dataframe.columns.ColumnPath
import org.jetbrains.kotlinx.dataframe.columns.ColumnResolutionContext
import org.jetbrains.kotlinx.dataframe.columns.ColumnWithPath
import org.jetbrains.kotlinx.dataframe.columns.FrameColumn
import org.jetbrains.kotlinx.dataframe.columns.ValueColumn
import org.jetbrains.kotlinx.dataframe.impl.columns.ColumnGroupImpl
import org.jetbrains.kotlinx.dataframe.impl.columns.FrameColumnImpl
import org.jetbrains.kotlinx.dataframe.impl.columns.ValueColumnImpl
import org.jetbrains.kotlinx.dataframe.impl.columns.addPath
import org.jetbrains.kotlinx.dataframe.impl.columns.guessColumnType
import org.jetbrains.kotlinx.dataframe.impl.columns.toColumnKind
import org.jetbrains.kotlinx.dataframe.impl.getValuesType
import org.jetbrains.kotlinx.dataframe.impl.splitByIndices
import org.jetbrains.kotlinx.dataframe.schema.DataFrameSchema
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package org.jetbrains.kotlinx.dataframe

import org.jetbrains.kotlinx.dataframe.aggregation.Aggregatable
import org.jetbrains.kotlinx.dataframe.aggregation.AggregateGroupedBody
import org.jetbrains.kotlinx.dataframe.api.ColumnsSelectionDsl
import org.jetbrains.kotlinx.dataframe.api.add
import org.jetbrains.kotlinx.dataframe.api.cast
import org.jetbrains.kotlinx.dataframe.api.getRows
Expand Down Expand Up @@ -68,18 +69,14 @@ public interface DataFrame<out T> : Aggregatable<T>, ColumnsContainer<T> {

// region get columns

override operator fun <C> get(columns: ColumnsSelector<T, C>): List<DataColumn<C>> =
/**
* Returns a list of columns selected by [columns], a [ColumnsSelectionDsl].
*
* NOTE: This doesn't work in [ColumnsSelectionDsl], use [ColumnsSelectionDsl.cols] to select columns by predicate.
*/
override fun <C> get(columns: ColumnsSelector<T, C>): List<DataColumn<C>> =
getColumnsImpl(UnresolvedColumnsPolicy.Fail, columns)

public operator fun get(first: AnyColumnReference, vararg other: AnyColumnReference): DataFrame<T> =
select { (listOf(first) + other).toColumnSet() }

public operator fun get(first: String, vararg other: String): DataFrame<T> =
select { (listOf(first) + other).toColumnSet() }

public operator fun get(columnRange: ClosedRange<String>): DataFrame<T> =
select { columnRange.start..columnRange.endInclusive }

// endregion

// region get rows
Expand All @@ -103,6 +100,25 @@ public interface DataFrame<out T> : Aggregatable<T>, ColumnsContainer<T> {
// endregion
}

// region get columns

/**
* Returns a list of columns selected by [columns], a [ColumnsSelectionDsl].
*/
public operator fun <T, C> DataFrame<T>.get(columns: ColumnsSelector<T, C>): List<DataColumn<C>> =
this.get(columns)

public operator fun <T> DataFrame<T>.get(first: AnyColumnReference, vararg other: AnyColumnReference): DataFrame<T> =
select { (listOf(first) + other).toColumnSet() }

public operator fun <T> DataFrame<T>.get(first: String, vararg other: String): DataFrame<T> =
select { (listOf(first) + other).toColumnSet() }

public operator fun <T> DataFrame<T>.get(columnRange: ClosedRange<String>): DataFrame<T> =
select { columnRange.start..columnRange.endInclusive }

// endregion

internal val ColumnsContainer<*>.ncol get() = columnsCount()
internal val AnyFrame.nrow get() = rowsCount()
internal val AnyFrame.indices get() = indices()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,26 @@ import org.jetbrains.kotlinx.dataframe.api.ColumnsSelectionDsl
import org.jetbrains.kotlinx.dataframe.api.pathOf
import org.jetbrains.kotlinx.dataframe.columns.ColumnPath
import org.jetbrains.kotlinx.dataframe.columns.ColumnSet
import org.jetbrains.kotlinx.dataframe.columns.SingleColumn
import org.jetbrains.kotlinx.dataframe.impl.aggregation.ConfiguredAggregateColumn

public interface ColumnsForAggregateSelectionDsl<out T> : ColumnsSelectionDsl<T> {

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

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

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> SingleColumn<C>.into(name: String): SingleColumn<C> =
ConfiguredAggregateColumn.withPath(this, pathOf(name)).single()

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()
}
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
package org.jetbrains.kotlinx.dataframe.aggregation

import org.jetbrains.kotlinx.dataframe.Selector
import org.jetbrains.kotlinx.dataframe.columns.ColumnSet
import org.jetbrains.kotlinx.dataframe.columns.ColumnsResolver

public typealias AggregateBody<T, R> = Selector<AggregateDsl<T>, R>

public typealias AggregateGroupedBody<G, R> = Selector<AggregateGroupedDsl<G>, R>

public typealias ColumnsForAggregateSelector<T, C> = Selector<ColumnsForAggregateSelectionDsl<T>, ColumnSet<C>>
public typealias ColumnsForAggregateSelector<T, C> = Selector<ColumnsForAggregateSelectionDsl<T>, ColumnsResolver<C>>
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,13 @@ import org.jetbrains.kotlinx.dataframe.columns.ColumnAccessor
import org.jetbrains.kotlinx.dataframe.columns.ColumnReference
import org.jetbrains.kotlinx.dataframe.columns.ColumnSet
import org.jetbrains.kotlinx.dataframe.columns.ColumnWithPath
import org.jetbrains.kotlinx.dataframe.columns.ColumnsResolver
import org.jetbrains.kotlinx.dataframe.columns.SingleColumn

/**
* [Predicate] is used to reach a [Boolean] result using the given instance of `T` as `it`.
* ## Predicate
*
* [Predicate] is a lambda function expecting a [Boolean] result given an instance of `T` as `it`.
*
* Shorthand for:
* ```kotlin
Expand All @@ -19,7 +22,9 @@ import org.jetbrains.kotlinx.dataframe.columns.SingleColumn
public typealias Predicate<T> = (it: T) -> Boolean

/**
* [Selector] is used to express or select any instance of `R` using the given instance of `T` as `this` and `it`.
* ## Selector
*
* [Selector] is a lambda function expecting an `R` result given an instance of `T` as context (`this` and `it`).
*
* Shorthand for:
* ```kotlin
Expand All @@ -31,8 +36,11 @@ public typealias Selector<T, R> = T.(it: T) -> R
// region selectors

/**
* [DataFrameExpression] is used to express or select any instance of `R` using the given instance of [DataFrame]`<T>`
* as `this` and `it`.
* ## DataFrame Expression
*
* [DataFrameExpression] is a lambda function expecting an `R` result given an instance of [DataFrame]`<T>` as context
* (`this` and `it`).
* `R` can be selected or expressed.
*
* Shorthand for:
* ```kotlin
Expand All @@ -42,8 +50,10 @@ public typealias Selector<T, R> = T.(it: T) -> R
public typealias DataFrameExpression<T, R> = Selector<DataFrame<T>, R>

/**
* [RowExpression] is used to express or select any instance of `R` using the given instance of [DataRow]`<T>` as
* `this` and `it`.
* ## Row Expression
*
* [RowExpression] is a lambda function expecting an `R` result given an instance of [DataRow]`<T>` as context
* (`this` and `it`). `R` can be selected or expressed.
*
* Shorthand for:
* ```kotlin
Expand All @@ -53,8 +63,10 @@ public typealias DataFrameExpression<T, R> = Selector<DataFrame<T>, R>
public typealias RowExpression<T, R> = Selector<DataRow<T>, R>

/**
* [RowValueExpression] is used to express or select any instance of `R` using the given value `it: C` and the given
* instance of [DataRow]`<T>` as `this`.
* ## Row Value Expression
*
* [RowValueExpression] is a lambda function expecting an `R` result given the value `it: C` and an
* instance of [DataRow]`<T>` as context (`this`). `R` can be selected or expressed.
*
* Shorthand for:
* ```kotlin
Expand All @@ -64,8 +76,10 @@ public typealias RowExpression<T, R> = Selector<DataRow<T>, R>
public typealias RowValueExpression<T, C, R> = DataRow<T>.(it: C) -> R

/**
* [RowColumnExpression] is used to express or select any instance of `R` using the given instances of
* [DataRow]`<T>` as `row` and [DataColumn]`<C>` as `col`.
* ## Row Column Expression
*
* [RowColumnExpression] is a lambda function expecting an `R` result given an instance of [DataRow]`<T>` as
* `row` and [DataColumn]`<C>` as `col`. `R` can be selected or expressed.
*
* Shorthand for:
* ```kotlin
Expand All @@ -75,8 +89,10 @@ public typealias RowValueExpression<T, C, R> = DataRow<T>.(it: C) -> R
public typealias RowColumnExpression<T, C, R> = (row: DataRow<T>, col: DataColumn<C>) -> R

/**
* [ColumnExpression] is used to express or select any instance of `R` using the given instance of [DataColumn]`<C>` as
* `this` and `it`.
* ## Column Expression
*
* [ColumnExpression] is a lambda function expecting an `R` result given an instance of [DataColumn]`<C>` as context
* (`this` and `it`). `R` can be selected or expressed.
*
* Shorthand for:
* ```kotlin
Expand All @@ -86,8 +102,12 @@ public typealias RowColumnExpression<T, C, R> = (row: DataRow<T>, col: DataColum
public typealias ColumnExpression<C, R> = Selector<DataColumn<C>, R>

/**
* [ColumnSelector] is used to express or select a single column, represented by [SingleColumn]`<C>`, using the
* context of [ColumnsSelectionDsl]`<T>` as `this` and `it`.
* ## Column Selector
*
* [ColumnSelector] is a lambda function expecting a [SingleColumn]<`C`> result given an instance of [ColumnsSelectionDsl]`<T>`
* as context (`this` and `it`). [SingleColumn]`<C>` can be selected or expressed.
*
* See [Columns Selection DSL][ColumnsSelectionDsl] for more information.
*
* Shorthand for:
* ```kotlin
Expand All @@ -97,22 +117,31 @@ public typealias ColumnExpression<C, R> = Selector<DataColumn<C>, R>
public typealias ColumnSelector<T, C> = Selector<ColumnsSelectionDsl<T>, SingleColumn<C>>

/**
* [ColumnsSelector] is used to express or select multiple columns, represented by [ColumnSet]`<C>`, using the
* context of [ColumnsSelectionDsl]`<T>` as `this` and `it`.
* ## Columns Selector
*
* [ColumnsSelector] is a lambda function expecting a [ColumnsResolver]<`C`> ([SingleColumn]<`C`> or [ColumnSet]<`C`>)
* result given an instance of [ColumnsSelectionDsl]`<T>` as context (`this` and `it`).
* [ColumnsResolver]<`C`> can be selected or expressed.
*
* See [Columns Selection DSL][ColumnsSelectionDsl] for more information.
*
* Shorthand for:
* ```kotlin
* ColumnsSelectionDsl<T>.(it: ColumnsSelectionDsl<T>) -> ColumnSet<C>
* ColumnsSelectionDsl<T>.(it: ColumnsSelectionDsl<T>) -> ColumnsResolver<C>
* ```
*/
public typealias ColumnsSelector<T, C> = Selector<ColumnsSelectionDsl<T>, ColumnSet<C>>
public typealias ColumnsSelector<T, C> = Selector<ColumnsSelectionDsl<T>, ColumnsResolver<C>>

// endregion

// region filters

/**
* [RowFilter] is used to filter or find rows using the given instance of [DataRow]`<T>` as `this` and `it`.
* ## Row Filter
*
* [RowFilter] is a lambda function expecting a [Boolean] result given an instance of [DataRow]`<T>` as context
* (`this` and `it`).
*
* Return `true` if the row should be included in the result.
*
* Shorthand for:
Expand All @@ -123,7 +152,11 @@ public typealias ColumnsSelector<T, C> = Selector<ColumnsSelectionDsl<T>, Column
public typealias RowFilter<T> = RowExpression<T, Boolean>

/**
* [ColumnFilter] is used to filter or find columns using the given instance of [ColumnWithPath]`<T>` as `it`.
* ## Column Filter
*
* [ColumnFilter] is a lambda function expecting a [Boolean] result given an instance of [DataColumn]`<C>` as context
* (`this` and `it`).
*
* Return `true` if the column should be included in the result.
*
* Shorthand for:
Expand All @@ -134,8 +167,11 @@ public typealias RowFilter<T> = RowExpression<T, Boolean>
public typealias ColumnFilter<T> = Predicate<ColumnWithPath<T>>

/**
* [RowValueFilter] is used to filter or find rows using the given value of `it: C` and the given instance of
* [DataRow]`<T>` as `this`.
* ## Row Value Filter
*
* [RowValueFilter] is a lambda function expecting a [Boolean] result given the value `it: C` and an instance
* of [DataRow]`<T>` as context (`this`).
*
* Return `true` if the row should be included in the result.
*
* Shorthand for:
Expand Down
Loading