Skip to content

Commit f629c6f

Browse files
therapondlurton
andauthored
Prepare release v0.2.1 (#250)
* Respect ProjectionIterationBehavior.UNFILTERED within star projection (#247) Fixes #246 * Prepare release 0.2.1 Co-authored-by: David Lurton <[email protected]>
1 parent 8d84c92 commit f629c6f

File tree

5 files changed

+64
-4
lines changed

5 files changed

+64
-4
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ This project is published to [Maven Central](https://search.maven.org/artifact/o
3131

3232
| Group ID | Artifact ID | Recommended Version |
3333
|----------|-------------|---------------------|
34-
| `org.partiql` | `partiql-lang-kotlin` | `0.2.0`
34+
| `org.partiql` | `partiql-lang-kotlin` | `0.2.1`
3535

3636

3737
For Maven builds, add this to your `pom.xml`:

build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ allprojects {
3737

3838
subprojects {
3939
group = 'org.partiql'
40-
version = '0.2.0'
40+
version = '0.2.1'
4141
}
4242

4343
buildDir = new File(rootProject.projectDir, "gradle-build/" + project.name)

lang/src/org/partiql/lang/eval/EvaluatingCompiler.kt

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ import org.partiql.lang.ast.passes.*
2121
import org.partiql.lang.errors.*
2222
import org.partiql.lang.eval.binding.*
2323
import org.partiql.lang.syntax.SqlParser
24-
import org.partiql.lang.syntax.*
2524
import org.partiql.lang.util.*
2625
import java.math.*
2726
import java.util.*
@@ -1088,7 +1087,13 @@ internal class EvaluatingCompiler(
10881087
val name = syntheticColumnName(columns.size).exprValue()
10891088
columns.add(value.namedValue(name))
10901089
} else {
1091-
for (childValue in value.filter { it.type != ExprValueType.MISSING }) {
1090+
val valuesToProject = when(compileOptions.projectionIteration) {
1091+
ProjectionIterationBehavior.FILTER_MISSING -> {
1092+
value.filter { it.type != ExprValueType.MISSING }
1093+
}
1094+
ProjectionIterationBehavior.UNFILTERED -> value
1095+
}
1096+
for (childValue in valuesToProject) {
10921097
val namedFacet = childValue.asFacet(Named::class.java)
10931098
val name = namedFacet?.name
10941099
?: syntheticColumnName(columns.size).exprValue()

lang/test/org/partiql/lang/eval/EvaluatingCompilerTests.kt

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,10 @@
1414

1515
package org.partiql.lang.eval
1616

17+
import com.amazon.ion.system.IonSystemBuilder
1718
import org.junit.Ignore
1819
import org.junit.Test
20+
import org.partiql.lang.CompilerPipeline
1921
import org.partiql.lang.syntax.ParserException
2022

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

1496+
@Test
1497+
fun projectionIterationBehaviorUnfiltered_select_list() =
1498+
assertEvalExprValue(
1499+
source = "select a from <<{'a': MISSING}>>",
1500+
expected = "<<{'a': MISSING}>>",
1501+
compileOptions = CompileOptions.build {
1502+
projectionIteration(ProjectionIterationBehavior.UNFILTERED)
1503+
}
1504+
)
1505+
1506+
@Test
1507+
fun projectionIterationBehaviorUnfiltered_select_star() =
1508+
assertEvalExprValue(
1509+
source = "select * from <<{'a': MISSING}>>",
1510+
expected = "<<{'a': MISSING}>>",
1511+
compileOptions = CompileOptions.build {
1512+
projectionIteration(ProjectionIterationBehavior.UNFILTERED)
1513+
}
1514+
)
1515+
14941516
@Test
14951517
fun undefinedQualifiedVariableWithUndefinedVariableBehaviorError() {
14961518
// Demonstrates that UndefinedVariableBehavior.ERROR does not affect qualified field names.

lang/test/org/partiql/lang/eval/EvaluatorTestBase.kt

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,14 @@ abstract class EvaluatorTestBase : TestBase() {
136136
assertRewrite(source, originalExprNode)
137137
}
138138

139+
protected fun assertExprEquals(expected: ExprValue, actual: ExprValue) {
140+
if(!expected.exprEquals(actual)) {
141+
println("Expected ionValue: ${ConfigurableExprValueFormatter.pretty.format(expected)} ")
142+
println("Actual ionValue : ${ConfigurableExprValueFormatter.pretty.format(actual)} ")
143+
fail("Expected and actual ExprValue instances are not equivalent")
144+
}
145+
}
146+
139147
protected fun assertExprEquals(expected: ExprValue, actual: ExprValue, message: String) {
140148
if(!expected.exprEquals(actual)) {
141149
println(message)
@@ -145,6 +153,31 @@ abstract class EvaluatorTestBase : TestBase() {
145153
fail("Expected and actual ExprValue instances are not equivalent")
146154
}
147155
}
156+
/**
157+
* Evaluates [expected] and [source] and asserts that the resulting [ExprValue]s
158+
* are equivalent using PartiQL's equivalence rules. This differs from `assertEval`
159+
* in that the [ExprValue]s are not converted to Ion before comparison.
160+
* This function should be used for any result involving `BAG` and `MISSING`
161+
* since Ion has no representation for these values.
162+
*
163+
* @param source query source to be tested
164+
* @param expected expected result
165+
* @param session [EvaluationSession] used for evaluation
166+
* @param block function literal with receiver used to plug in custom assertions
167+
*/
168+
protected fun assertEvalExprValue(source: String,
169+
expected: String,
170+
session: EvaluationSession = EvaluationSession.standard(),
171+
compileOptions: CompileOptions = CompileOptions.standard()) {
172+
val parser = SqlParser(ion)
173+
val originalExprNode = parser.parseExprNode(source)
174+
val expectedExprNode = parser.parseExprNode(expected)
175+
176+
val originalExprValue = eval(originalExprNode, compileOptions, session)
177+
val expectedExprValue = eval(expectedExprNode, compileOptions, session)
178+
assertExprEquals(expectedExprValue, originalExprValue)
179+
}
180+
148181

149182

150183
/**

0 commit comments

Comments
 (0)