[jira] [Commented] (CASSANDRA-15458) CQL: Unable to escape single quote in a map attribute

2023-01-17 Thread Paulo Motta (Jira)


[ 
https://issues.apache.org/jira/browse/CASSANDRA-15458?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=17677971#comment-17677971
 ] 

Paulo Motta commented on CASSANDRA-15458:
-

Thanks Brandon

Tests committed to trunk as 
[1528798a5bb36187cf2b952b5b5a8b0982d262fb|https://github.com/apache/cassandra/commit/1528798a5bb36187cf2b952b5b5a8b0982d262fb],
 will close as Not a Problem.

> CQL: Unable to escape single quote in a map attribute
> ---
>
> Key: CASSANDRA-15458
> URL: https://issues.apache.org/jira/browse/CASSANDRA-15458
> Project: Cassandra
>  Issue Type: Bug
>  Components: CQL/Interpreter, CQL/Semantics
>Reporter: Abhijeet Singh
>Assignee: Yaman Ziadeh
>Priority: Normal
>  Labels: AdventCalendar2021, lhf
> Attachments: cass-screen.png
>
>
> h3. Overview
> For {{text}} attributes, CQL allows escaping single quote [using additional 
> single 
> quote|http://mail-archives.apache.org/mod_mbox/cassandra-user/201108.mbox/%3c20110803152250.294...@gmx.net%3E].
>  But applying the same syntax for a {{map}} attribute does not 
> work. Inconsistent behavior was observed between {{text}} datatype and 
> {{map}} datatype.
> h3. CQL semantic proposal
> Cassandra (CQL) should apply same escaping semantics on {{text}} and 
> text-within-map {{map}} datatypes.
> h3. Reproducing the bug:
> CREATE query: 
> {code:java}
> CREATE TABLE university.test (id int, data map, PRIMARY KEY 
> (id));{code}
>  INSERT query: 
> {code:java}
> insert into university.test (id, data) values(1, {1:'I''m newb'});{code}
> On running the aforementioned INSERT query, Cassandra inserts and returns 
> {{\{1: 'I''m newb'}}} while the expected result is {{\{1: 'I'm newb'}}}
> h3. Technical details 
> OS: CentOS 7
> Kernel: Linux 3.10.0-1062.9.1.el7.x86_64
> Cassandra version: 3.11.5
> Screenshot: [Output after SELECT query|https://i.stack.imgur.com/PLAan.png]
>   
> +Additional information for newcomers:+
> The issue seems to come from the ANTLR Lexer logic for {{STRING_LITERAL}}. A 
> unit test should also be added in {{SelectTest}}



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

-
To unsubscribe, e-mail: commits-unsubscr...@cassandra.apache.org
For additional commands, e-mail: commits-h...@cassandra.apache.org



[jira] [Commented] (CASSANDRA-15458) CQL: Unable to escape single quote in a map attribute

2023-01-17 Thread Brandon Williams (Jira)


[ 
https://issues.apache.org/jira/browse/CASSANDRA-15458?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=17677964#comment-17677964
 ] 

Brandon Williams commented on CASSANDRA-15458:
--

bq. ok to commit the tests and close this as not a problem?

LGTM, +1.

> CQL: Unable to escape single quote in a map attribute
> ---
>
> Key: CASSANDRA-15458
> URL: https://issues.apache.org/jira/browse/CASSANDRA-15458
> Project: Cassandra
>  Issue Type: Bug
>  Components: CQL/Interpreter, CQL/Semantics
>Reporter: Abhijeet Singh
>Assignee: Yaman Ziadeh
>Priority: Normal
>  Labels: AdventCalendar2021, lhf
> Attachments: cass-screen.png
>
>
> h3. Overview
> For {{text}} attributes, CQL allows escaping single quote [using additional 
> single 
> quote|http://mail-archives.apache.org/mod_mbox/cassandra-user/201108.mbox/%3c20110803152250.294...@gmx.net%3E].
>  But applying the same syntax for a {{map}} attribute does not 
> work. Inconsistent behavior was observed between {{text}} datatype and 
> {{map}} datatype.
> h3. CQL semantic proposal
> Cassandra (CQL) should apply same escaping semantics on {{text}} and 
> text-within-map {{map}} datatypes.
> h3. Reproducing the bug:
> CREATE query: 
> {code:java}
> CREATE TABLE university.test (id int, data map, PRIMARY KEY 
> (id));{code}
>  INSERT query: 
> {code:java}
> insert into university.test (id, data) values(1, {1:'I''m newb'});{code}
> On running the aforementioned INSERT query, Cassandra inserts and returns 
> {{\{1: 'I''m newb'}}} while the expected result is {{\{1: 'I'm newb'}}}
> h3. Technical details 
> OS: CentOS 7
> Kernel: Linux 3.10.0-1062.9.1.el7.x86_64
> Cassandra version: 3.11.5
> Screenshot: [Output after SELECT query|https://i.stack.imgur.com/PLAan.png]
>   
> +Additional information for newcomers:+
> The issue seems to come from the ANTLR Lexer logic for {{STRING_LITERAL}}. A 
> unit test should also be added in {{SelectTest}}



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

-
To unsubscribe, e-mail: commits-unsubscr...@cassandra.apache.org
For additional commands, e-mail: commits-h...@cassandra.apache.org



[jira] [Commented] (CASSANDRA-15458) CQL: Unable to escape single quote in a map attribute

2023-01-17 Thread Paulo Motta (Jira)


[ 
https://issues.apache.org/jira/browse/CASSANDRA-15458?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=17677958#comment-17677958
 ] 

Paulo Motta commented on CASSANDRA-15458:
-

I noticed this issue is a duplicate of CASSANDRA-10263 which was closed as not 
a problem. Since this seems to be a recurrent confusion I created 
CASSANDRA-18170 to document this behavior.

I squashed [~yziadeh]'s tests validating the quoting behavior into this commit: 
[https://github.com/pauloricardomg/cassandra/commit/437acae1e80f12e02e317168402874c64c606188]

CI apparently looks good: 
[https://ci-cassandra.apache.org/view/patches/job/Cassandra-devbranch/2201/]:
* 
[SelectTest|https://ci-cassandra.apache.org/view/patches/job/Cassandra-devbranch/2201/testReport/org.apache.cassandra.cql3.validation.operations/SelectTest/]
* 
[test_cqlsh_completion|https://ci-cassandra.apache.org/view/patches/job/Cassandra-devbranch/2201/testReport/cqlshlib.python3.jdk8.cython.test.test_cqlsh_completion/]
* 
[test_cqlsh_output|https://ci-cassandra.apache.org/view/patches/job/Cassandra-devbranch/2201/testReport/cqlshlib.python3.jdk8.cython.test.test_cqlsh_output/]

[~brandon.williams] ok to commit the tests and close this as not a problem?

> CQL: Unable to escape single quote in a map attribute
> ---
>
> Key: CASSANDRA-15458
> URL: https://issues.apache.org/jira/browse/CASSANDRA-15458
> Project: Cassandra
>  Issue Type: Bug
>  Components: CQL/Interpreter, CQL/Semantics
>Reporter: Abhijeet Singh
>Assignee: Yaman Ziadeh
>Priority: Normal
>  Labels: AdventCalendar2021, lhf
> Attachments: cass-screen.png
>
>
> h3. Overview
> For {{text}} attributes, CQL allows escaping single quote [using additional 
> single 
> quote|http://mail-archives.apache.org/mod_mbox/cassandra-user/201108.mbox/%3c20110803152250.294...@gmx.net%3E].
>  But applying the same syntax for a {{map}} attribute does not 
> work. Inconsistent behavior was observed between {{text}} datatype and 
> {{map}} datatype.
> h3. CQL semantic proposal
> Cassandra (CQL) should apply same escaping semantics on {{text}} and 
> text-within-map {{map}} datatypes.
> h3. Reproducing the bug:
> CREATE query: 
> {code:java}
> CREATE TABLE university.test (id int, data map, PRIMARY KEY 
> (id));{code}
>  INSERT query: 
> {code:java}
> insert into university.test (id, data) values(1, {1:'I''m newb'});{code}
> On running the aforementioned INSERT query, Cassandra inserts and returns 
> {{\{1: 'I''m newb'}}} while the expected result is {{\{1: 'I'm newb'}}}
> h3. Technical details 
> OS: CentOS 7
> Kernel: Linux 3.10.0-1062.9.1.el7.x86_64
> Cassandra version: 3.11.5
> Screenshot: [Output after SELECT query|https://i.stack.imgur.com/PLAan.png]
>   
> +Additional information for newcomers:+
> The issue seems to come from the ANTLR Lexer logic for {{STRING_LITERAL}}. A 
> unit test should also be added in {{SelectTest}}



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

-
To unsubscribe, e-mail: commits-unsubscr...@cassandra.apache.org
For additional commands, e-mail: commits-h...@cassandra.apache.org



[jira] [Commented] (CASSANDRA-15458) CQL: Unable to escape single quote in a map attribute

2023-01-12 Thread Yaman Ziadeh (Jira)


[ 
https://issues.apache.org/jira/browse/CASSANDRA-15458?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=17676287#comment-17676287
 ] 

Yaman Ziadeh commented on CASSANDRA-15458:
--

The tests that failed were all to do with auto completion, they can be found 
here: pylib/cqlshlib/test/test_cqlsh_completion.py. 

Whenever new tables or types are added to 
pylib/cqlshlib/test/test_keyspace_init.cql, their name must be added to the 
appropriate completion tests. In this case, I fixed the broken tests by firstly 
renaming the new table 't1' to a more standard name 'escape_quotes' and the new 
type 'random' to 'quote_udt', then adding them to completion tests 
test_complete_in_create_type, test_complete_in_alter_type, and 
test_complete_in_alter_table respectively. 

> CQL: Unable to escape single quote in a map attribute
> ---
>
> Key: CASSANDRA-15458
> URL: https://issues.apache.org/jira/browse/CASSANDRA-15458
> Project: Cassandra
>  Issue Type: Bug
>  Components: CQL/Interpreter, CQL/Semantics
>Reporter: Abhijeet Singh
>Assignee: Yaman Ziadeh
>Priority: Normal
>  Labels: AdventCalendar2021, lhf
> Attachments: cass-screen.png
>
>
> h3. Overview
> For {{text}} attributes, CQL allows escaping single quote [using additional 
> single 
> quote|http://mail-archives.apache.org/mod_mbox/cassandra-user/201108.mbox/%3c20110803152250.294...@gmx.net%3E].
>  But applying the same syntax for a {{map}} attribute does not 
> work. Inconsistent behavior was observed between {{text}} datatype and 
> {{map}} datatype.
> h3. CQL semantic proposal
> Cassandra (CQL) should apply same escaping semantics on {{text}} and 
> text-within-map {{map}} datatypes.
> h3. Reproducing the bug:
> CREATE query: 
> {code:java}
> CREATE TABLE university.test (id int, data map, PRIMARY KEY 
> (id));{code}
>  INSERT query: 
> {code:java}
> insert into university.test (id, data) values(1, {1:'I''m newb'});{code}
> On running the aforementioned INSERT query, Cassandra inserts and returns 
> {{\{1: 'I''m newb'}}} while the expected result is {{\{1: 'I'm newb'}}}
> h3. Technical details 
> OS: CentOS 7
> Kernel: Linux 3.10.0-1062.9.1.el7.x86_64
> Cassandra version: 3.11.5
> Screenshot: [Output after SELECT query|https://i.stack.imgur.com/PLAan.png]
>   
> +Additional information for newcomers:+
> The issue seems to come from the ANTLR Lexer logic for {{STRING_LITERAL}}. A 
> unit test should also be added in {{SelectTest}}



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

-
To unsubscribe, e-mail: commits-unsubscr...@cassandra.apache.org
For additional commands, e-mail: commits-h...@cassandra.apache.org



[jira] [Commented] (CASSANDRA-15458) CQL: Unable to escape single quote in a map attribute

2023-01-05 Thread Paulo Motta (Jira)


[ 
https://issues.apache.org/jira/browse/CASSANDRA-15458?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=17655151#comment-17655151
 ] 

Paulo Motta commented on CASSANDRA-15458:
-

Submitted CI run for 
[branch|https://github.com/yziadeh/cassandra/tree/CASSANDRA-18035] with tests:
* https://ci-cassandra.apache.org/view/patches/job/Cassandra-devbranch/2159/

> CQL: Unable to escape single quote in a map attribute
> ---
>
> Key: CASSANDRA-15458
> URL: https://issues.apache.org/jira/browse/CASSANDRA-15458
> Project: Cassandra
>  Issue Type: Bug
>  Components: CQL/Interpreter, CQL/Semantics
>Reporter: Abhijeet Singh
>Assignee: Yaman Ziadeh
>Priority: Normal
>  Labels: AdventCalendar2021, lhf
> Attachments: cass-screen.png
>
>
> h3. Overview
> For {{text}} attributes, CQL allows escaping single quote [using additional 
> single 
> quote|http://mail-archives.apache.org/mod_mbox/cassandra-user/201108.mbox/%3c20110803152250.294...@gmx.net%3E].
>  But applying the same syntax for a {{map}} attribute does not 
> work. Inconsistent behavior was observed between {{text}} datatype and 
> {{map}} datatype.
> h3. CQL semantic proposal
> Cassandra (CQL) should apply same escaping semantics on {{text}} and 
> text-within-map {{map}} datatypes.
> h3. Reproducing the bug:
> CREATE query: 
> {code:java}
> CREATE TABLE university.test (id int, data map, PRIMARY KEY 
> (id));{code}
>  INSERT query: 
> {code:java}
> insert into university.test (id, data) values(1, {1:'I''m newb'});{code}
> On running the aforementioned INSERT query, Cassandra inserts and returns 
> {{\{1: 'I''m newb'}}} while the expected result is {{\{1: 'I'm newb'}}}
> h3. Technical details 
> OS: CentOS 7
> Kernel: Linux 3.10.0-1062.9.1.el7.x86_64
> Cassandra version: 3.11.5
> Screenshot: [Output after SELECT query|https://i.stack.imgur.com/PLAan.png]
>   
> +Additional information for newcomers:+
> The issue seems to come from the ANTLR Lexer logic for {{STRING_LITERAL}}. A 
> unit test should also be added in {{SelectTest}}



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

-
To unsubscribe, e-mail: commits-unsubscr...@cassandra.apache.org
For additional commands, e-mail: commits-h...@cassandra.apache.org



[jira] [Commented] (CASSANDRA-15458) CQL: Unable to escape single quote in a map attribute

2023-01-04 Thread Yaman Ziadeh (Jira)


[ 
https://issues.apache.org/jira/browse/CASSANDRA-15458?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=17654629#comment-17654629
 ] 

Yaman Ziadeh commented on CASSANDRA-15458:
--

Makes sense, I updated the tests to reflect current behavior and reverted 
pylib/cqlshlib/formatting.py changes.

> CQL: Unable to escape single quote in a map attribute
> ---
>
> Key: CASSANDRA-15458
> URL: https://issues.apache.org/jira/browse/CASSANDRA-15458
> Project: Cassandra
>  Issue Type: Bug
>  Components: CQL/Interpreter, CQL/Semantics
>Reporter: Abhijeet Singh
>Assignee: Yaman Ziadeh
>Priority: Normal
>  Labels: AdventCalendar2021, lhf
> Attachments: cass-screen.png
>
>
> h3. Overview
> For {{text}} attributes, CQL allows escaping single quote [using additional 
> single 
> quote|http://mail-archives.apache.org/mod_mbox/cassandra-user/201108.mbox/%3c20110803152250.294...@gmx.net%3E].
>  But applying the same syntax for a {{map}} attribute does not 
> work. Inconsistent behavior was observed between {{text}} datatype and 
> {{map}} datatype.
> h3. CQL semantic proposal
> Cassandra (CQL) should apply same escaping semantics on {{text}} and 
> text-within-map {{map}} datatypes.
> h3. Reproducing the bug:
> CREATE query: 
> {code:java}
> CREATE TABLE university.test (id int, data map, PRIMARY KEY 
> (id));{code}
>  INSERT query: 
> {code:java}
> insert into university.test (id, data) values(1, {1:'I''m newb'});{code}
> On running the aforementioned INSERT query, Cassandra inserts and returns 
> {{\{1: 'I''m newb'}}} while the expected result is {{\{1: 'I'm newb'}}}
> h3. Technical details 
> OS: CentOS 7
> Kernel: Linux 3.10.0-1062.9.1.el7.x86_64
> Cassandra version: 3.11.5
> Screenshot: [Output after SELECT query|https://i.stack.imgur.com/PLAan.png]
>   
> +Additional information for newcomers:+
> The issue seems to come from the ANTLR Lexer logic for {{STRING_LITERAL}}. A 
> unit test should also be added in {{SelectTest}}



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

-
To unsubscribe, e-mail: commits-unsubscr...@cassandra.apache.org
For additional commands, e-mail: commits-h...@cassandra.apache.org



[jira] [Commented] (CASSANDRA-15458) CQL: Unable to escape single quote in a map attribute

2023-01-04 Thread Brandon Williams (Jira)


[ 
https://issues.apache.org/jira/browse/CASSANDRA-15458?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=17654567#comment-17654567
 ] 

Brandon Williams commented on CASSANDRA-15458:
--

I agree that neither a) or b) is very desirable, so just committing the tests 
makes sense to me.

> CQL: Unable to escape single quote in a map attribute
> ---
>
> Key: CASSANDRA-15458
> URL: https://issues.apache.org/jira/browse/CASSANDRA-15458
> Project: Cassandra
>  Issue Type: Bug
>  Components: CQL/Interpreter, CQL/Semantics
>Reporter: Abhijeet Singh
>Assignee: Yaman Ziadeh
>Priority: Normal
>  Labels: AdventCalendar2021, lhf
> Attachments: cass-screen.png
>
>
> h3. Overview
> For {{text}} attributes, CQL allows escaping single quote [using additional 
> single 
> quote|http://mail-archives.apache.org/mod_mbox/cassandra-user/201108.mbox/%3c20110803152250.294...@gmx.net%3E].
>  But applying the same syntax for a {{map}} attribute does not 
> work. Inconsistent behavior was observed between {{text}} datatype and 
> {{map}} datatype.
> h3. CQL semantic proposal
> Cassandra (CQL) should apply same escaping semantics on {{text}} and 
> text-within-map {{map}} datatypes.
> h3. Reproducing the bug:
> CREATE query: 
> {code:java}
> CREATE TABLE university.test (id int, data map, PRIMARY KEY 
> (id));{code}
>  INSERT query: 
> {code:java}
> insert into university.test (id, data) values(1, {1:'I''m newb'});{code}
> On running the aforementioned INSERT query, Cassandra inserts and returns 
> {{\{1: 'I''m newb'}}} while the expected result is {{\{1: 'I'm newb'}}}
> h3. Technical details 
> OS: CentOS 7
> Kernel: Linux 3.10.0-1062.9.1.el7.x86_64
> Cassandra version: 3.11.5
> Screenshot: [Output after SELECT query|https://i.stack.imgur.com/PLAan.png]
>   
> +Additional information for newcomers:+
> The issue seems to come from the ANTLR Lexer logic for {{STRING_LITERAL}}. A 
> unit test should also be added in {{SelectTest}}



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

-
To unsubscribe, e-mail: commits-unsubscr...@cassandra.apache.org
For additional commands, e-mail: commits-h...@cassandra.apache.org



[jira] [Commented] (CASSANDRA-15458) CQL: Unable to escape single quote in a map attribute

2023-01-04 Thread Paulo Motta (Jira)


[ 
https://issues.apache.org/jira/browse/CASSANDRA-15458?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=17654556#comment-17654556
 ] 

Paulo Motta commented on CASSANDRA-15458:
-

Thanks for looking into this [~yziadeh].

It doesn't seem like this is a problem at the parser level, as shown by the 
server unit tests, but just a cqlsh display setting.

When reviewing this I realized that the example shown in the ticket description 
might not be incorrect:
{noformat}
SELECT data from test.t1; data
--
 I'm newb

SELECT data from test.t2; data
--
 {1: 'I''m newb'}
{noformat}
If we were to standardize quoting across simple text types vs complex types 
with text on cqlsh, we would have the following options:

a) Quote simple text fields:
{noformat}
SELECT data from test.t1; data
--
 'I''m newb'
{noformat}
b) Unquote complex types.
{noformat}
SELECT data from test.t2; data
--
 {1: I'm newb}
{noformat}
The problem with a) is that this would change the display of simple text fields 
on CQLSH, what could cause compatibility problems.

The problem with b) is that it makes the presentation more ambiguous, for 
instance in the example above we don't know if the key '1' on }1: I'm 
newb{ is a text or number without looking at the schema, while }1: 
'I''m newb'{ makes it immediately visible that the key '1' is a number.

I belive this is working as intended, despite the confusion. I propose we 
commit just the tests without changing the behavior.

What do you think [~stefan.miklosovic] [~brandon.williams] [~e.dimitrova]?

> CQL: Unable to escape single quote in a map attribute
> ---
>
> Key: CASSANDRA-15458
> URL: https://issues.apache.org/jira/browse/CASSANDRA-15458
> Project: Cassandra
>  Issue Type: Bug
>  Components: CQL/Interpreter, CQL/Semantics
>Reporter: Abhijeet Singh
>Assignee: Yaman Ziadeh
>Priority: Normal
>  Labels: AdventCalendar2021, lhf
> Attachments: cass-screen.png
>
>
> h3. Overview
> For {{text}} attributes, CQL allows escaping single quote [using additional 
> single 
> quote|http://mail-archives.apache.org/mod_mbox/cassandra-user/201108.mbox/%3c20110803152250.294...@gmx.net%3E].
>  But applying the same syntax for a {{map}} attribute does not 
> work. Inconsistent behavior was observed between {{text}} datatype and 
> {{map}} datatype.
> h3. CQL semantic proposal
> Cassandra (CQL) should apply same escaping semantics on {{text}} and 
> text-within-map {{map}} datatypes.
> h3. Reproducing the bug:
> CREATE query: 
> {code:java}
> CREATE TABLE university.test (id int, data map, PRIMARY KEY 
> (id));{code}
>  INSERT query: 
> {code:java}
> insert into university.test (id, data) values(1, {1:'I''m newb'});{code}
> On running the aforementioned INSERT query, Cassandra inserts and returns 
> {{\{1: 'I''m newb'}}} while the expected result is {{\{1: 'I'm newb'}}}
> h3. Technical details 
> OS: CentOS 7
> Kernel: Linux 3.10.0-1062.9.1.el7.x86_64
> Cassandra version: 3.11.5
> Screenshot: [Output after SELECT query|https://i.stack.imgur.com/PLAan.png]
>   
> +Additional information for newcomers:+
> The issue seems to come from the ANTLR Lexer logic for {{STRING_LITERAL}}. A 
> unit test should also be added in {{SelectTest}}



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

-
To unsubscribe, e-mail: commits-unsubscr...@cassandra.apache.org
For additional commands, e-mail: commits-h...@cassandra.apache.org



[jira] [Commented] (CASSANDRA-15458) CQL: Unable to escape single quote in a map attribute

2023-01-03 Thread Yaman Ziadeh (Jira)


[ 
https://issues.apache.org/jira/browse/CASSANDRA-15458?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=17654193#comment-17654193
 ] 

Yaman Ziadeh commented on CASSANDRA-15458:
--

Created a PR ([https://github.com/apache/cassandra/pull/2063)] to standardize 
all formatting in pylib/cqlshlib/formatting.py to be unquoted (quote=False) and 
escaped. Previously, collections formatting was not consistent with text 
formatting as mentioned above. With these proposed changes, retrieved text, 
map, set, list, tuple, and UDT data will be escaped and unquoted. 

For example,
{code:java}
CREATE KEYSPACE test WITH replication = {'class': 'NetworkTopologyStrategy', 
'datacenter1': 3};
USE test;
CREATE TABLE t1 (id int, data map, PRIMARY KET (id));
INSERT INTO t1 (id, data) values (1, 'I''m newb');{code}
When fetching Map data from table t1, this would have been the output prior to 
these changes:
{code:java}
 id | data
+---
  1 | {1: 'I''m newb'} {code}
Now, the data will be escaped and unquoted as such:
{code:java}
 id | data
+---
  1 | {1: I'm newb} {code}
Previously for Sets:
{code:java}
 id | data
+
  1 | {'I''m newb'} {code}
and now:
{code:java}
 id | data
+
  1 | {I'm newb}{code}
Previously for UDTs:
{code:java}
CREATE TYPE random (data text);
CREATE TABLE t5 (id int, data random, PRIMARY KEY(id));
INSERT INTO t5 (id, data) values (1, {data: 'I''m newb'});
SELECT * FROM t5;

 id | data
+--
  1 | {data: 'I''m newb'} {code}
and now:
{code:java}
 id | data
+--
  1 | {data: I'm newb} {code}

Let me know what you think!




 

 

> CQL: Unable to escape single quote in a map attribute
> ---
>
> Key: CASSANDRA-15458
> URL: https://issues.apache.org/jira/browse/CASSANDRA-15458
> Project: Cassandra
>  Issue Type: Bug
>  Components: CQL/Interpreter, CQL/Semantics
>Reporter: Abhijeet Singh
>Assignee: Yaman Ziadeh
>Priority: Normal
>  Labels: AdventCalendar2021, lhf
> Attachments: cass-screen.png
>
>
> h3. Overview
> For {{text}} attributes, CQL allows escaping single quote [using additional 
> single 
> quote|http://mail-archives.apache.org/mod_mbox/cassandra-user/201108.mbox/%3c20110803152250.294...@gmx.net%3E].
>  But applying the same syntax for a {{map}} attribute does not 
> work. Inconsistent behavior was observed between {{text}} datatype and 
> {{map}} datatype.
> h3. CQL semantic proposal
> Cassandra (CQL) should apply same escaping semantics on {{text}} and 
> text-within-map {{map}} datatypes.
> h3. Reproducing the bug:
> CREATE query: 
> {code:java}
> CREATE TABLE university.test (id int, data map, PRIMARY KEY 
> (id));{code}
>  INSERT query: 
> {code:java}
> insert into university.test (id, data) values(1, {1:'I''m newb'});{code}
> On running the aforementioned INSERT query, Cassandra inserts and returns 
> {{\{1: 'I''m newb'}}} while the expected result is {{\{1: 'I'm newb'}}}
> h3. Technical details 
> OS: CentOS 7
> Kernel: Linux 3.10.0-1062.9.1.el7.x86_64
> Cassandra version: 3.11.5
> Screenshot: [Output after SELECT query|https://i.stack.imgur.com/PLAan.png]
>   
> +Additional information for newcomers:+
> The issue seems to come from the ANTLR Lexer logic for {{STRING_LITERAL}}. A 
> unit test should also be added in {{SelectTest}}



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

-
To unsubscribe, e-mail: commits-unsubscr...@cassandra.apache.org
For additional commands, e-mail: commits-h...@cassandra.apache.org



[jira] [Commented] (CASSANDRA-15458) CQL: Unable to escape single quote in a map attribute

2022-03-18 Thread Maciej Sokol (Jira)


[ 
https://issues.apache.org/jira/browse/CASSANDRA-15458?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=17508714#comment-17508714
 ] 

Maciej Sokol commented on CASSANDRA-15458:
--

While looking at the python tests i found why there's a difference. See: 
CASSANDRA-6172

I've tested unquoting both maps and other collections and ran some tests 
locally with ccm. The error mentioned in the ticket above is not reproducible 
(atleast not with what was stated in the ticket). Also noticed that UDTs are 
quoted, which feels strange as well.

What do you think Benjamin? It's a pretty drastic change but if we want to be 
consistent we should keep everything unquoted (since everything is unquoted by 
default except when the values are in a collection).

> CQL: Unable to escape single quote in a map attribute
> ---
>
> Key: CASSANDRA-15458
> URL: https://issues.apache.org/jira/browse/CASSANDRA-15458
> Project: Cassandra
>  Issue Type: Bug
>  Components: CQL/Interpreter, CQL/Semantics
>Reporter: Abhijeet Singh
>Assignee: Maciej Sokol
>Priority: Normal
>  Labels: AdventCalendar2021, lhf
> Attachments: cass-screen.png
>
>
> h3. Overview
> For {{text}} attributes, CQL allows escaping single quote [using additional 
> single 
> quote|http://mail-archives.apache.org/mod_mbox/cassandra-user/201108.mbox/%3c20110803152250.294...@gmx.net%3E].
>  But applying the same syntax for a {{map}} attribute does not 
> work. Inconsistent behavior was observed between {{text}} datatype and 
> {{map}} datatype.
> h3. CQL semantic proposal
> Cassandra (CQL) should apply same escaping semantics on {{text}} and 
> text-within-map {{map}} datatypes.
> h3. Reproducing the bug:
> CREATE query: 
> {code:java}
> CREATE TABLE university.test (id int, data map, PRIMARY KEY 
> (id));{code}
>  INSERT query: 
> {code:java}
> insert into university.test (id, data) values(1, {1:'I''m newb'});{code}
> On running the aforementioned INSERT query, Cassandra inserts and returns 
> {{\{1: 'I''m newb'}}} while the expected result is {{\{1: 'I'm newb'}}}
> h3. Technical details 
> OS: CentOS 7
> Kernel: Linux 3.10.0-1062.9.1.el7.x86_64
> Cassandra version: 3.11.5
> Screenshot: [Output after SELECT query|https://i.stack.imgur.com/PLAan.png]
>   
> +Additional information for newcomers:+
> The issue seems to come from the ANTLR Lexer logic for {{STRING_LITERAL}}. A 
> unit test should also be added in {{SelectTest}}



--
This message was sent by Atlassian Jira
(v8.20.1#820001)

-
To unsubscribe, e-mail: commits-unsubscr...@cassandra.apache.org
For additional commands, e-mail: commits-h...@cassandra.apache.org



[jira] [Commented] (CASSANDRA-15458) CQL: Unable to escape single quote in a map attribute

2022-03-16 Thread Benjamin Lerer (Jira)


[ 
https://issues.apache.org/jira/browse/CASSANDRA-15458?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=17507451#comment-17507451
 ] 

Benjamin Lerer commented on CASSANDRA-15458:


{quote}I guess we want to have the same behavior for text as well as text in 
map.{quote}

Yes, you are right. We should have the same behavior.

Nice work in finding the root cause of the problem :-)  

> CQL: Unable to escape single quote in a map attribute
> ---
>
> Key: CASSANDRA-15458
> URL: https://issues.apache.org/jira/browse/CASSANDRA-15458
> Project: Cassandra
>  Issue Type: Bug
>  Components: CQL/Interpreter, CQL/Semantics
>Reporter: Abhijeet Singh
>Assignee: Maciej Sokol
>Priority: Normal
>  Labels: AdventCalendar2021, lhf
> Attachments: cass-screen.png
>
>
> h3. Overview
> For {{text}} attributes, CQL allows escaping single quote [using additional 
> single 
> quote|http://mail-archives.apache.org/mod_mbox/cassandra-user/201108.mbox/%3c20110803152250.294...@gmx.net%3E].
>  But applying the same syntax for a {{map}} attribute does not 
> work. Inconsistent behavior was observed between {{text}} datatype and 
> {{map}} datatype.
> h3. CQL semantic proposal
> Cassandra (CQL) should apply same escaping semantics on {{text}} and 
> text-within-map {{map}} datatypes.
> h3. Reproducing the bug:
> CREATE query: 
> {code:java}
> CREATE TABLE university.test (id int, data map, PRIMARY KEY 
> (id));{code}
>  INSERT query: 
> {code:java}
> insert into university.test (id, data) values(1, {1:'I''m newb'});{code}
> On running the aforementioned INSERT query, Cassandra inserts and returns 
> {{\{1: 'I''m newb'}}} while the expected result is {{\{1: 'I'm newb'}}}
> h3. Technical details 
> OS: CentOS 7
> Kernel: Linux 3.10.0-1062.9.1.el7.x86_64
> Cassandra version: 3.11.5
> Screenshot: [Output after SELECT query|https://i.stack.imgur.com/PLAan.png]
>   
> +Additional information for newcomers:+
> The issue seems to come from the ANTLR Lexer logic for {{STRING_LITERAL}}. A 
> unit test should also be added in {{SelectTest}}



--
This message was sent by Atlassian Jira
(v8.20.1#820001)

-
To unsubscribe, e-mail: commits-unsubscr...@cassandra.apache.org
For additional commands, e-mail: commits-h...@cassandra.apache.org



[jira] [Commented] (CASSANDRA-15458) CQL: Unable to escape single quote in a map attribute

2022-03-16 Thread Maciej Sokol (Jira)


[ 
https://issues.apache.org/jira/browse/CASSANDRA-15458?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=17507423#comment-17507423
 ] 

Maciej Sokol commented on CASSANDRA-15458:
--

I've continued searching and found where the issue is, it's in 
pylib/cqlshlib/formatting.py.

When map is formatted quote=True is sent to the format function and when text 
is formatted quote=False is sent. I.e changing quote=False in the 
format_value_map will produce the same results as for text.
{code:java}
SELECT * FROM test.t1;
 id | data
+--
  1 | I'm newb

SELECT * FROM test.t2;
 id | data
+---
  1 | {1: I'm newb} {code}
So the question arises here, do we want to quote or not quote? I guess we want 
to have the same behavior for text as well as text in map.

> CQL: Unable to escape single quote in a map attribute
> ---
>
> Key: CASSANDRA-15458
> URL: https://issues.apache.org/jira/browse/CASSANDRA-15458
> Project: Cassandra
>  Issue Type: Bug
>  Components: CQL/Interpreter, CQL/Semantics
>Reporter: Abhijeet Singh
>Assignee: Maciej Sokol
>Priority: Normal
>  Labels: AdventCalendar2021, lhf
> Attachments: cass-screen.png
>
>
> h3. Overview
> For {{text}} attributes, CQL allows escaping single quote [using additional 
> single 
> quote|http://mail-archives.apache.org/mod_mbox/cassandra-user/201108.mbox/%3c20110803152250.294...@gmx.net%3E].
>  But applying the same syntax for a {{map}} attribute does not 
> work. Inconsistent behavior was observed between {{text}} datatype and 
> {{map}} datatype.
> h3. CQL semantic proposal
> Cassandra (CQL) should apply same escaping semantics on {{text}} and 
> text-within-map {{map}} datatypes.
> h3. Reproducing the bug:
> CREATE query: 
> {code:java}
> CREATE TABLE university.test (id int, data map, PRIMARY KEY 
> (id));{code}
>  INSERT query: 
> {code:java}
> insert into university.test (id, data) values(1, {1:'I''m newb'});{code}
> On running the aforementioned INSERT query, Cassandra inserts and returns 
> {{\{1: 'I''m newb'}}} while the expected result is {{\{1: 'I'm newb'}}}
> h3. Technical details 
> OS: CentOS 7
> Kernel: Linux 3.10.0-1062.9.1.el7.x86_64
> Cassandra version: 3.11.5
> Screenshot: [Output after SELECT query|https://i.stack.imgur.com/PLAan.png]
>   
> +Additional information for newcomers:+
> The issue seems to come from the ANTLR Lexer logic for {{STRING_LITERAL}}. A 
> unit test should also be added in {{SelectTest}}



--
This message was sent by Atlassian Jira
(v8.20.1#820001)

-
To unsubscribe, e-mail: commits-unsubscr...@cassandra.apache.org
For additional commands, e-mail: commits-h...@cassandra.apache.org



[jira] [Commented] (CASSANDRA-15458) CQL: Unable to escape single quote in a map attribute

2022-03-15 Thread Maciej Sokol (Jira)


[ 
https://issues.apache.org/jira/browse/CASSANDRA-15458?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=17506863#comment-17506863
 ] 

Maciej Sokol commented on CASSANDRA-15458:
--

I've started looking at the lexer and didn't found any faults. Created a 
unittest and it passes... Tried reproducing in ccm and indeed there seems to be 
some kind of a bug.

Added debug logs to UpdateStatement class to make sure that the values are 
coming in correctly and they're:

t1:

1,'I'm newb

t2

1,\{1: 'I'm newb'}
{code:java}
CREATE KEYSPACE test WITH replication = {'class': 'NetworkTopologyStrategy', 
'datacenter1': 3};
CREATE TABLE test.t1 (id int, data text, PRIMARY KEY (id));
CREATE TABLE test.t2 (id int, data map, PRIMARY KEY (id));
INSERT INTO test.t1 (id, data) values(1, 'I''m newb');
INSERT INTO test.t2 (id, data) values(1, {1:'I''m newb'});
SELECT data from test.t1; data
--
 I'm newb
SELECT data from test.t2; data
--
 {1: 'I''m newb'}{code}
[~blerer] do you have any ideas where to look further? I'm kinda stuck right now

> CQL: Unable to escape single quote in a map attribute
> ---
>
> Key: CASSANDRA-15458
> URL: https://issues.apache.org/jira/browse/CASSANDRA-15458
> Project: Cassandra
>  Issue Type: Bug
>  Components: CQL/Interpreter, CQL/Semantics
>Reporter: Abhijeet Singh
>Assignee: Maciej Sokol
>Priority: Normal
>  Labels: AdventCalendar2021, lhf
> Attachments: cass-screen.png
>
>
> h3. Overview
> For {{text}} attributes, CQL allows escaping single quote [using additional 
> single 
> quote|http://mail-archives.apache.org/mod_mbox/cassandra-user/201108.mbox/%3c20110803152250.294...@gmx.net%3E].
>  But applying the same syntax for a {{map}} attribute does not 
> work. Inconsistent behavior was observed between {{text}} datatype and 
> {{map}} datatype.
> h3. CQL semantic proposal
> Cassandra (CQL) should apply same escaping semantics on {{text}} and 
> text-within-map {{map}} datatypes.
> h3. Reproducing the bug:
> CREATE query: 
> {code:java}
> CREATE TABLE university.test (id int, data map, PRIMARY KEY 
> (id));{code}
>  INSERT query: 
> {code:java}
> insert into university.test (id, data) values(1, {1:'I''m newb'});{code}
> On running the aforementioned INSERT query, Cassandra inserts and returns 
> {{\{1: 'I''m newb'}}} while the expected result is {{\{1: 'I'm newb'}}}
> h3. Technical details 
> OS: CentOS 7
> Kernel: Linux 3.10.0-1062.9.1.el7.x86_64
> Cassandra version: 3.11.5
> Screenshot: [Output after SELECT query|https://i.stack.imgur.com/PLAan.png]
>   
> +Additional information for newcomers:+
> The issue seems to come from the ANTLR Lexer logic for {{STRING_LITERAL}}. A 
> unit test should also be added in {{SelectTest}}



--
This message was sent by Atlassian Jira
(v8.20.1#820001)

-
To unsubscribe, e-mail: commits-unsubscr...@cassandra.apache.org
For additional commands, e-mail: commits-h...@cassandra.apache.org