-
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.
Prohibit ORDER BY, LIMIT, OFFSET on bag ops; change eval impl to use …
…lazy
- Loading branch information
Showing
11 changed files
with
56 additions
and
34 deletions.
There are no files selected for viewing
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
19 changes: 15 additions & 4 deletions
19
partiql-eval/src/main/kotlin/org/partiql/eval/internal/helpers/ToBag.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 |
---|---|---|
@@ -1,24 +1,35 @@ | ||
package org.partiql.eval.internal.helpers | ||
|
||
import org.partiql.errors.TypeCheckException | ||
import org.partiql.eval.value.Datum | ||
import org.partiql.types.PType | ||
|
||
/** | ||
* Coercion function F for bag operators described in RFC-0007 | ||
* Coercion function F for bag operators described in RFC-0007. | ||
* - F(absent_value) -> << >> | ||
* - F(scalar_value) -> << scalar_value >> # singleton bag | ||
* - F(tuple_value) -> << tuple_value >> # singleton bag, see future extensions | ||
* - F(array_value) -> bag_value # discard ordering | ||
* - F(bag_value) -> bag_value # identity | ||
* | ||
* Throws a [TypeCheckException] when coercing a non-collection to a bag. | ||
*/ | ||
internal fun Datum.asIterator(): Iterator<Datum> { | ||
internal fun Datum.asIterator(coerce: Boolean): Iterator<Datum> { | ||
val d = this | ||
return if (d.isNull || d.isMissing) { | ||
emptyList<Datum>().iterator() | ||
coerce.throwOrIterator(emptyList<Datum>().iterator()) | ||
} else { | ||
when (d.type.kind) { | ||
PType.Kind.LIST, PType.Kind.BAG, PType.Kind.SEXP -> d.iterator() | ||
else -> listOf(d).iterator() | ||
else -> coerce.throwOrIterator(listOf(d).iterator()) | ||
} | ||
} | ||
} | ||
|
||
private fun Boolean.throwOrIterator(iterator: Iterator<Datum>): Iterator<Datum> { | ||
if (this) { | ||
return iterator | ||
} else { | ||
throw TypeCheckException() | ||
} | ||
} |
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
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
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
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
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
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
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
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