티스토리 뷰

728x90
    @Test
    fun toNull() {
        // given
        data class Person(
            val name: String?,
            val job: String?,
            val age: Int
        )

        val spark = SparkUtil.make()

        val data = spark.createDataFrame(
            mutableListOf(
                Person("null", "a", 25),
                Person("Bob", "null", 30),
                Person("null", "null", 35)
            ), Person::class.java
        ).toDF()

        val expected = spark.createDataFrame(
            mutableListOf(
                Person(null, "a", 25),
                Person("Bob", null, 30),
                Person(null, null, 35)
            ), Person::class.java
        ).toDF()

        // when
        val actual = JobUtil.toNull(data)
        val diff = expected.except(actual).count()

        // then
        Assertions.assertEquals(diff, 0)
    }
728x90
댓글