[jira] [Commented] (IGNITE-17997) Whitespaces at the end are ignored during string comparison

2022-11-02 Thread Yury Gerzhedovich (Jira)


[ 
https://issues.apache.org/jira/browse/IGNITE-17997?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=17627610#comment-17627610
 ] 

Yury Gerzhedovich commented on IGNITE-17997:


[~akhitrin] , in case we agree that's not a bug let's close the ticket.

> Whitespaces at the end are ignored during string comparison
> ---
>
> Key: IGNITE-17997
> URL: https://issues.apache.org/jira/browse/IGNITE-17997
> Project: Ignite
>  Issue Type: Bug
>  Components: sql
>Affects Versions: 3.0.0-beta1
>Reporter: Andrey Khitrin
>Priority: Major
>  Labels: ignite-3
>
> In 3.0.0-Beta-1:
> {code:java}
> sql-cli> select 'a' = 'a' as t1, 'a' = 'b' as t2, 'a' = 'a   ' as t3, 'a' = ' 
>   a' as t4;
> ╔══╤═══╤══╤═══╗
> ║ T1   │ T2    │ T3   │ T4    ║
> ╠══╪═══╪══╪═══╣
> ║ true │ false │ true │ false ║
> ╚══╧═══╧══╧═══╝
> {code}
> Tests T1, T2, and T4 show correct behavior. But in test T2 we see that string 
> 'a' is considered being equal to string 'a   '  (same string but with 
> arbitrary amount of whitespaces at the end). This is incorrect behavior.
> This issue may have the same nature as IGNITE-17996, but it's just a 
> hypothesis.



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


[jira] [Commented] (IGNITE-17997) Whitespaces at the end are ignored during string comparison

2022-10-28 Thread Andrey Khitrin (Jira)


[ 
https://issues.apache.org/jira/browse/IGNITE-17997?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=17625538#comment-17625538
 ] 

Andrey Khitrin commented on IGNITE-17997:
-

Thank you, I see expected behavior with `VARCHAR`:

{code:sql}
sql-cli> select cast('a' AS VARCHAR) = cast('a' AS VARCHAR) as test;
╔═╗
║ TEST║
╠═╣
║ true║
╚═╝

sql-cli> select cast('a' AS VARCHAR) = cast('a ' AS VARCHAR) as test;
╔═╗
║ TEST║
╠═╣
║ false   ║
╚═╝
{code}

> Whitespaces at the end are ignored during string comparison
> ---
>
> Key: IGNITE-17997
> URL: https://issues.apache.org/jira/browse/IGNITE-17997
> Project: Ignite
>  Issue Type: Bug
>  Components: sql
>Affects Versions: 3.0.0-beta1
>Reporter: Andrey Khitrin
>Priority: Major
>
> In 3.0.0-Beta-1:
> {code:java}
> sql-cli> select 'a' = 'a' as t1, 'a' = 'b' as t2, 'a' = 'a   ' as t3, 'a' = ' 
>   a' as t4;
> ╔══╤═══╤══╤═══╗
> ║ T1   │ T2    │ T3   │ T4    ║
> ╠══╪═══╪══╪═══╣
> ║ true │ false │ true │ false ║
> ╚══╧═══╧══╧═══╝
> {code}
> Tests T1, T2, and T4 show correct behavior. But in test T2 we see that string 
> 'a' is considered being equal to string 'a   '  (same string but with 
> arbitrary amount of whitespaces at the end). This is incorrect behavior.
> This issue may have the same nature as IGNITE-17996, but it's just a 
> hypothesis.



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


[jira] [Commented] (IGNITE-17997) Whitespaces at the end are ignored during string comparison

2022-10-27 Thread Konstantin Orlov (Jira)


[ 
https://issues.apache.org/jira/browse/IGNITE-17997?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=17625170#comment-17625170
 ] 

Konstantin Orlov commented on IGNITE-17997:
---

Yes in IGNITE-17996 the same rule about type inference is applied. You could 
make an explicit cast to 

varchar, though. This will do the trick.

> Whitespaces at the end are ignored during string comparison
> ---
>
> Key: IGNITE-17997
> URL: https://issues.apache.org/jira/browse/IGNITE-17997
> Project: Ignite
>  Issue Type: Bug
>  Components: sql
>Affects Versions: 3.0.0-beta1
>Reporter: Andrey Khitrin
>Priority: Major
>
> In 3.0.0-Beta-1:
> {code:java}
> sql-cli> select 'a' = 'a' as t1, 'a' = 'b' as t2, 'a' = 'a   ' as t3, 'a' = ' 
>   a' as t4;
> ╔══╤═══╤══╤═══╗
> ║ T1   │ T2    │ T3   │ T4    ║
> ╠══╪═══╪══╪═══╣
> ║ true │ false │ true │ false ║
> ╚══╧═══╧══╧═══╝
> {code}
> Tests T1, T2, and T4 show correct behavior. But in test T2 we see that string 
> 'a' is considered being equal to string 'a   '  (same string but with 
> arbitrary amount of whitespaces at the end). This is incorrect behavior.
> This issue may have the same nature as IGNITE-17996, but it's just a 
> hypothesis.



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


[jira] [Commented] (IGNITE-17997) Whitespaces at the end are ignored during string comparison

2022-10-27 Thread Andrey Khitrin (Jira)


[ 
https://issues.apache.org/jira/browse/IGNITE-17997?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=17625149#comment-17625149
 ] 

Andrey Khitrin commented on IGNITE-17997:
-

Thank you. I've forgot about collations. As I can see, the same behavior could 
be achieved in other database engines, depending on data type and/or query 
options. E.g., in [sqlite3|https://www.sqlite.org/datatype3.html#collation]:
{code:sql}
sqlite> SELECT 'a' = 'a ';
0-- false
sqlite> SELECT 'a' = 'a ' COLLATE RTRIM;
1-- true
{code}
In that case, I hardly can treat this behavior as a bug. At most, it's a 
different default, not obvious though.

[~korlov] what would you say about IGNITE-17996? Does this behavior obey the 
same rules?

Also, are there plans to support different collation schemes in the future?

> Whitespaces at the end are ignored during string comparison
> ---
>
> Key: IGNITE-17997
> URL: https://issues.apache.org/jira/browse/IGNITE-17997
> Project: Ignite
>  Issue Type: Bug
>  Components: sql
>Affects Versions: 3.0.0-beta1
>Reporter: Andrey Khitrin
>Priority: Major
>
> In 3.0.0-Beta-1:
> {code:java}
> sql-cli> select 'a' = 'a' as t1, 'a' = 'b' as t2, 'a' = 'a   ' as t3, 'a' = ' 
>   a' as t4;
> ╔══╤═══╤══╤═══╗
> ║ T1   │ T2    │ T3   │ T4    ║
> ╠══╪═══╪══╪═══╣
> ║ true │ false │ true │ false ║
> ╚══╧═══╧══╧═══╝
> {code}
> Tests T1, T2, and T4 show correct behavior. But in test T2 we see that string 
> 'a' is considered being equal to string 'a   '  (same string but with 
> arbitrary amount of whitespaces at the end). This is incorrect behavior.
> This issue may have the same nature as IGNITE-17996, but it's just a 
> hypothesis.



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


[jira] [Commented] (IGNITE-17997) Whitespaces at the end are ignored during string comparison

2022-10-27 Thread Konstantin Orlov (Jira)


[ 
https://issues.apache.org/jira/browse/IGNITE-17997?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=17625070#comment-17625070
 ] 

Konstantin Orlov commented on IGNITE-17997:
---

Hi [~akhitrin]! According to SQL Standard (in standard 1999 it's chapter 8.2 
``, p 3.b of general rules): 

{code:java}
If the length in characters of X is not equal to the length in characters of Y, 
then the shorter string is effectively replaced, for the purposes of 
comparison, with a copy of itself that has been extended to the length of the 
longer string by concatenation on the right of one or more pad characters, 
where the pad character is chosen based on CS. If CS has the NO PAD 
characteristic, then the pad character is an implementation-dependent character 
different from any character in the character set of X and Y that collates less 
than any string under CS. Otherwise, the pad character is a . {code}
 

Type inference for literal is working in a way to find the most restrictive 
type. In your example, these will be CHAR(1) and CHAR(4) accordingly. With that 
said, I consider the result of your example rather valid.

> Whitespaces at the end are ignored during string comparison
> ---
>
> Key: IGNITE-17997
> URL: https://issues.apache.org/jira/browse/IGNITE-17997
> Project: Ignite
>  Issue Type: Bug
>  Components: sql
>Affects Versions: 3.0.0-beta1
>Reporter: Andrey Khitrin
>Priority: Major
>
> In 3.0.0-Beta-1:
> {code:java}
> sql-cli> select 'a' = 'a' as t1, 'a' = 'b' as t2, 'a' = 'a   ' as t3, 'a' = ' 
>   a' as t4;
> ╔══╤═══╤══╤═══╗
> ║ T1   │ T2    │ T3   │ T4    ║
> ╠══╪═══╪══╪═══╣
> ║ true │ false │ true │ false ║
> ╚══╧═══╧══╧═══╝
> {code}
> Tests T1, T2, and T4 show correct behavior. But in test T2 we see that string 
> 'a' is considered being equal to string 'a   '  (same string but with 
> arbitrary amount of whitespaces at the end). This is incorrect behavior.
> This issue may have the same nature as IGNITE-17996, but it's just a 
> hypothesis.



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