Improve `inferType` documentation, KDocs, and test coverage
Los mantenedores suelen responder en 1 día
Nadie ha tomado este issue todavía.
Evaluación
- Dificultad
- 4/5
- Tiempo estimado
- 3-5 días
- Aptitud para principiantes
- 72/100
- Tipo de issue
- Documentación
- Claridad
- Bien especificado
- Estado de actividad
- Tranquilo
- Stack tecnológico
- kotlin
- Área
- documentation, testing-qa
Línea de trabajo
Comienza con core/src/main/kotlin/org/jetbrains/kotlinx/dataframe/api/inferType.kt y la prueba existente en core/src/test/kotlin/org/jetbrains/kotlinx/dataframe/api/inferType.kt; después, actualiza docs/StardustDocs/topics/inferType.md. Ejecuta las pruebas existentes de inferType antes de ampliar la cobertura para las sobrecargas y los escenarios indicados. El trabajo estará terminado cuando el sitio web y KDocs expliquen la inferencia basada en tiempo de ejecución y sus límites, y las pruebas cubran los comportamientos especificados.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
Improve inferType documentation, KDocs, and test coverage
Context
inferType is useful when a column keeps a wider type than the values currently stored in it require.
Typical cases:
- after
filter, when a column originally typed asAny?,Comparable<*>, orNumber?now contains only values of a more specific type; - after manual transformations such as
convert(...).with(Infer.None); - after reading or constructing loosely typed data where columns initially have broad types;
- before schema-sensitive operations that benefit from more precise column types, such as
colsOf<T>(),convertTo<Schema>(), typed accessors, schema checks, or serialization.
Important distinction: inferType does not parse or convert values. It only refines the column type based on already stored runtime values. For example, it may refine Any? to Int? if the values are already integers, but it will not convert "123" to Int.
Current website page:
https://kotlin.github.io/dataframe/infertype.html
Current source:
core/src/main/kotlin/org/jetbrains/kotlinx/dataframe/api/inferType.kt
Current docs source:
docs/StardustDocs/topics/inferType.md
Existing tests:
core/src/test/kotlin/org/jetbrains/kotlinx/dataframe/api/inferType.kt
Problem
The current website page is too short and does not explain when inferType is useful in real DataFrame workflows.
The public API also has little or no KDoc, even though the behavior has important nuances:
- inference is based on existing runtime values;
- the result is the nearest common supertype of the values;
- inference is constrained by the current column type upper bound via
TypeSuggestion.InferWithUpperbound(type); DataFrame.inferType()applies to non-column-group columns at any depth;inferTypeis not parsing and should be distinguished fromparseandconvert.
The existing tests cover only a narrow subset of behavior.
Acceptance Criteria
- The
inferTypewebsite page explains why the operation exists and when users should consider it. - The website clearly states that
inferTypedoes not parse or convert values. - The website includes examples for whole-DataFrame inference, selected-column inference, and post-filter type refinement.
- Public non-deprecated
inferTypefunctions have KDocs. - KDocs mention runtime-value-based inference, nearest common supertype behavior, and the current type upper bound.
- KDocs explain the default behavior of
DataFrame.inferType(). - Tests cover all non-deprecated public overloads.
- Tests cover nullable values, selected columns, whole-DataFrame inference, nested columns, and broad-to-specific type refinement.
- Tests include at least one scenario demonstrating that strings are not parsed into numbers by
inferType.
Website Recommendations
1. Add a “When to use it” section
Explain that inferType is useful when values have become more specific than the column type.
Suggested example:
val col by columnOf<Comparable<*>>("Alice", 1, 3.5)
val strings = col.filter { it is String }
strings.type() // Comparable<*>
strings.inferType().type() // String
2. Add a “What it does not do” section
Clarify that inferType does not parse or transform values.
Suggested example:
val col by columnOf<Any?>("1", "2", "3")
col.inferType().type() // String?, not Int?
For converting strings to numbers, point users to parse or convert.
3. Document whole-DataFrame behavior
Explain that:
df.inferType()
infers types for non-column-group columns at any depth.
Mention that column groups themselves are not replaced by inferred value columns.
4. Document selected-column behavior
Show both name-based and selector-based usage:
df.inferType("value")
df.inferType {
colsOf<Any?>()
}
5. Add a schema-sensitive workflow example
Show why type refinement is useful before operations that depend on column types:
val refined = df.inferType("value")
refined.select { colsOf<Int?>() }
6. Link to related operations
Add a short “See also” section:
parsefor parsing string values into typed valuesconvertfor explicit conversionconvertTo<Schema>()for schema conversion
KDoc Recommendations
Add KDocs to:
public fun AnyCol.inferType(): DataColumn<*>
public fun <T> DataFrame<T>.inferType(): DataFrame<T>
public fun <T> DataFrame<T>.inferType(columns: ColumnsSelector<T, *>): DataFrame<T>
public fun <T> DataFrame<T>.inferType(vararg columns: String): DataFrame<T>
Suggested KDoc topics:
- The operation refines column types based on already stored runtime values.
- It does not parse strings or convert values.
- The resulting type is the nearest common supertype of the current values.
- The inferred type is constrained by the current column type as an upper bound.
DataFrame.inferType()applies to all non-column-group columns at any depth.- Selected-column overloads preserve column names and positions.
- Typical use cases include post-filter narrowing, loosely typed input data, and recovery after transformations that intentionally disabled inference.
Test Scenarios
1. AnyCol.inferType() narrows after filtering
Existing scenario can stay:
val col by columnOf<Comparable<*>>("Alice", 1, 3.5)
val filtered = col.filter { it is String }
filtered.inferType().type() shouldBe typeOf<String>()
2. DataFrame.inferType("column") narrows a selected column
Create a DataFrame with two broad columns and verify that only the named column is refined.
3. DataFrame.inferType { ... } narrows selector-matched columns
Use a selector such as colsOf<Any?>() or a name predicate and verify only selected columns are affected.
4. DataFrame.inferType() applies to non-column-group columns at any depth
Create a DataFrame with a nested column group containing broad typed value columns. Verify nested value columns are refined, while the column group structure is preserved.
5. Nullable values preserve nullability
Example expectation:
val col by columnOf<Any?>(1, null, 2)
col.inferType().type() shouldBe typeOf<Int?>()
6. Mixed values infer nearest common supertype
Example:
val col by columnOf<Any?>(1, 2.0)
col.inferType().type()
Verify the expected common type according to the library’s type inference rules.
7. inferType does not parse strings
Example:
val col by columnOf<Any?>("1", "2", "3")
col.inferType().type() shouldBe typeOf<String?>()
Also verify the values remain strings.
8. Inference respects current column type upper bound
Create a column with a declared broad-but-bounded type, then ensure inference does not produce a type outside the current upper bound.
9. Post-convert(...).with(Infer.None) refinement
Existing scenario can be kept and possibly expanded:
val converted = df.convert(col).with(Infer.None) {
B(it) as A<Int>
}
converted[col].type() shouldBe typeOf<A<Int>>()
converted.inferType(col)[col].type() shouldBe typeOf<B<Int>>()
- Lenguaje dominante
- Kotlin
- Estrellas
- 1.1k
- Forks
- 87
- Merge medio
- 2 d 21 h
- PR fusionados (30 d)
- 40
Preparar el entorno
Inicia el contenedor de desarrollo del proyecto en tu navegador, con tu propia cuenta de GitHub.
- Sin Dockerfile ni archivo de Docker Compose
- Sin plantilla de pull request
- Leer la guía de contribución
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Más de Kotlin/dataframe
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 68/100
Los mantenedores suelen responder en 1 día
-
Add `columnOf(vararg DataFrame<T: DataRowSchema>): FrameColumn<T>` overload for compatibilityAbiertoAPI
Dificultad 2/5 1-3 horas Aptitud para principiantes 66/100
Kotlin/dataframe#2202 · 3 comentarios · 1 reacción ·
Los mantenedores suelen responder en 1 día
-
documentation
Dificultad 2/5 1-3 horas Aptitud para principiantes 72/100
Kotlin/dataframe#2195 · 2 comentarios · 1 reacción ·
Los mantenedores suelen responder en 1 día
-
AX
Dificultad 1/5 Menos de una hora Aptitud para principiantes 90/100
Los mantenedores suelen responder en 1 día
-
Add minimal KDocs for `print` APIsPosiblemente ocupada @zaleslaw la tomó hace 4 días. AbiertoKDocs
Dificultad 2/5 1-3 horas Aptitud para principiantes 88/100
Los mantenedores suelen responder en 1 día
Todos los issues de Kotlin/dataframe
Issues similares
-
feat: 清理.git残留锁文件AUTO_MERGE.lockAbierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 65/100
-
Android: update ServiceControllerImpl comment and naming after Reports paused got its own idAbierto
Dificultad 1/5 Menos de una hora Aptitud para principiantes 90/100
OneBusAway/vehicle-positions#288 ·
Los mantenedores suelen responder en 1 día
-
Labor 09 - CSS: fájlnevekAbierto
Dificultad 1/5 Menos de una hora Aptitud para principiantes 90/100
-
[New Rule]zstd-kmpAbierto
Dificultad 1/5 1-3 horas Aptitud para principiantes 82/100
LibChecker/LibChecker-Rules#1456 ·
-
支持iOS 15.1及以上的系统Abierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 73/100
Los mantenedores suelen responder en 1 día