-
Notifications
You must be signed in to change notification settings - Fork 63
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
Adds support for PERMISSIVE vs STRICT #1353
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
package org.partiql.eval.internal.operator.rel | ||
|
||
import org.partiql.eval.internal.Record | ||
import org.partiql.eval.internal.operator.Operator | ||
import org.partiql.value.BagValue | ||
import org.partiql.value.CollectionValue | ||
import org.partiql.value.PartiQLValue | ||
import org.partiql.value.PartiQLValueExperimental | ||
import org.partiql.value.int64Value | ||
import org.partiql.value.missingValue | ||
|
||
@OptIn(PartiQLValueExperimental::class) | ||
internal class RelScanIndexedPermissive( | ||
private val expr: Operator.Expr | ||
) : Operator.Relation { | ||
|
||
private lateinit var iterator: Iterator<PartiQLValue> | ||
private var index: Long = 0 | ||
private var isIndexable: Boolean = true | ||
|
||
override fun open() { | ||
val r = expr.eval(Record.empty) | ||
index = 0 | ||
iterator = when (r) { | ||
is BagValue<*> -> { | ||
isIndexable = false | ||
r.iterator() | ||
} | ||
is CollectionValue<*> -> r.iterator() | ||
else -> { | ||
isIndexable = false | ||
iterator { yield(r) } | ||
} | ||
} | ||
} | ||
|
||
override fun next(): Record? { | ||
if (!iterator.hasNext()) { | ||
return null | ||
} | ||
val v = iterator.next() | ||
return when (isIndexable) { | ||
true -> { | ||
val i = index | ||
index += 1 | ||
Record.of(v, int64Value(i)) | ||
} | ||
false -> Record.of(v, missingValue()) | ||
} | ||
} | ||
|
||
override fun close() {} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
package org.partiql.eval.internal.operator.rel | ||
|
||
import org.partiql.eval.internal.Record | ||
import org.partiql.eval.internal.operator.Operator | ||
import org.partiql.value.CollectionValue | ||
import org.partiql.value.PartiQLValueExperimental | ||
|
||
@OptIn(PartiQLValueExperimental::class) | ||
internal class RelScanPermissive( | ||
private val expr: Operator.Expr | ||
) : Operator.Relation { | ||
|
||
private lateinit var records: Iterator<Record> | ||
|
||
override fun open() { | ||
val r = expr.eval(Record.empty) | ||
records = when (r) { | ||
is CollectionValue<*> -> r.map { Record.of(it) }.iterator() | ||
else -> iterator { yield(Record.of(r)) } | ||
} | ||
} | ||
|
||
override fun next(): Record? { | ||
return if (records.hasNext()) { | ||
records.next() | ||
} else { | ||
null | ||
} | ||
} | ||
|
||
override fun close() {} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,13 @@ | ||
package org.partiql.eval.internal.operator.rex | ||
|
||
import org.partiql.errors.TypeCheckException | ||
import org.partiql.eval.internal.Record | ||
import org.partiql.eval.internal.operator.Operator | ||
import org.partiql.value.PartiQLValue | ||
import org.partiql.value.PartiQLValueExperimental | ||
import org.partiql.value.StringValue | ||
import org.partiql.value.StructValue | ||
import org.partiql.value.check | ||
import org.partiql.value.missingValue | ||
|
||
internal class ExprPathKey( | ||
@JvmField val root: Operator.Expr, | ||
|
@@ -19,6 +19,6 @@ internal class ExprPathKey( | |
val rootEvaluated = root.eval(record).check<StructValue<PartiQLValue>>() | ||
val keyEvaluated = key.eval(record).check<StringValue>() | ||
val keyString = keyEvaluated.value ?: error("String value was null") | ||
return rootEvaluated[keyString] ?: missingValue() | ||
return rootEvaluated[keyString] ?: throw TypeCheckException() | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
It seems like right now we don't have the notion of ordered vs unordered struct during runtime. Maybe just keep a todo note here? |
||
} | ||
} |
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.
Not related to this PR, but does this work for subquery?
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.
That's a good question. I have a subquery PR out, and when I rebase, I'll take a look at that.