Skip to content

Commit

Permalink
Fix QbeastStats serialization/deserialization tests
Browse files Browse the repository at this point in the history
  • Loading branch information
JosepSampe committed Oct 11, 2024
1 parent 0186ea1 commit 11b2290
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 18 deletions.
17 changes: 0 additions & 17 deletions src/test/scala/io/qbeast/QbeastIntegrationTestSpec.scala
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,6 @@
*/
package io.qbeast

import com.fasterxml.jackson.databind.JsonNode
import com.fasterxml.jackson.databind.ObjectMapper
import com.github.mrpowers.spark.fast.tests.DatasetComparer
import io.qbeast.context.QbeastContext
import io.qbeast.context.QbeastContextImpl
Expand Down Expand Up @@ -217,19 +215,4 @@ trait QbeastIntegrationTestSpec extends AnyFlatSpec with Matchers with DatasetCo
QbeastContext.metadataManager.loadSnapshot(tableId)
}

def areJsonEqual(json1: String, json2: String): Boolean = {
val basicMapper = new ObjectMapper()

try {
val node1: JsonNode = basicMapper.readTree(json1)
val node2: JsonNode = basicMapper.readTree(json2)

node1.equals(node2)
} catch {
case e: Exception =>
println(s"Error parsing JSON: ${e.getMessage}")
false
}
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
*/
package io.qbeast.spark.delta

import com.fasterxml.jackson.databind.JsonNode
import com.fasterxml.jackson.databind.ObjectMapper
import io.delta.tables._
import io.qbeast.QbeastIntegrationTestSpec
import org.apache.spark.sql.delta.DeltaLog
Expand All @@ -31,6 +33,21 @@ class QbeastDeltaIntegrationTest extends QbeastIntegrationTestSpec {
Seq(("A", 1), ("B", 2), ("C", 3)).toDF("a", "b")
}

def areJsonEqual(json1: String, json2: String): Boolean = {
val basicMapper = new ObjectMapper()

try {
val node1: JsonNode = basicMapper.readTree(json1)
val node2: JsonNode = basicMapper.readTree(json2)

node1.equals(node2)
} catch {
case e: Exception =>
println(s"Error parsing JSON: ${e.getMessage}")
false
}
}

"Qbeast" should "output correctly Operation Metrics in Delta History" in
withQbeastContextSparkAndTmpDir((spark, tmpDir) => {

Expand Down Expand Up @@ -69,7 +86,6 @@ class QbeastDeltaIntegrationTest extends QbeastIntegrationTestSpec {
|"maxValues":{"a":"C","b":3},
|"nullCount":{"a":0,"b":0}}""".stripMargin


areJsonEqual(stats.head, expectedStats) shouldBe true
})

Expand Down

0 comments on commit 11b2290

Please sign in to comment.