Skip to content

Comprison on NULL differes from SQL #1414

Open

Description

@mandel

Hi,

We have noticed that the result of the following example doesn't return the expected result (based on https://doi.org/10.14778/3151113.3151116)

alasql('CREATE TABLE R (a number)');
alasql('CREATE TABLE S (b number)');
alasql.tables.R.data = [ {a: 1}, {a: null} ];
alasql.tables.S.data = [ {b: null} ];
var res = alasql('select a from R where a not in (select b from S)');
// expected: res = []
// alasql:   res = [ {"a": 1} ]

See https://jsfiddle.net/3ya794kr/.

This query compares each row of R with NULL which always returns unknown in SQL. Since not in unknown is unknown, the result should be the empty collection.

Activity

  1. piotr-m-bielski commented on Oct 14, 2022

    @piotr-m-bielski

    Im on it

  2. mathiasrw commented on Oct 14, 2022

    @mathiasrw
    Member

    It is a very interesting areas where AlaSQL is stepping in the two worlds of NULL...

    The programming language null is a value but database null is not a value.

    I found great joy in reading this a while ago: https://arxiv.org/html/1606.00740

    @piotr-m-bielski this will likely be a breaking change. I suggest we identify how to solve it, and then consider if its possible to make an option to use the old way or the SQL way.

  3. piotr-m-bielski commented on Oct 14, 2022

    @piotr-m-bielski

    Okey, so let me know when you make decision how to do it.

  4. mathiasrw commented on Oct 17, 2022

    @mathiasrw
    Member

    Oh - we can work on a solution. So you can just start on this. But before the release we will discuss how to let the users configure this. How we do that depends on what the solution looks like. So I suggest you work on solving this, and then we talk about how the solution can be part of what Alasql offers.

  5. mathiasrw commented on Oct 26, 2022

    @mathiasrw
    Member

    @piotr-m-bielski Have you had a chance to dive into this? Any ideas?

  6. piotr-m-bielski commented on Oct 26, 2022

    @piotr-m-bielski

    I tried to do that, but It is really hard to understand how it works. (parser) Variables like yy do not help. I will try again over this weekend

  7. mathiasrw commented on Oct 27, 2022

    @mathiasrw
    Member

    In agree. Its a nasty beast to dive into.

    In short: the compiler makes an AST. The AST is transformed into a string of the javascript doing all the things needed to execute the SQL. Then the string is run with data as parameters.

    NULL has a sad story in AlaSQL with the original design not tapping into its power, but treating undefined and null as kind of the same.

  8. mathiasrw commented on Oct 27, 2022

    @mathiasrw
    Member

    You can also have a look at #1415 (comment) for some inputs regarding diving into the code.

  9. piotr-m-bielski commented on Nov 3, 2022

    @piotr-m-bielski

    I give up.

  10. removed their assignment
    on Nov 3, 2022
  11. mathiasrw commented on Nov 3, 2022

    @mathiasrw
    Member

    Thank you for trying.

    Di you find out anything interesting? Any thoughts to share?

  12. aotru commented on Nov 11, 2022

    @aotru

    My friend and I plan on working on this and issue 1415 (union operator not working). Any advice before we get started?

  13. mathiasrw commented on Nov 13, 2022

    @mathiasrw
    Member

    @aotru Thank you so much.

    Advice: Make a test first that illustrates the problem.

    You might also benefit from the suggestions in this this comment about one way of running alasql with breaks and steps: #1415 (comment)

  14. mathiasrw commented on Dec 27, 2022

    @mathiasrw
    Member

    Any luck @aotru ?

  15. Jnani-222 commented on Aug 30, 2023

    @Jnani-222

    Try using the join concept, to get the expected output.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions