package com.octaldata.domain.structure

import io.kotest.core.spec.style.FunSpec
import io.kotest.matchers.shouldBe

class FlattenSchemaTest : FunSpec() {
   init {

      test("flatten top level fields") {
         val schema: Schema.Struct = Schema.Struct(
            null,
            Schema.Field("a", Schema.Utf8),
            Schema.Field("b", Schema.Int32),
         )
         schema.flatten() shouldBe listOf("a", "b")
      }

      test("flatten should drop branch fields") {
         val schema = Schema.Struct(
            null,
            Schema.Field("a", Schema.Utf8),
            Schema.Field(
               "b",
               Schema.Struct(
                  null,
                  Schema.Field("c", Schema.Utf8),
                  Schema.Field("d", Schema.Bool),
               )
            ),
         )
         schema.flatten() shouldBe listOf("a", "b.c", "b.d")
      }
   }
}