Skip to content

Commit

Permalink
Prepare release v0.2.1 (#250)
Browse files Browse the repository at this point in the history
* Respect ProjectionIterationBehavior.UNFILTERED within star projection (#247)

Fixes #246

* Prepare release 0.2.1

Co-authored-by: David Lurton <dlurton@users.noreply.github.com>
  • Loading branch information
therapon and dlurton authored Jun 9, 2020
1 parent 8d84c92 commit f629c6f
Show file tree
Hide file tree
Showing 5 changed files with 64 additions and 4 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ This project is published to [Maven Central](https://search.maven.org/artifact/o

| Group ID | Artifact ID | Recommended Version |
|----------|-------------|---------------------|
| `org.partiql` | `partiql-lang-kotlin` | `0.2.0`
| `org.partiql` | `partiql-lang-kotlin` | `0.2.1`


For Maven builds, add this to your `pom.xml`:
Expand Down
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ allprojects {

subprojects {
group = 'org.partiql'
version = '0.2.0'
version = '0.2.1'
}

buildDir = new File(rootProject.projectDir, "gradle-build/" + project.name)
Expand Down
9 changes: 7 additions & 2 deletions lang/src/org/partiql/lang/eval/EvaluatingCompiler.kt
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ import org.partiql.lang.ast.passes.*
import org.partiql.lang.errors.*
import org.partiql.lang.eval.binding.*
import org.partiql.lang.syntax.SqlParser
import org.partiql.lang.syntax.*
import org.partiql.lang.util.*
import java.math.*
import java.util.*
Expand Down Expand Up @@ -1088,7 +1087,13 @@ internal class EvaluatingCompiler(
val name = syntheticColumnName(columns.size).exprValue()
columns.add(value.namedValue(name))
} else {
for (childValue in value.filter { it.type != ExprValueType.MISSING }) {
val valuesToProject = when(compileOptions.projectionIteration) {
ProjectionIterationBehavior.FILTER_MISSING -> {
value.filter { it.type != ExprValueType.MISSING }
}
ProjectionIterationBehavior.UNFILTERED -> value
}
for (childValue in valuesToProject) {
val namedFacet = childValue.asFacet(Named::class.java)
val name = namedFacet?.name
?: syntheticColumnName(columns.size).exprValue()
Expand Down
22 changes: 22 additions & 0 deletions lang/test/org/partiql/lang/eval/EvaluatingCompilerTests.kt
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,10 @@

package org.partiql.lang.eval

import com.amazon.ion.system.IonSystemBuilder
import org.junit.Ignore
import org.junit.Test
import org.partiql.lang.CompilerPipeline
import org.partiql.lang.syntax.ParserException

class EvaluatingCompilerTests : EvaluatorTestBase() {
Expand Down Expand Up @@ -1491,6 +1493,26 @@ class EvaluatingCompilerTests : EvaluatorTestBase() {
assertEquals("100, MISSING, 200", actual.iterator().asSequence().joinToString(separator = ", "))
}

@Test
fun projectionIterationBehaviorUnfiltered_select_list() =
assertEvalExprValue(
source = "select a from <<{'a': MISSING}>>",
expected = "<<{'a': MISSING}>>",
compileOptions = CompileOptions.build {
projectionIteration(ProjectionIterationBehavior.UNFILTERED)
}
)

@Test
fun projectionIterationBehaviorUnfiltered_select_star() =
assertEvalExprValue(
source = "select * from <<{'a': MISSING}>>",
expected = "<<{'a': MISSING}>>",
compileOptions = CompileOptions.build {
projectionIteration(ProjectionIterationBehavior.UNFILTERED)
}
)

@Test
fun undefinedQualifiedVariableWithUndefinedVariableBehaviorError() {
// Demonstrates that UndefinedVariableBehavior.ERROR does not affect qualified field names.
Expand Down
33 changes: 33 additions & 0 deletions lang/test/org/partiql/lang/eval/EvaluatorTestBase.kt
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,14 @@ abstract class EvaluatorTestBase : TestBase() {
assertRewrite(source, originalExprNode)
}

protected fun assertExprEquals(expected: ExprValue, actual: ExprValue) {
if(!expected.exprEquals(actual)) {
println("Expected ionValue: ${ConfigurableExprValueFormatter.pretty.format(expected)} ")
println("Actual ionValue : ${ConfigurableExprValueFormatter.pretty.format(actual)} ")
fail("Expected and actual ExprValue instances are not equivalent")
}
}

protected fun assertExprEquals(expected: ExprValue, actual: ExprValue, message: String) {
if(!expected.exprEquals(actual)) {
println(message)
Expand All @@ -145,6 +153,31 @@ abstract class EvaluatorTestBase : TestBase() {
fail("Expected and actual ExprValue instances are not equivalent")
}
}
/**
* Evaluates [expected] and [source] and asserts that the resulting [ExprValue]s
* are equivalent using PartiQL's equivalence rules. This differs from `assertEval`
* in that the [ExprValue]s are not converted to Ion before comparison.
* This function should be used for any result involving `BAG` and `MISSING`
* since Ion has no representation for these values.
*
* @param source query source to be tested
* @param expected expected result
* @param session [EvaluationSession] used for evaluation
* @param block function literal with receiver used to plug in custom assertions
*/
protected fun assertEvalExprValue(source: String,
expected: String,
session: EvaluationSession = EvaluationSession.standard(),
compileOptions: CompileOptions = CompileOptions.standard()) {
val parser = SqlParser(ion)
val originalExprNode = parser.parseExprNode(source)
val expectedExprNode = parser.parseExprNode(expected)

val originalExprValue = eval(originalExprNode, compileOptions, session)
val expectedExprValue = eval(expectedExprNode, compileOptions, session)
assertExprEquals(expectedExprValue, originalExprValue)
}



/**
Expand Down

0 comments on commit f629c6f

Please sign in to comment.