-
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.
Merge pull request #1513 from johnedquinn/v1-conformance-datum-distinct
Fixes all DISTINCT conformance tests
- Loading branch information
Showing
9 changed files
with
222 additions
and
71 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
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
28 changes: 28 additions & 0 deletions
28
partiql-spi/src/main/kotlin/org/partiql/spi/fn/builtins/internal/AccumulatorDistinct.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,28 @@ | ||
package org.partiql.spi.fn.builtins.internal | ||
|
||
import org.partiql.value.PartiQLValue | ||
import org.partiql.value.PartiQLValueExperimental | ||
import java.util.TreeSet | ||
|
||
@OptIn(PartiQLValueExperimental::class) | ||
internal class AccumulatorDistinct( | ||
private val _delegate: Accumulator, | ||
) : Accumulator() { | ||
|
||
// TODO: Add support for a datum comparator once the accumulator passes datums instead of PartiQL values. | ||
@OptIn(PartiQLValueExperimental::class) | ||
private val seen = TreeSet(PartiQLValue.comparator()) | ||
|
||
@OptIn(PartiQLValueExperimental::class) | ||
override fun nextValue(value: PartiQLValue) { | ||
if (!seen.contains(value)) { | ||
seen.add(value) | ||
_delegate.nextValue(value) | ||
} | ||
} | ||
|
||
@OptIn(PartiQLValueExperimental::class) | ||
override fun value(): PartiQLValue { | ||
return _delegate.value() | ||
} | ||
} |
Oops, something went wrong.