Uploaded image for project: 'Apache Cassandra'
  1. Apache Cassandra
  2. CASSANDRA-20154

BETWEEN where token(Y) > token(Z) returns wrong answer

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Open
    • Normal
    • Resolution: Unresolved
    • 5.x
    • CQL/Semantics
    • None
    • Correctness - API / Semantic Implementation
    • Normal
    • Normal
    • User Report
    • All
    • 5.x

    Description

      Noticed it’s not compliant with the SQL specification for BETWEEN and so doesn’t match what other databases do (tested on Postgres and MySQL).

      Here is the SQL 92 spec (later versions probably don't change something so fundamental).

      In particular rule 6 doesn't match the observed behavior which is to swap Y and Z and then return what is in between them which is pretty surprising as a result.

      6) "X BETWEEN Y AND Z" is equivalent to "X>=Y AND X<=Z".
      
               8.3  <between predicate>
      
               Function
      
               Specify a range comparison.
      
               Format
      
               <between predicate> ::=
                    <row value constructor> [ NOT ] BETWEEN
                      <row value constructor> AND <row value constructor>
      
      
               Syntax Rules
      
               1) The three <row value constructor>s shall be of the same degree.
      
               2) Let respective values be values with the same ordinal position
                  in the two <row value constructor>s.
      
               3) The data types of the respective values of the three <row value
                  constructor>s shall be comparable.
      
               4) Let X, Y, and Z be the first, second, and third <row value con-
                  structor>s, respectively.
      
               5) "X NOT BETWEEN Y AND Z" is equivalent to "NOT ( X BETWEEN Y AND
                  Z )".
      
               6) "X BETWEEN Y AND Z" is equivalent to "X>=Y AND X<=Z".
      

      Attachments

        Issue Links

          Activity

            People

              xvade Simon Chess
              aweisberg Ariel Weisberg
              Simon Chess
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

                Created:
                Updated: