|
1 | 1 | import io.kotest.assertions.throwables.shouldThrow
|
2 | 2 | import io.kotest.matchers.shouldBe
|
3 | 3 | import org.apache.arrow.vector.util.Text
|
| 4 | +import org.jetbrains.kotlinx.dataframe.DataColumn |
4 | 5 | import org.jetbrains.kotlinx.dataframe.DataFrame
|
5 | 6 | import org.jetbrains.kotlinx.dataframe.api.NullabilityOptions
|
6 | 7 | import org.jetbrains.kotlinx.dataframe.api.columnOf
|
7 | 8 | import org.jetbrains.kotlinx.dataframe.api.dataFrameOf
|
8 | 9 | import org.jetbrains.kotlinx.dataframe.api.toColumn
|
| 10 | +import org.jetbrains.kotlinx.dataframe.io.arrowWriter |
9 | 11 | import org.jetbrains.kotlinx.dataframe.io.readArrowFeather
|
10 | 12 | import org.jetbrains.kotlinx.dataframe.io.readArrowIPC
|
11 | 13 | import org.junit.Test
|
| 14 | +import java.io.File |
12 | 15 | import java.net.URL
|
| 16 | +import java.time.LocalDate |
13 | 17 |
|
14 | 18 | internal class ArrowKtTest {
|
15 | 19 |
|
@@ -87,4 +91,58 @@ internal class ArrowKtTest {
|
87 | 91 | assertEstimations(DataFrame.readArrowFeather(testArrowFeather("test-illegal.arrow"), NullabilityOptions.Widening), true, true)
|
88 | 92 | assertEstimations(DataFrame.readArrowIPC(testArrowIPC("test-illegal.arrow"), NullabilityOptions.Widening), true, true)
|
89 | 93 | }
|
| 94 | + |
| 95 | + val cities = dataFrameOf( |
| 96 | + DataColumn.createValueColumn("name", listOf( |
| 97 | + "Berlin", |
| 98 | + "Hamburg", |
| 99 | + "New York", |
| 100 | + "Washington", |
| 101 | + "Saint Petersburg" |
| 102 | + )), |
| 103 | + DataColumn.createValueColumn("affiliation", listOf( |
| 104 | + "Germany", |
| 105 | + "Germany", |
| 106 | + "The USA", |
| 107 | + "The USA", |
| 108 | + "Russia" |
| 109 | + )), |
| 110 | + DataColumn.createValueColumn("is_capital", listOf( |
| 111 | + true, |
| 112 | + false, |
| 113 | + false, |
| 114 | + true, |
| 115 | + false |
| 116 | + )), |
| 117 | + DataColumn.createValueColumn("population", listOf( |
| 118 | + 3_769_495, |
| 119 | + 1_845_229, |
| 120 | + 8_467_513, |
| 121 | + 689_545, |
| 122 | + 5_377_503 |
| 123 | + )), |
| 124 | + DataColumn.createValueColumn("area", listOf( |
| 125 | + 891.7, |
| 126 | + 755.22, |
| 127 | + 1223.59, |
| 128 | + 177.0, |
| 129 | + 1439.0 |
| 130 | + )), |
| 131 | +// DataColumn.createValueColumn("settled", listOf( |
| 132 | +// LocalDate.of(1237, 1, 1), |
| 133 | +// LocalDate.of(1189, 5, 7), |
| 134 | +// LocalDate.of(1624, 1, 1), |
| 135 | +// LocalDate.of(1790, 7, 16), |
| 136 | +// LocalDate.of(1703, 5, 27) |
| 137 | +// )) |
| 138 | + ) |
| 139 | + |
| 140 | + @Test |
| 141 | + fun testWritingGeneral() { |
| 142 | + val testFile = File.createTempFile("cities", "arrow") |
| 143 | + cities.arrowWriter().writeArrowFeather(testFile) |
| 144 | + DataFrame.readArrowFeather(testFile).shouldBe(cities) |
| 145 | + } |
| 146 | + |
| 147 | + |
90 | 148 | }
|
0 commit comments