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

PlannerCompiler w/ SELECT DISTINCT and ORDER BY returns a bag #1277

Closed
alancai98 opened this issue Dec 1, 2023 · 1 comment · Fixed by #1298
Closed

PlannerCompiler w/ SELECT DISTINCT and ORDER BY returns a bag #1277

alancai98 opened this issue Dec 1, 2023 · 1 comment · Fixed by #1298
Labels
bug Something isn't working

Comments

@alancai98
Copy link
Member

Description

PlannerCompiler returns a bag rather than a list like the EvaluatingCompiler currently does.

To Reproduce

Steps to reproduce the behavior:

-- `PlanCompiler` returns a bag
PartiQL> SELECT DISTINCT a FROM <<{'a': 1}, {'a': 2}, {'a': 1}>> AS t ORDER BY t.a;
==='
<<
  {
    'a': 1
  },
  {
    'a': 2
  }
>>
-- `EvaluatingCompiler` returns a list
PartiQL> SELECT DISTINCT a FROM <<{'a': 1}, {'a': 2}, {'a': 1}>> AS t ORDER BY t.a;
==='
[
  {
    'a': 1
  },
  {
    'a': 2
  }
]

Expected Behavior

Expect both compilers to return the same output type (i.e. list).

Additional Context

  • Java version: 11
  • PartiQL version: 0.13.3
@alancai98 alancai98 added the bug Something isn't working label Dec 1, 2023
@alancai98
Copy link
Member Author

Some investigation

The PlanCompiler performs the DISTINCT call on the output of the projection (source), which will call the builtin scalar function filter_distinct. Currently, filter_distinct will always return a bag: https://github.com/partiql/partiql-lang-kotlin/blob/main/partiql-lang/src/main/kotlin/org/partiql/lang/eval/builtins/ScalarBuiltinsExt.kt#L124-L138.

We could potentially modify filter_distinct to return a list if we can guarantee that the order of the input list can be preserved.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant