Skip to content

Commit

Permalink
Merge pull request #1454 from johnedquinn/v1-conformance-null-equality
Browse files Browse the repository at this point in the history
Fixes null comparisons and coercions of null collections
  • Loading branch information
johnedquinn authored Jul 17, 2024
2 parents 0703da5 + 17f59e2 commit ce2c689
Show file tree
Hide file tree
Showing 5 changed files with 36 additions and 791 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -341,12 +341,17 @@ internal class ExprCast(val arg: Operator.Expr, val cast: Ref.Cast) : Operator.E
}
}

// TODO: Fix NULL Collection
@OptIn(PartiQLValueExperimental::class)
private fun castFromCollection(value: CollectionValue<*>, t: PType): PartiQLValue {
val elements = mutableListOf<PartiQLValue>()
value.iterator().forEachRemaining {
elements.add(it)
val elements = when (value.isNull) {
true -> null
false -> {
val elements = mutableListOf<PartiQLValue>()
value.iterator().forEachRemaining {
elements.add(it)
}
elements
}
}
return when (t.kind) {
PType.Kind.BAG -> bagValue(elements)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -595,14 +595,13 @@ internal class PlanTyperTestsPorted {
catalog = "pql",
expected = StaticType.BOOL,
),
ErrorTestCase(
// TODO: For some reason, the conformance tests say that this results in TRUE. Regardless, we know it returns
// a boolean. We should re-look at what the conformance tests should return.
SuccessTestCase(
name = "MISSING IS NULL",
key = key("is-type-04"),
catalog = "pql",
expected = StaticType.BOOL,
problemHandler = assertProblemExists(
ProblemGenerator.expressionAlwaysReturnsMissing("Static function always receives MISSING arguments.")
)
),
SuccessTestCase(
name = "NULL IS NULL",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -121,33 +121,6 @@ internal object SqlBuiltins {
Fn_DIVIDE__FLOAT32_FLOAT32__FLOAT32,
Fn_DIVIDE__FLOAT64_FLOAT64__FLOAT64,
Fn_DIVIDE__DECIMAL_ARBITRARY_DECIMAL_ARBITRARY__DECIMAL_ARBITRARY,
Fn_EQ__NULL_NULL__BOOL,
Fn_EQ__MISSING_MISSING__BOOL,
Fn_EQ__BOOL_BOOL__BOOL,
Fn_EQ__INT8_INT8__BOOL,
Fn_EQ__INT16_INT16__BOOL,
Fn_EQ__INT32_INT32__BOOL,
Fn_EQ__INT64_INT64__BOOL,
Fn_EQ__INT_INT__BOOL,
Fn_EQ__DECIMAL_DECIMAL__BOOL,
Fn_EQ__FLOAT32_FLOAT32__BOOL,
Fn_EQ__FLOAT64_FLOAT64__BOOL,
Fn_EQ__DECIMAL_ARBITRARY_DECIMAL_ARBITRARY__BOOL,
Fn_EQ__CHAR_CHAR__BOOL,
Fn_EQ__STRING_STRING__BOOL,
Fn_EQ__CLOB_CLOB__BOOL,
Fn_EQ__SYMBOL_SYMBOL__BOOL,
Fn_EQ__BINARY_BINARY__BOOL,
Fn_EQ__BYTE_BYTE__BOOL,
Fn_EQ__BLOB_BLOB__BOOL,
Fn_EQ__DATE_DATE__BOOL,
Fn_EQ__TIME_TIME__BOOL,
Fn_EQ__TIMESTAMP_TIMESTAMP__BOOL,
Fn_EQ__INTERVAL_INTERVAL__BOOL,
Fn_EQ__LIST_LIST__BOOL,
Fn_EQ__SEXP_SEXP__BOOL,
Fn_EQ__BAG_BAG__BOOL,
Fn_EQ__STRUCT_STRUCT__BOOL,
Fn_EQ__ANY_ANY__BOOL,
Fn_EXTRACT_DAY__DATE__INT32,
Fn_EXTRACT_DAY__TIMESTAMP__INT32,
Expand Down
Loading

0 comments on commit ce2c689

Please sign in to comment.