Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[YCQL] Incorrect TOJSON() output for nested UDT #18344

Closed
1 task done
OlegLoginov opened this issue Jul 20, 2023 · 2 comments
Closed
1 task done

[YCQL] Incorrect TOJSON() output for nested UDT #18344

OlegLoginov opened this issue Jul 20, 2023 · 2 comments

Comments

@OlegLoginov
Copy link
Contributor

OlegLoginov commented Jul 20, 2023

Jira Link: DB-7332

Description

The issue:
YB:

ycqlsh:a> create type UDT1 (a int, b int);
ycqlsh:a> create type UDT2 (c int, d frozen<UDT1>);
ycqlsh:a> create table t5 (h int primary key, v UDT2);
ycqlsh:a> insert into t5 (h,v) values (1, {c:1, d:{a:1, b:1}});
ycqlsh:a> select v from t5;
 v
-------------------------
 {c: 1, d: {a: 1, b: 1}}
(1 rows)
ycqlsh:a> select tojson(v) from t5;
 server_tojson(v)
-------------------
 {"c":1,"d":[1,1]}      <<<<< ERROR!
(1 rows)

Cassandra:

cqlsh:a> create type UDT1 (a int, b int);
cqlsh:a> create type UDT2 (c int, d frozen<UDT1>);
cqlsh:a> create table t5 (h int primary key, v UDT2);
cqlsh:a> insert into t5 (h,v) values (1, {c:1, d:{a:1, b:1}});
cqlsh:a> select v from t5;
 v
-------------------------
 {c: 1, d: {a: 1, b: 1}}
(1 rows)
cqlsh:a> select tojson(v) from t5;
 system.tojson(v)
---------------------------------
 {"c": 1, "d": {"a": 1, "b": 1}}       <<<< OK!
(1 rows)

Warning: Please confirm that this issue does not contain any sensitive information

  • I confirm this issue does not contain any sensitive information.
@OlegLoginov OlegLoginov added kind/bug This issue is a bug area/ycql Yugabyte CQL (YCQL) status/awaiting-triage Issue awaiting triage labels Jul 20, 2023
@OlegLoginov OlegLoginov added this to To Do in YCQL via automation Jul 20, 2023
@yugabyte-ci yugabyte-ci added the priority/medium Medium priority issue label Jul 20, 2023
@OlegLoginov
Copy link
Contributor Author

OlegLoginov commented Jul 20, 2023

Note that for the first level of nesting it works correctly:
YB:

ycqlsh:a> create type UDT1 (a int, b int);
ycqlsh:a> create table t4 (h int primary key, v UDT1);
ycqlsh:a> insert into t4 (h,v) values (1, {a:1, b:1});
ycqlsh:a> select v from t4;
 v
--------------
 {a: 1, b: 1}
(1 rows)
ycqlsh:a> select tojson(v) from t4;
 server_tojson(v)
------------------
    {"a":1,"b":1}        <<<< OK!
(1 rows)

Cassandra:

cqlsh:a> insert into t4 (h,v) values (1, {a:1, b:1});
cqlsh:a> select v from t4;
 v
--------------
 {a: 1, b: 1}
(1 rows)
cqlsh:a> select tojson(v) from t4;
 system.tojson(v)
------------------
 {"a": 1, "b": 1}        <<< OK
(1 rows)

@yugabyte-ci yugabyte-ci removed the status/awaiting-triage Issue awaiting triage label Jul 22, 2023
@OlegLoginov OlegLoginov self-assigned this Aug 3, 2023
@OlegLoginov
Copy link
Contributor Author

Note: The issue affects any UDT< FROZEN<*> > combinations - including UDT< FROZEN<UDT> >, UDT< FROZEN<LIST> >, UDT< FROZEN<SET> >, UDT< FROZEN<MAP> >, etc.

OlegLoginov added a commit that referenced this issue Aug 7, 2023
Summary:
Before the fix the `TOJSON()` implementation in DocDB did not
unpack UDT if it's a field in a parent UDT (a nested UDT).
Now it's fixed.

The issue affects any `UDT< FROZEN<*> >` combinations - including
`UDT< FROZEN<UDT> >`,  `UDT< FROZEN<LIST> >`,
`UDT< FROZEN<SET> >` and `UDT< FROZEN<MAP> >`.

Note: UDT=User Defined Type
Jira: DB-7332

Test Plan:
ybd --cxx-test ql_ql-select-expr-test --gtest_filter QLTestSelectedExpr.TestQLSelectToJson
ybd --java-test org.yb.cql.TestSelect#testToJson

Reviewers: mihnea, stiwary

Reviewed By: stiwary

Subscribers: ybase, yql

Differential Revision: https://phorge.dev.yugabyte.com/D27544
OlegLoginov added a commit that referenced this issue Aug 9, 2023
Summary:
Original commit: 8b54187 / D27544
GH link: 8b54187

Before the fix the `TOJSON()` implementation in DocDB did not
unpack UDT if it's a field in a parent UDT (a nested UDT).
Now it's fixed.

The issue affects any `UDT< FROZEN<*> >` combinations - including
`UDT< FROZEN<UDT> >`,  `UDT< FROZEN<LIST> >`,
`UDT< FROZEN<SET> >` and `UDT< FROZEN<MAP> >`.

Note: UDT=User Defined Type
Jira: DB-7332

Test Plan:
ybd --cxx-test ql_ql-select-expr-test --gtest_filter QLTestSelectedExpr.TestQLSelectToJson
ybd --java-test org.yb.cql.TestSelect#testToJson

Reviewers: mihnea, stiwary, pjain

Reviewed By: pjain

Subscribers: pjain, yql, ybase

Differential Revision: https://phorge.dev.yugabyte.com/D27592
OlegLoginov added a commit that referenced this issue Aug 9, 2023
Summary:
Original commit: 8b54187 / D27544
GH link: 8b54187

Before the fix the `TOJSON()` implementation in DocDB did not
unpack UDT if it's a field in a parent UDT (a nested UDT).
Now it's fixed.

The issue affects any `UDT< FROZEN<*> >` combinations - including
`UDT< FROZEN<UDT> >`,  `UDT< FROZEN<LIST> >`,
`UDT< FROZEN<SET> >` and `UDT< FROZEN<MAP> >`.

Note: UDT=User Defined Type
Jira: DB-7332

Test Plan:
ybd --cxx-test ql_ql-select-expr-test --gtest_filter QLTestSelectedExpr.TestQLSelectToJson
ybd --java-test org.yb.cql.TestSelect#testToJson

Reviewers: mihnea, stiwary, pjain

Reviewed By: pjain

Subscribers: pjain, yql, ybase

Differential Revision: https://phorge.dev.yugabyte.com/D27593
OlegLoginov added a commit that referenced this issue Aug 9, 2023
Summary:
Original commit: 8b54187 / D27544
GH link: 8b54187

Before the fix the `TOJSON()` implementation in DocDB did not
unpack UDT if it's a field in a parent UDT (a nested UDT).
Now it's fixed.

The issue affects any `UDT< FROZEN<*> >` combinations - including
`UDT< FROZEN<UDT> >`,  `UDT< FROZEN<LIST> >`,
`UDT< FROZEN<SET> >` and `UDT< FROZEN<MAP> >`.

Note: UDT=User Defined Type
Jira: DB-7332

Test Plan:
ybd --cxx-test ql_ql-select-expr-test --gtest_filter QLTestSelectedExpr.TestQLSelectToJson
ybd --java-test org.yb.cql.TestSelect#testToJson

Reviewers: mihnea, stiwary, pjain

Reviewed By: pjain

Subscribers: pjain, yql, ybase

Differential Revision: https://phorge.dev.yugabyte.com/D27591
YCQL automation moved this from To Do to Done Aug 9, 2023
OlegLoginov added a commit that referenced this issue Aug 10, 2023
Summary:
Fixing the test which was introduced in the diff: D27544.
Commit: 8b54187

Fixed unstable error:
```
Cannot delete type 'cql_test_keyspace.udt'. It is used in field u1 of type 'udt8'
```
Because the test framework can try to delete the `udt` type before the parent type `udt8`.
Jira: DB-7332

Test Plan:
Jenkins: test regex: .*ToJson.*

ybd --java-test org.yb.cql.TestSelect#testToJson

ybd --cxx-test ql_ql-select-expr-test --gtest_filter QLTestSelectedExpr.TestQLSelectToJson

Reviewers: mihnea, pjain, stiwary

Reviewed By: pjain

Subscribers: yql

Differential Revision: https://phorge.dev.yugabyte.com/D27639
OlegLoginov added a commit that referenced this issue Aug 11, 2023
…stToJson

Summary:
Original commit: 2be0a41 / D27639
GH link: 2be0a41

Fixing the test which was introduced in the diff: D27544.
Commit: 8b54187

Fixed unstable error:
```
Cannot delete type 'cql_test_keyspace.udt'. It is used in field u1 of type 'udt8'
```
Because the test framework can try to delete the `udt` type before the parent type `udt8`.
Jira: DB-7332

Test Plan:
Jenkins: test regex: .*ToJson.*

ybd --java-test org.yb.cql.TestSelect#testToJson

ybd --cxx-test ql_ql-select-expr-test --gtest_filter QLTestSelectedExpr.TestQLSelectToJson

Reviewers: mihnea, pjain, stiwary

Reviewed By: pjain

Subscribers: yql

Differential Revision: https://phorge.dev.yugabyte.com/D27712
OlegLoginov added a commit that referenced this issue Aug 11, 2023
…stToJson

Summary:
Original commit: 2be0a41 / D27639
GH link: 2be0a41

Fixing the test which was introduced in the diff: D27544.
Commit: 8b54187

Fixed unstable error:
```
Cannot delete type 'cql_test_keyspace.udt'. It is used in field u1 of type 'udt8'
```
Because the test framework can try to delete the `udt` type before the parent type `udt8`.
Jira: DB-7332

Test Plan:
Jenkins: test regex: .*ToJson.*

ybd --java-test org.yb.cql.TestSelect#testToJson

ybd --cxx-test ql_ql-select-expr-test --gtest_filter QLTestSelectedExpr.TestQLSelectToJson

Reviewers: mihnea, pjain, stiwary

Reviewed By: pjain

Subscribers: yql

Differential Revision: https://phorge.dev.yugabyte.com/D27711
OlegLoginov added a commit that referenced this issue Aug 11, 2023
…stToJson

Summary:
Original commit: 2be0a41 / D27639
GH link: 2be0a41

Fixing the test which was introduced in the diff: D27544.
Commit: 8b54187

Fixed unstable error:
```
Cannot delete type 'cql_test_keyspace.udt'. It is used in field u1 of type 'udt8'
```
Because the test framework can try to delete the `udt` type before the parent type `udt8`.
Jira: DB-7332

Test Plan:
Jenkins: test regex: .*ToJson.*

ybd --java-test org.yb.cql.TestSelect#testToJson

ybd --cxx-test ql_ql-select-expr-test --gtest_filter QLTestSelectedExpr.TestQLSelectToJson

Reviewers: mihnea, pjain, stiwary

Reviewed By: pjain

Subscribers: yql

Differential Revision: https://phorge.dev.yugabyte.com/D27710
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
YCQL
  
Done
Development

No branches or pull requests

2 participants