Yaoxuan Wu created FLINK-40933:
----------------------------------

             Summary: BETWEEN with equal bounds drops trailing spaces of the 
bound
                 Key: FLINK-40933
                 URL: https://issues.apache.org/jira/browse/FLINK-40933
             Project: Flink
          Issue Type: Bug
          Components: Table SQL / Planner
            Reporter: Yaoxuan Wu
             Fix For: 2.3.0


{code:java}
SELECT s FROM (VALUES ('a'), ('a ')) AS t(s) WHERE s BETWEEN 'a ' AND 'a ';
-- Flink: 'a'        expected: 'a 'SELECT s FROM (VALUES ('a'), ('a ')) AS t(s) 
WHERE s = 'a ';

-- 'a ' (correct)SELECT s FROM (VALUES (''), (' ')) AS t(s) WHERE s >= ' ' AND 
s <= ' ';
-- Flink: ''         expected: ' ' {code}
When both bounds of a range are the same string ending in spaces, the range is 
simplified to an equality and the trailing spaces are dropped:

{{=}} and {{IN}} keep the spaces ({{{}s = 'a '{}}} matches only {{{}'a '{}}}), 
so Flink itself compares these strings without padding. Only the simplified 
range trims them, so the query drops the row that matches and returns one that 
does not.



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to