Skip to content

Commit aa0e570

Browse files
committed
Update documentation for 0.12.1
1 parent fe29f9c commit aa0e570

File tree

4 files changed

+27
-16
lines changed

4 files changed

+27
-16
lines changed

docs/StardustDocs/topics/gradleReference.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,8 @@ dataframes {
153153
}
154154
```
155155

156+
Find full example code [here](https://github.com/zaleslaw/KotlinDataFrame-SQL-Examples/blob/master/src/main/kotlin/Example_3_Import_schema_via_Gradle.kt).
157+
156158
**NOTE:** This is an experimental functionality and, for now,
157159
we only support four databases: MariaDB, MySQL, PostgreSQL, and SQLite.
158160

docs/StardustDocs/topics/read.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,9 @@
33

44
The Kotlin DataFrame library supports CSV, TSV, JSON, XLS and XLSX, and Apache Arrow input formats.
55

6-
The reading from SQL databases is also supported. Read [here](readSqlDatabases.md) to know more.
6+
The reading from SQL databases is also supported.
7+
Read [here](readSqlDatabases.md) to know more
8+
or explore the [example project](https://github.com/zaleslaw/KotlinDataFrame-SQL-Examples).
79

810
The `.read()` function automatically detects the input format based on a file extension and content:
911

docs/StardustDocs/topics/readSqlDatabases.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,9 @@ val df = DataFrame.readSqlTable(dbConfig, tableName, 100)
8080

8181
df.print()
8282
```
83+
84+
Find full example project [here](https://github.com/zaleslaw/KotlinDataFrame-SQL-Examples/).
85+
8386
## Getting Started with Notebooks
8487

8588
To use the latest version of the Kotlin DataFrame library
@@ -92,6 +95,8 @@ USE {
9295
dependencies("org.mariadb.jdbc:mariadb-java-client:$version")
9396
}
9497
```
98+
99+
Find full example Notebook [here](https://github.com/zaleslaw/KotlinDataFrame-SQL-Examples/blob/master/notebooks/imdb.ipynb).
95100

96101
**NOTE:** The user should specify the version of the JDBC driver.
97102

docs/StardustDocs/topics/schemasImportSqlGradle.md

Lines changed: 17 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,12 @@ as the first parameter of the annotation `@file:ImportDataSchema`.
2020

2121
```kotlin
2222
@file:ImportDataSchema(
23-
"ActorSchema",
23+
"Directors",
2424
URL,
25-
jdbcOptions = JdbcOptions(USER_NAME, PASSWORD, tableName = TABLE_NAME)
25+
jdbcOptions = JdbcOptions(USER_NAME, PASSWORD, tableName = TABLE_NAME_DIRECTORS)
2626
)
2727

28-
package databases
28+
package org.jetbrains.kotlinx.dataframe.examples.jdbc
2929

3030
import org.jetbrains.kotlinx.dataframe.annotations.ImportDataSchema
3131
```
@@ -37,7 +37,7 @@ const val USER_NAME = "root"
3737

3838
const val PASSWORD = "pass"
3939

40-
const val TABLE_NAME = "actors"
40+
const val TABLE_NAME_DIRECTORS = "directors"
4141
```
4242
To generate schema for the result of an SQL query,
4343
you need to define the SQL query itself
@@ -48,12 +48,12 @@ as a first parameter of annotation `@file:ImportDataSchema`.
4848

4949
```kotlin
5050
@file:ImportDataSchema(
51-
"TarantinoFilmSchema",
51+
"NewActors",
5252
URL,
53-
jdbcOptions = JdbcOptions(USER_NAME, PASSWORD, sqlQuery = TARANTINO_FILMS_SQL_QUERY)
53+
jdbcOptions = JdbcOptions(USER_NAME, PASSWORD, sqlQuery = ACTORS_IN_LATEST_MOVIES)
5454
)
5555

56-
package databases
56+
package org.jetbrains.kotlinx.dataframe.examples.jdbc
5757

5858
import org.jetbrains.kotlinx.dataframe.annotations.ImportDataSchema
5959
```
@@ -65,17 +65,17 @@ const val USER_NAME = "root"
6565

6666
const val PASSWORD = "pass"
6767

68-
const val TARANTINO_FILMS_SQL_QUERY = """
69-
SELECT name, year, rank,
70-
GROUP_CONCAT (genre) as "genres"
71-
FROM movies JOIN movies_directors ON movie_id = movies.id
72-
JOIN directors ON directors.id=director_id LEFT JOIN movies_genres ON movies.id = movies_genres.movie_id
73-
WHERE directors.first_name = "Quentin" AND directors.last_name = "Tarantino"
74-
GROUP BY name, year, rank
75-
ORDER BY year
68+
const val ACTORS_IN_LATEST_MOVIES = """
69+
SELECT a.first_name, a.last_name, r.role, m.name AS movie_name, m.year
70+
FROM actors a
71+
INNER JOIN roles r ON a.id = r.actor_id
72+
INNER JOIN movies m ON m.id = r.movie_id
73+
WHERE m.year > 2000
7674
"""
7775
```
7876

77+
Find full example code [here](https://github.com/zaleslaw/KotlinDataFrame-SQL-Examples/blob/master/src/main/kotlin/Example_2_Import_schema_annotation.kt).
78+
7979
### With Gradle Task
8080

8181
To generate a schema for an existing SQL table,
@@ -124,6 +124,8 @@ dataframes {
124124
}
125125
```
126126

127+
Find full example code [here](https://github.com/zaleslaw/KotlinDataFrame-SQL-Examples/blob/master/src/main/kotlin/Example_3_Import_schema_via_Gradle.kt).
128+
127129
After importing the data schema, you can start to import any data from SQL table or as a result of an SQL query
128130
you like using the generated schemas.
129131

0 commit comments

Comments
 (0)