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

Records with a JSON column aren't deleted correctly #37205

Closed
melvynator opened this issue May 13, 2022 · 0 comments · Fixed by #37266
Closed

Records with a JSON column aren't deleted correctly #37205

melvynator opened this issue May 13, 2022 · 0 comments · Fixed by #37266
Assignees
Labels
comp-type-object potential bug To be reviewed by developers and confirmed/rejected.

Comments

@melvynator
Copy link
Member

Describe what's wrong

Record with a JSON column seems to not be deleted correctly.

Does it reproduce on recent release?

Yes

How to reproduce

First let's create the table with a JSON column.

CREATE TABLE testJson
(
    `id` UInt32,
    `fields` JSON
)
ENGINE = ReplicatedMergeTree
ORDER BY id
SETTINGS index_granularity = 8192

Let's add a row to the table:

INSERT INTO testJson  (id, fields) VALUES (1,'{"fieldInteger":1,"fieldBoolean":true,"fieldFloat":1.23,"fieldString":"StringValue"}');

Let's check that the row has been properly inserted.

SELECT *
FROM testJson

Query id: 62875aa8-67fc-46ee-80b3-382346bbf255

┌─id─┬─fields───────────────────┐
│  1 │ (1,1.23,1,'StringValue') │
└────┴──────────────────────────┘

1 row in set. Elapsed: 0.158 sec.

Then I delete the element

ALTER TABLE testJson
    DELETE WHERE id = 1

Query id: 288c33ed-75c4-42fc-ac04-bbce2cc325e3

┌─host──────────────────────────┬─status─┬─error─┬─num_hosts_remaining─┬─num_hosts_active─┐
│ default|host-1 │      0 │       │                   1 │                1 │
└───────────────────────────────┴────────┴───────┴─────────────────────┴──────────────────┘
┌─host──────────────────────────┬─status─┬─error─┬─num_hosts_remaining─┬─num_hosts_active─┐
│ default|host-2 │      0 │       │                   0 │                0 │
└───────────────────────────────┴────────┴───────┴─────────────────────┴──────────────────┘

2 rows in set. Elapsed: 0.366 sec.

Let's verify that the record has been deleted:

SELECT *
FROM testJson

Query id: 62875aa8-67fc-46ee-80b3-382346bbf255

┌─id─┬─fields───────────────────┐
│  1 │ (1,1.23,1,'StringValue') │
└────┴──────────────────────────┘

1 row in set. Elapsed: 0.158 sec.

The record is still there.

Expected behavior

The row should have been deleted like in the below example:

CREATE TABLE testString
(
    `id` UInt32,
    `fields` String
)
ENGINE = ReplicatedMergeTree
ORDER BY id
SETTINGS index_granularity = 8192

Let's insert a row:

INSERT INTO testString  (id, fields) VALUES (1,'test');

Let's check that the record is there:

SELECT *
FROM testString

Query id: b2f8f509-3633-43fc-9be7-a797492df0bb

┌─id─┬─fields─┐
│  1 │ test   │
└────┴────────┘

1 rows in set. Elapsed: 0.202 sec.

Let's remove it:

ALTER TABLE testJson
    DELETE WHERE id = 1

Query id: 10ad5930-9102-4297-96c3-ae1fdef09d50

┌─host──────────────────────────┬─status─┬─error─┬─num_hosts_remaining─┬─num_hosts_active─┐
│ default|host-1 │      0 │       │                   1 │                1 │
└───────────────────────────────┴────────┴───────┴─────────────────────┴──────────────────┘
┌─host──────────────────────────┬─status─┬─error─┬─num_hosts_remaining─┬─num_hosts_active─┐
│ default|host-2│      0 │       │                   0 │                0 │
└───────────────────────────────┴────────┴───────┴─────────────────────┴──────────────────┘

2 rows in set. Elapsed: 0.339 sec.

It's being deleted correctly:

SELECT *
FROM testString

Query id: fe3c0ea5-cc5a-41c0-be69-04c12d80cd93

Ok.

0 rows in set. Elapsed: 0.156 sec.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
comp-type-object potential bug To be reviewed by developers and confirmed/rejected.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants