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

sql: DistSQL loses named tuple field names #70360

Closed
nvanbenschoten opened this issue Sep 17, 2021 · 3 comments · Fixed by #70375
Closed

sql: DistSQL loses named tuple field names #70360

nvanbenschoten opened this issue Sep 17, 2021 · 3 comments · Fixed by #70375
Labels
A-sql-execution Relating to SQL execution. A-tools-postgrest C-bug Code not up to spec/doc, specs & docs deemed correct. Solution expected to change code/behavior. T-sql-queries SQL Queries Team

Comments

@nvanbenschoten
Copy link
Member

nvanbenschoten commented Sep 17, 2021

I've found behavior that indicates that DistSQL has some negative effect on named tuples / records, causing field names to be lost. This disrupts queries that use these field names during record->json conversions.

The following example demonstrates this behavior.

./cockroach demo --empty --nodes=9

CREATE TABLE tweets (
    tweet_id   INT PRIMARY KEY,
    message    STRING NOT NULL
);
ALTER TABLE tweets SPLIT AT (SELECT generate_series(1, 100));
INSERT INTO tweets VALUES (1, 'tweet1'), (2, 'tweet2');

SET distsql = off;
SELECT json_agg(tweets.*) FROM tweets;
#                                     json_agg
# --------------------------------------------------------------------------------
#   [{"message": "tweet1", "tweet_id": 1}, {"message": "tweet2", "tweet_id": 2}]

SET distsql = on;
SELECT json_agg(tweets.*) FROM tweets;
#                          json_agg
# ----------------------------------------------------------
#   [{"f1": 2, "f2": "tweet2"}, {"f1": 1, "f2": "tweet1"}]

I have not dug into this far enough to diagnose where the problem is coming from. It's possible that this is a known issue.

Epic CRDB-10300

@nvanbenschoten nvanbenschoten added C-bug Code not up to spec/doc, specs & docs deemed correct. Solution expected to change code/behavior. A-sql-execution Relating to SQL execution. A-tools-postgrest labels Sep 17, 2021
@blathers-crl blathers-crl bot added the T-sql-queries SQL Queries Team label Sep 17, 2021
@jordanlewis
Copy link
Member

This doesn't repro for me. Can you share the EXPLAIN(DISTSQL) output of a case where it fails?

@jordanlewis
Copy link
Member

Nevermind, I found a repro.

@jordanlewis
Copy link
Member

Thanks for reporting this! It was a small bug that somehow never got noticed in the tuple type deserialization routine. #70375 should resolve it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-sql-execution Relating to SQL execution. A-tools-postgrest C-bug Code not up to spec/doc, specs & docs deemed correct. Solution expected to change code/behavior. T-sql-queries SQL Queries Team
Projects
Archived in project
Development

Successfully merging a pull request may close this issue.

2 participants