Skip to content

Commit

Permalink
more test for boolean expression & fuzzer
Browse files Browse the repository at this point in the history
  • Loading branch information
3cham committed May 12, 2024
1 parent 49279df commit 2ca0ea6
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 1 deletion.
2 changes: 1 addition & 1 deletion fuzzer/src/main/kotlin/Fuzzer.kt
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ class Fuzzer {
return createRecordBatch(schema, columns)
}

private fun createRecordBatch(schema: Schema, column: List<List<Any?>>): RecordBatch {
fun createRecordBatch(schema: Schema, column: List<List<Any?>>): RecordBatch {
val arrowVectors = schema.fields.withIndex().map { field ->
val fv = FieldVectorFactory.create(field.value.dataType, column[field.index].size)

Expand Down
26 changes: 26 additions & 0 deletions physical-plan/src/test/kotlin/BooleanExpressionTest.kt
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import io.hqew.kquery.datatypes.Field
import io.hqew.kquery.datatypes.Schema
import io.hqew.kquery.fuzzer.Fuzzer
import io.hqew.kquery.physical.expressions.ColumnExpression
import io.hqew.kquery.physical.expressions.EqExpression
import io.hqew.kquery.physical.expressions.LtEqExpression
import org.junit.Test
import org.junit.jupiter.api.TestInstance
Expand Down Expand Up @@ -30,4 +31,29 @@ class BooleanExpressionTest {
assertEquals(expected, lteq.getValue(it))
}
}

@Test
fun `test EqExpression with string`() {
val schema = Schema(listOf(
Field("0", ArrowTypes.StringType),
Field("1", ArrowTypes.StringType)
))

val l = ColumnExpression(0)
val r = ColumnExpression(1)

val values = listOf(
listOf("aaa", "bbb", "ccc"),
listOf("aaa", "bbb", "ccd")
)

val input = Fuzzer().createRecordBatch(schema, values)

val eq = EqExpression(l, r).evaluate(input)

(0 until eq.size()).forEach {
val expected = input.fields[0].getValue(it) == input.fields[1].getValue(it)
assertEquals(expected, eq.getValue(it))
}
}
}

0 comments on commit 2ca0ea6

Please sign in to comment.