-
Notifications
You must be signed in to change notification settings - Fork 62
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add tests for Ion's typed nulls (#1164)
- Loading branch information
Showing
1 changed file
with
57 additions
and
0 deletions.
There are no files selected for viewing
57 changes: 57 additions & 0 deletions
57
partiql-lang/src/test/kotlin/org/partiql/lang/eval/TypedNullTests.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
package org.partiql.lang.eval | ||
|
||
import com.amazon.ion.IonSystem | ||
import com.amazon.ion.system.IonSystemBuilder | ||
import org.junit.Test | ||
import org.partiql.lang.CompilerPipeline | ||
|
||
/** | ||
* The following tests demonstrate the current typed null behavior and tracks possible regressions in future commits. | ||
* This behavior is what the Kotlin implementation defines and is subject to change pending resolution of | ||
* https://github.com/partiql/partiql-spec/issues/61. | ||
*/ | ||
class TypedNullTests : EvaluatorTestBase() { | ||
// Round-tripped typed nulls (IonValue -> ExprValue -> IonValue) results in same typed null value | ||
@Test | ||
fun typedNullIonValueExprValueRoundTrip() { | ||
val ion: IonSystem = IonSystemBuilder.standard().build() | ||
val ionValue = ion.singleValue("null.int") | ||
val exprValue = ExprValue.of(ionValue) | ||
val roundTripped = exprValue.toIonValue(ion) | ||
assertEquals(ionValue, roundTripped) | ||
} | ||
|
||
// Evaluated typed nulls converted to an IonValue preserve the typed null. | ||
@Test | ||
fun typedNullIonLiteralEvaluation() { | ||
val pipeline = CompilerPipeline.standard() | ||
val ionValueAsString = "null.int" | ||
val expr = pipeline.compile("`$ionValueAsString`") | ||
val session = EvaluationSession.standard() | ||
val result = expr.eval(session) | ||
val ionValueRoundtripped = result.toIonValue(ion) | ||
assertEquals(ion.singleValue(ionValueAsString), ionValueRoundtripped) | ||
} | ||
|
||
// Evaluated typed nulls in an SFW projection. Converting result to an IonValue preserves the typed null. | ||
@Test | ||
fun typedNullInSFW() { | ||
val pipeline = CompilerPipeline.standard() | ||
val expr = pipeline.compile("SELECT t.a FROM [{'a': `null.int`}] AS t") | ||
val session = EvaluationSession.standard() | ||
val result = expr.eval(session) | ||
val ionValueRoundtripped = result.toIonValue(ion) | ||
assertEquals(ion.singleValue("\$bag::[{a: null.int}]"), ionValueRoundtripped) | ||
} | ||
|
||
// Evaluated typed nulls in an arithmetic expression will NOT preserve the type when converting back to IonValue. | ||
@Test | ||
fun typedNullInArithmeticOperation() { | ||
val pipeline = CompilerPipeline.standard() | ||
val expr = pipeline.compile("`null.int` + `null.int`") | ||
val session = EvaluationSession.standard() | ||
val result = expr.eval(session) | ||
val ionValueRoundtripped = result.toIonValue(ion) | ||
assertEquals(ion.singleValue("null"), ionValueRoundtripped) | ||
} | ||
} |
c580925
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
JMH Benchmark
org.partiql.jmh.benchmarks.MultipleLikeBenchmark.testPartiQLCompiler15
122.05493607311249
us/op179.36948160391643
us/op0.68
org.partiql.jmh.benchmarks.MultipleLikeBenchmark.testPartiQLCompiler30
234.29145538849357
us/op395.32692704927916
us/op0.59
org.partiql.jmh.benchmarks.MultipleLikeBenchmark.testPartiQLEvaluator15
451416.7675916667
us/op594068.3074
us/op0.76
org.partiql.jmh.benchmarks.MultipleLikeBenchmark.testPartiQLEvaluator30
1039896.2575
us/op1116918.99835
us/op0.93
org.partiql.jmh.benchmarks.MultipleLikeBenchmark.testPartiQLEvaluator30WithData10
10467659.807500001
us/op11200307.3889
us/op0.93
org.partiql.jmh.benchmarks.MultipleLikeBenchmark.testPartiQLParser15
189.514053242577
us/op248.32620909009628
us/op0.76
org.partiql.jmh.benchmarks.MultipleLikeBenchmark.testPartiQLParser30
379.17309851691573
us/op485.7572023208039
us/op0.78
org.partiql.jmh.benchmarks.ParserBenchmark.parseFailNameCaseWhenThen
46.127625361692125
us/op80.40577800924878
us/op0.57
org.partiql.jmh.benchmarks.ParserBenchmark.parseFailNameComplexQuery
63.22506589098462
us/op91.59307064706026
us/op0.69
org.partiql.jmh.benchmarks.ParserBenchmark.parseFailNameComplexQuery01
315.49890013365786
us/op458.9099344396042
us/op0.69
org.partiql.jmh.benchmarks.ParserBenchmark.parseFailNameComplexQuery02
549.7708447699017
us/op747.1327009431432
us/op0.74
org.partiql.jmh.benchmarks.ParserBenchmark.parseFailNameExceptUnionIntersectSixty
215.4475671559751
us/op292.3742689597752
us/op0.74
org.partiql.jmh.benchmarks.ParserBenchmark.parseFailNameExec20Expressions
68.88502136324108
us/op104.24032907224039
us/op0.66
org.partiql.jmh.benchmarks.ParserBenchmark.parseFailNameFromLet
48.49314863524876
us/op83.93179545902805
us/op0.58
org.partiql.jmh.benchmarks.ParserBenchmark.parseFailNameGraphPattern
48.62248081644734
us/op78.66738795415063
us/op0.62
org.partiql.jmh.benchmarks.ParserBenchmark.parseFailNameGraphPreFilters
75.884645518122
us/op131.3816760914659
us/op0.58
org.partiql.jmh.benchmarks.ParserBenchmark.parseFailNameGroupLimit
49.690954334276306
us/op91.64691341714969
us/op0.54
org.partiql.jmh.benchmarks.ParserBenchmark.parseFailNameLongFromSourceOrderBy
70.08263933846999
us/op102.50367278559592
us/op0.68
org.partiql.jmh.benchmarks.ParserBenchmark.parseFailNameManyJoins
68.83532072586334
us/op113.89178590874783
us/op0.60
org.partiql.jmh.benchmarks.ParserBenchmark.parseFailNameNestedAggregates
119.5659725452906
us/op183.08778691509545
us/op0.65
org.partiql.jmh.benchmarks.ParserBenchmark.parseFailNameNestedParen
22.153789705836946
us/op34.859077858322124
us/op0.64
org.partiql.jmh.benchmarks.ParserBenchmark.parseFailNamePivot
72.03602506402245
us/op119.93769601656213
us/op0.60
org.partiql.jmh.benchmarks.ParserBenchmark.parseFailNameQuery15OrsAndLikes
222.80173119495709
us/op361.79161031081065
us/op0.62
org.partiql.jmh.benchmarks.ParserBenchmark.parseFailNameQuery30Plus
122.83779610359367
us/op169.31291085427546
us/op0.73
org.partiql.jmh.benchmarks.ParserBenchmark.parseFailNameQueryFunc
55.26646379375201
us/op84.1577931905553
us/op0.66
org.partiql.jmh.benchmarks.ParserBenchmark.parseFailNameQueryFuncInProjection
127.62861558151126
us/op181.18625184256842
us/op0.70
org.partiql.jmh.benchmarks.ParserBenchmark.parseFailNameQueryList
82.75994516917672
us/op124.42108512640755
us/op0.67
org.partiql.jmh.benchmarks.ParserBenchmark.parseFailNameQueryNestedSelect
780.9349864574201
us/op1033.3210688093604
us/op0.76
org.partiql.jmh.benchmarks.ParserBenchmark.parseFailNameQuerySimple
19.911621791320393
us/op30.81793269869154
us/op0.65
org.partiql.jmh.benchmarks.ParserBenchmark.parseFailNameSeveralJoins
25.985980954042496
us/op43.05898089577538
us/op0.60
org.partiql.jmh.benchmarks.ParserBenchmark.parseFailNameSeveralProjections
75.51335653019405
us/op120.30467485786502
us/op0.63
org.partiql.jmh.benchmarks.ParserBenchmark.parseFailNameSeveralSelect
220.1614959150611
us/op325.4621894085254
us/op0.68
org.partiql.jmh.benchmarks.ParserBenchmark.parseFailNameSimpleInsert
33.89818650073466
us/op60.26623457896085
us/op0.56
org.partiql.jmh.benchmarks.ParserBenchmark.parseFailNameSomeJoins
25.66619565724137
us/op40.8656316265531
us/op0.63
org.partiql.jmh.benchmarks.ParserBenchmark.parseFailNameSomeProjections
33.99708957422836
us/op54.73938812263408
us/op0.62
org.partiql.jmh.benchmarks.ParserBenchmark.parseFailNameSomeSelect
57.91553709495038
us/op90.8796850550864
us/op0.64
org.partiql.jmh.benchmarks.ParserBenchmark.parseFailNameTimeZone
29.461197455565475
us/op46.06846290614983
us/op0.64
org.partiql.jmh.benchmarks.ParserBenchmark.parseFailNameVeryLongQuery
362.8578449373355
us/op493.71907697882773
us/op0.73
org.partiql.jmh.benchmarks.ParserBenchmark.parseFailNameVeryLongQuery01
1096.0161856678683
us/op1503.2544534622325
us/op0.73
org.partiql.jmh.benchmarks.ParserBenchmark.parseNameCaseWhenThen
28.789034876155473
us/op41.16143856682594
us/op0.70
org.partiql.jmh.benchmarks.ParserBenchmark.parseNameComplexQuery
263.29804194647033
us/op363.5105488484568
us/op0.72
org.partiql.jmh.benchmarks.ParserBenchmark.parseNameComplexQuery01
117.3161058068857
us/op168.170863990143
us/op0.70
org.partiql.jmh.benchmarks.ParserBenchmark.parseNameExceptUnionIntersectSixty
237.85250070347934
us/op295.1048271781815
us/op0.81
org.partiql.jmh.benchmarks.ParserBenchmark.parseNameExec20Expressions
72.46652149895019
us/op101.64657321993901
us/op0.71
org.partiql.jmh.benchmarks.ParserBenchmark.parseNameFromLet
41.34411639752328
us/op63.6972659693944
us/op0.65
org.partiql.jmh.benchmarks.ParserBenchmark.parseNameGraphPattern
44.613931628234276
us/op68.90532098358224
us/op0.65
org.partiql.jmh.benchmarks.ParserBenchmark.parseNameGraphPreFilters
74.70424574405331
us/op107.12351596822225
us/op0.70
org.partiql.jmh.benchmarks.ParserBenchmark.parseNameGroupLimit
36.59936835634586
us/op63.712288285439726
us/op0.57
org.partiql.jmh.benchmarks.ParserBenchmark.parseNameLongFromSourceOrderBy
140.9092505591318
us/op200.41056743103465
us/op0.70
org.partiql.jmh.benchmarks.ParserBenchmark.parseNameManyJoins
47.774983696005705
us/op70.8224072765803
us/op0.67
org.partiql.jmh.benchmarks.ParserBenchmark.parseNameNestedAggregates
100.20897610812993
us/op143.12300286006337
us/op0.70
org.partiql.jmh.benchmarks.ParserBenchmark.parseNameNestedParen
92.54327135753516
us/op111.59063341178985
us/op0.83
org.partiql.jmh.benchmarks.ParserBenchmark.parseNamePivot
68.90421183375268
us/op98.58712535914779
us/op0.70
org.partiql.jmh.benchmarks.ParserBenchmark.parseNameQuery15OrsAndLikes
185.29223122475574
us/op246.5652179610832
us/op0.75
org.partiql.jmh.benchmarks.ParserBenchmark.parseNameQuery30Plus
68.29906460197033
us/op85.32059913024739
us/op0.80
org.partiql.jmh.benchmarks.ParserBenchmark.parseNameQueryFunc
137.82306114374745
us/op213.65445513598428
us/op0.65
org.partiql.jmh.benchmarks.ParserBenchmark.parseNameQueryFuncInProjection
103.24264900192398
us/op126.41918307060811
us/op0.82
org.partiql.jmh.benchmarks.ParserBenchmark.parseNameQueryList
88.33082671978244
us/op110.99149891463341
us/op0.80
org.partiql.jmh.benchmarks.ParserBenchmark.parseNameQueryNestedSelect
145.81853948540015
us/op210.90218509966104
us/op0.69
org.partiql.jmh.benchmarks.ParserBenchmark.parseNameQuerySimple
15.025943891534116
us/op21.438112720633786
us/op0.70
org.partiql.jmh.benchmarks.ParserBenchmark.parseNameSeveralJoins
79.43087412252149
us/op106.89775872669527
us/op0.74
org.partiql.jmh.benchmarks.ParserBenchmark.parseNameSeveralProjections
62.85038504691122
us/op83.0535139336651
us/op0.76
org.partiql.jmh.benchmarks.ParserBenchmark.parseNameSeveralSelect
119.24319942559444
us/op155.76221343829758
us/op0.77
org.partiql.jmh.benchmarks.ParserBenchmark.parseNameSimpleInsert
24.00261805940456
us/op37.08539752665267
us/op0.65
org.partiql.jmh.benchmarks.ParserBenchmark.parseNameSomeJoins
23.818668609471402
us/op34.841857786877014
us/op0.68
org.partiql.jmh.benchmarks.ParserBenchmark.parseNameSomeProjections
20.817881434513247
us/op30.473554981228357
us/op0.68
org.partiql.jmh.benchmarks.ParserBenchmark.parseNameSomeSelect
38.558339950480594
us/op51.05844109763021
us/op0.76
org.partiql.jmh.benchmarks.ParserBenchmark.parseNameTimeZone
10.535186129194543
us/op15.635037906924794
us/op0.67
org.partiql.jmh.benchmarks.ParserBenchmark.parseNameVeryLongQuery
451.7669226339449
us/op578.9377567028818
us/op0.78
org.partiql.jmh.benchmarks.ParserBenchmark.parseNameVeryLongQuery01
1288.53918961447
us/op1510.5870572394736
us/op0.85
org.partiql.jmh.benchmarks.PartiQLBenchmark.testPartiQLCompiler
9.757357606645877
us/op14.673620588849014
us/op0.66
org.partiql.jmh.benchmarks.PartiQLBenchmark.testPartiQLEvaluator
2.5599806883641723
us/op2.9099337459729337
us/op0.88
org.partiql.jmh.benchmarks.PartiQLBenchmark.testPartiQLParser
13.16577834859251
us/op20.191156365983797
us/op0.65
This comment was automatically generated by workflow using github-action-benchmark.