Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes null comparisons and coercions of null collections #1454

Merged
merged 1 commit into from
Jul 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -322,12 +322,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
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could we cut an issue to partiql-tests for this? Or just fix the problematic conformance tests?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

// 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
Loading