Skip to content

Commit e0aa6fd

Browse files
committed
Merge branch 'master' into kdocs-gh-action-2
2 parents 5389900 + 76091c7 commit e0aa6fd

File tree

349 files changed

+55505
-1005
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

349 files changed

+55505
-1005
lines changed

build.gradle.kts

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import com.github.benmanes.gradle.versions.updates.DependencyUpdatesTask
2+
import org.jetbrains.kotlin.gradle.dsl.KotlinJvmProjectExtension
23
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
34
import org.jetbrains.kotlinx.dataframe.AnyFrame
45
import org.jetbrains.kotlinx.dataframe.DataFrame
@@ -14,7 +15,7 @@ plugins {
1415
with(libs.plugins) {
1516
alias(kotlin.jvm)
1617
alias(publisher)
17-
alias(serialization)
18+
alias(serialization) apply false
1819
alias(jupyter.api) apply false
1920
alias(dokka)
2021
alias(kover)
@@ -52,11 +53,11 @@ dependencies {
5253
api(project(":dataframe-jdbc"))
5354
}
5455

55-
private enum class Version : Comparable<Version> {
56+
enum class Version : Comparable<Version> {
5657
SNAPSHOT, DEV, ALPHA, BETA, RC, STABLE;
5758
}
5859

59-
private fun String.findVersion(): Version {
60+
fun String.findVersion(): Version {
6061
val version = this.lowercase()
6162
return when {
6263
"snapshot" in version -> Version.SNAPSHOT
@@ -70,8 +71,6 @@ private fun String.findVersion(): Version {
7071

7172
// these names of outdated dependencies will not show up in the table output
7273
val dependencyUpdateExclusions = listOf(
73-
// 5.6 requires Java 11
74-
libs.klaxon.get().name,
7574
// TODO Requires more work to be updated to 1.7.0+, https://github.com/Kotlin/dataframe/issues/594
7675
libs.plugins.kover.get().pluginId,
7776
// TODO Updating requires major changes all across the project, https://github.com/Kotlin/dataframe/issues/364
@@ -124,6 +123,8 @@ tasks.named<DependencyUpdatesTask>("dependencyUpdates").configure {
124123
}
125124
}
126125

126+
kotlin.jvmToolchain(11)
127+
127128
allprojects {
128129
tasks.withType<KotlinCompile> {
129130
kotlinOptions {
@@ -160,6 +161,9 @@ allprojects {
160161
} catch (_: UnknownDomainObjectException) {
161162
logger.warn("Could not set kotlinter config on :${this.name}")
162163
}
164+
165+
// set the java toolchain version to 11 for all subprojects for CI stability
166+
extensions.findByType<KotlinJvmProjectExtension>()?.jvmToolchain(11)
163167
}
164168
}
165169

core/build.gradle.kts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,9 @@ dependencies {
6666
implementation(libs.kotlin.stdlib.jdk8)
6767

6868
api(libs.commonsCsv)
69-
implementation(libs.klaxon)
69+
implementation(libs.serialization.core)
70+
implementation(libs.serialization.json)
71+
7072
implementation(libs.fuel)
7173

7274
api(libs.kotlin.datetimeJvm)

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

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

33
import org.jetbrains.kotlinx.dataframe.aggregation.Aggregatable
44
import org.jetbrains.kotlinx.dataframe.aggregation.AggregateGroupedBody
5+
import org.jetbrains.kotlinx.dataframe.annotations.HasSchema
56
import org.jetbrains.kotlinx.dataframe.api.ColumnsSelectionDsl
67
import org.jetbrains.kotlinx.dataframe.api.add
78
import org.jetbrains.kotlinx.dataframe.api.cast
@@ -29,6 +30,7 @@ import kotlin.reflect.KType
2930
*
3031
* @param T Schema marker. It identifies column schema and is used to generate schema-specific extension properties for typed data access. It is covariant, so `DataFrame<A>` is assignable to variable of type `DataFrame<B>` if `A` is a subtype of `B`.
3132
*/
33+
@HasSchema(schemaArg = 0)
3234
public interface DataFrame<out T> : Aggregatable<T>, ColumnsContainer<T> {
3335

3436
public companion object {

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

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,17 @@ public interface DataRow<out T> {
4343
return value as AnyRow
4444
}
4545

46+
public fun getFrameColumn(columnName: String): AnyFrame {
47+
val value = get(columnName)
48+
if (value == null) {
49+
val kind = df()[columnName].kind()
50+
if (kind != ColumnKind.Frame) {
51+
error("Cannot cast null value of a $kind to a ${DataFrame::class}")
52+
}
53+
}
54+
return value as AnyFrame
55+
}
56+
4657
public fun getOrNull(name: String): Any?
4758
public fun <R> getValueOrNull(column: ColumnReference<R>): R?
4859

core/generated-sources/src/main/kotlin/org/jetbrains/kotlinx/dataframe/aggregation/AggregateDsl.kt

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

33
import org.jetbrains.kotlinx.dataframe.DataFrame
4+
import org.jetbrains.kotlinx.dataframe.annotations.Interpretable
45
import org.jetbrains.kotlinx.dataframe.api.ColumnSelectionDsl
56
import org.jetbrains.kotlinx.dataframe.api.pathOf
67
import org.jetbrains.kotlinx.dataframe.columns.ColumnAccessor
@@ -12,6 +13,7 @@ import kotlin.reflect.typeOf
1213

1314
public abstract class AggregateDsl<out T> : DataFrame<T>, ColumnSelectionDsl<T> {
1415

16+
@Interpretable("GroupByInto")
1517
public inline infix fun <reified R> R.into(name: String): NamedValue = internal().yield(pathOf(name), this, typeOf<R>())
1618

1719
public inline infix fun <reified R> R.into(column: ColumnAccessor<R>): NamedValue = internal().yield(pathOf(column.name()), this, typeOf<R>())
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
package org.jetbrains.kotlinx.dataframe.annotations
2+
3+
@Target(AnnotationTarget.CLASS)
4+
public annotation class HasSchema(val schemaArg: Int)
5+
6+
/**
7+
* Compiler plugin will evaluate compile time value of the annotated function.
8+
* Needed because some function calls only serve as a part of overall compile time DataSchema evaluation
9+
* There's no need to update return type of such calls
10+
*/
11+
internal annotation class Interpretable(val interpreter: String)
12+
13+
/**
14+
* Compiler plugin will replace return type of calls to the annotated function
15+
*/
16+
internal annotation class Refine
17+
18+
internal annotation class OptInRefine
19+
20+
@Retention(AnnotationRetention.SOURCE)
21+
@Target(AnnotationTarget.FILE, AnnotationTarget.EXPRESSION)
22+
public annotation class DisableInterpretation
23+
24+
@Retention(AnnotationRetention.SOURCE)
25+
@Target(AnnotationTarget.EXPRESSION)
26+
public annotation class Import
27+
28+
@Target(AnnotationTarget.PROPERTY)
29+
public annotation class Order(val order: Int)
30+
31+
@Target(AnnotationTarget.FUNCTION)
32+
internal annotation class Check

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ public interface ColumnsSelectionDsl<out T> : /* SingleColumn<DataRow<T>> */
123123
// except(), allExcept {}, allColsExcept {}
124124
AllExceptColumnsSelectionDsl,
125125

126-
// nameContains(""), colsNameContains(""), nameStartsWith(""), childrenNameEndsWith("")
126+
// nameContains(""), colsNameContains(""), nameStartsWith(""), colsNameEndsWith("")
127127
ColumnNameFiltersColumnsSelectionDsl,
128128
// withoutNulls(), colsWithoutNulls()
129129
WithoutNullsColumnsSelectionDsl,
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
package org.jetbrains.kotlinx.dataframe.api
2+
3+
import org.jetbrains.kotlinx.dataframe.DataFrame
4+
5+
public interface DataRowSchema
6+
7+
public inline fun <reified T : DataRowSchema> dataFrameOf(vararg rows: T): DataFrame<T> =
8+
rows.asIterable().toDataFrame()
9+
10+
public inline fun <reified T : DataRowSchema> DataFrame<T>.append(vararg rows: T): DataFrame<T> =
11+
concat(dataFrameOf(*rows))

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
package org.jetbrains.kotlinx.dataframe.api
22

33
import org.jetbrains.kotlinx.dataframe.*
4+
import org.jetbrains.kotlinx.dataframe.annotations.Interpretable
5+
import org.jetbrains.kotlinx.dataframe.annotations.Refine
46
import org.jetbrains.kotlinx.dataframe.api.Update.UpdateOperationArg
57
import org.jetbrains.kotlinx.dataframe.columns.ColumnKind
68
import org.jetbrains.kotlinx.dataframe.columns.ColumnReference
@@ -918,6 +920,8 @@ public fun <T, C> DataFrame<T>.fillNA(vararg columns: ColumnReference<C>): Updat
918920
* If `false`, rows are dropped if any of the selected cells is `null`.
919921
* @param columns The [Columns Selector][org.jetbrains.kotlinx.dataframe.ColumnsSelector] used to select the columns of this [DataFrame][org.jetbrains.kotlinx.dataframe.DataFrame] to drop rows in.
920922
*/
923+
@Refine
924+
@Interpretable("DropNulls0")
921925
public fun <T> DataFrame<T>.dropNulls(whereAllNull: Boolean = false, columns: ColumnsSelector<T, *>): DataFrame<T> {
922926
val cols = this[columns]
923927
return if (whereAllNull) drop { row -> cols.all { col -> col[row] == null } }

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

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@ import org.jetbrains.kotlinx.dataframe.DataFrame
1212
import org.jetbrains.kotlinx.dataframe.DataRow
1313
import org.jetbrains.kotlinx.dataframe.RowExpression
1414
import org.jetbrains.kotlinx.dataframe.Selector
15+
import org.jetbrains.kotlinx.dataframe.annotations.Interpretable
16+
import org.jetbrains.kotlinx.dataframe.annotations.Refine
1517
import org.jetbrains.kotlinx.dataframe.columns.BaseColumn
1618
import org.jetbrains.kotlinx.dataframe.columns.ColumnAccessor
1719
import org.jetbrains.kotlinx.dataframe.columns.ColumnPath
@@ -121,6 +123,8 @@ public typealias AddExpression<T, R> = Selector<AddDataRow<T>, R>
121123
* @return new [DataFrame] with added column
122124
* @throws DuplicateColumnNamesException if [DataFrame] already contains a column with given [name]
123125
*/
126+
@Refine
127+
@Interpretable("Add")
124128
public inline fun <reified R, T> DataFrame<T>.add(
125129
name: String,
126130
infer: Infer = Infer.Nulls,
@@ -178,7 +182,10 @@ public class AddDsl<T>(@PublishedApi internal val df: DataFrame<T>) : ColumnsCon
178182
return df.mapToColumn("", infer, expression)
179183
}
180184

181-
public inline infix fun <reified R> String.from(noinline expression: RowExpression<T, R>): Boolean =
185+
@Interpretable("From")
186+
public inline infix fun <reified R> String.from(
187+
noinline expression: RowExpression<T, R>
188+
): Boolean =
182189
add(this, Infer.Nulls, expression)
183190

184191
// TODO: use path instead of name
@@ -192,6 +199,7 @@ public class AddDsl<T>(@PublishedApi internal val df: DataFrame<T>) : ColumnsCon
192199
public inline infix fun <reified R> ColumnAccessor<R>.from(column: ColumnReference<R>): Boolean = name() from column
193200
public inline infix fun <reified R> KProperty<R>.from(column: ColumnReference<R>): Boolean = name from column
194201

202+
@Interpretable("Into")
195203
public infix fun AnyColumnReference.into(name: String): Boolean = add(rename(name))
196204
public infix fun <R> ColumnReference<R>.into(column: ColumnAccessor<R>): Boolean = into(column.name())
197205
public infix fun <R> ColumnReference<R>.into(column: KProperty<R>): Boolean = into(column.name)
@@ -212,6 +220,8 @@ public class AddDsl<T>(@PublishedApi internal val df: DataFrame<T>) : ColumnsCon
212220
public infix fun AddGroup<T>.into(column: AnyColumnGroupAccessor): Unit = into(column.name())
213221
}
214222

223+
@Refine
224+
@Interpretable("AddWithDsl")
215225
public fun <T> DataFrame<T>.add(body: AddDsl<T>.() -> Unit): DataFrame<T> {
216226
val dsl = AddDsl(this)
217227
body(dsl)

0 commit comments

Comments
 (0)