-
Notifications
You must be signed in to change notification settings - Fork 3.8k
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: tuples not properly preserved during serialization #26624
Comments
cc @RaduBerinde |
I tried to always pretty-print using the syntax |
Could we introduce syntax to annotate as tuple? Something like |
Yes that might be a solution. |
This patch adds more complete support for composite types (labeled tuples) by ensuring the following: - tuple labels are preserved during constant folding of tuple expressions. - tuple labels are preserved during expression transformations in optimizations. - subqueries in scalar contexts receive a composite type with labels. Note that there is currently a bug in DTuple serialization which break composite literals in distributed execution, so the composite type support is not fully ready yet. This is tracked as separate bug cockroachdb#26624. Release note: None
This patch adds more complete support for composite types (labeled tuples) by ensuring the following: - tuple labels are preserved during constant folding of tuple expressions. - tuple labels are preserved during expression transformations in optimizations. - subqueries in scalar contexts receive a composite type with labels. Note that there is currently a bug in DTuple serialization which break composite literals in distributed execution, so the composite type support is not fully ready yet. This is tracked as separate bug cockroachdb#26624. Release note: None
This patch adds more complete support for composite types (labeled tuples) by ensuring the following: - tuple labels are preserved during constant folding of tuple expressions. - tuple labels are preserved during expression transformations in optimizations. - subqueries in scalar contexts receive a composite type with labels. Note that there is currently a bug in DTuple serialization which break composite literals in distributed execution, so the composite type support is not fully ready yet. This is tracked as separate bug cockroachdb#26624. Release note: None
26621: sql,opt: propagate composite types (labeled tuples) r=knz a=knz Needed to resolve #24866. This patch adds more complete support for composite types (labeled tuples) by ensuring the following: - tuple labels are preserved during constant folding of tuple expressions. - tuple labels are preserved during expression transformations in optimizations. - subqueries in scalar contexts receive a composite type with labels. Note that there is currently a bug in DTuple serialization which break composite literals in distributed execution, so the composite type support is not fully ready yet. This is tracked as separate bug #26624. Release note: None 26683: opt: don't push limit through project when ordering on synthesized column r=RaduBerinde a=RaduBerinde It is invalid to push limit/offset through a projection if the ordering depends on a synthesized column. Fix the rules to check for this. Release note: None Co-authored-by: Raphael 'kena' Poss <[email protected]> Co-authored-by: Radu Berinde <[email protected]>
26628: sql: Support tuple column access and tuple stars r=knz a=knz First commits from #26621. Completes the fix to #24866 by re-activating disabled tests. This work is yet another step towards #16971. It would actually fix #16971 if it were not for #26627, #26624 and #26629. This work is yet another step towards #16971. The labeled tuples introduced in #25283 can now be accessed using their labels or using a star, e.g. `(E).*`. Release note (sql change): Labeled tuples can now be accessed using their labels (e.g. `SELECT (x).word FROM (SELECT pg_expand_keywords() AS x)` or a star (e.g. `SELECT (x).* FROM (SELECT pg_expand_keywords() AS x)`). Fixes #26720. Co-authored-by: Raphael 'kena' Poss <[email protected]> Co-authored-by: Bram Gruneir <[email protected]>
some brainstorming:
Then after that for tuples with labels we need to find a new syntax which doesn't use parentheses like the current one. We can look at that after we've solved the no-label case. |
regarding the 2nd point above. The problem of adding
So in that last case I was proposing to special case the pretty-print of |
although technically perhaps we could allow That might be another way to do solution 2. |
So I went down path (2), and one problem is that there are many special cases. It is not just I would prefer allowing |
for PARTITION, VALUES and all other places the syntax is unambiguous (nothing else than a tuple can be placed there). Therefore it never fails to roundtrip even if you dont use The ambiguity really exists only for comparisons, IIRC. |
Ok I just changed my mind and I now recognize path (2) is non-viable, but for a different reason. The problem is not the incompatibility of syntax between IN and other things. This could be indeed solved like you did in #28100. The problem is that a DTuple does not contain the "row" attribute (like Tuple does), so after constant folding, as soon as there are DTuples in the expression tree, the pretty-print creates broken expressions. As long as we try to solve this with the ROW keyword, things break like pushing down the pieces of a jigsaw puzzle:
So really the entire ROW approach is bankrupt and cannot be saved. Therefore I have changed my mind and I think that indeed the path (3) is better. There is also a simple grammar solution, which I will post shortly. |
28128: sql: casting to timestamp should strip tz info r=jordanlewis a=jordanlewis And binary operations between timestamp and timestamptz should strip the tz from the timestamptz. Confirmed that all of this behavior matches postgres (and that it didn't before). Release note (bug fix): correct casts and binary operators between timestamptz and timestamp in some cases. 28149: sql: avoid using Tuple in RangePartition r=knz a=knz Forked off #28143, needed for #25522 / #26624. The `Tuple` AST node is really for scalar tuples. RangePartition is not using a scalar tuple. So split them. Release note: None Co-authored-by: Jordan Lewis <[email protected]> Co-authored-by: Raphael 'kena' Poss <[email protected]>
28191: sql: avoid using Tuple in ValuesClause r=knz a=knz Forked off from #28143. Needed for #26624. The `Tuple` AST node is really about scalar tuples. The `VALUES` clause operands are not really scalar tuples. So instead use `Exprs` for `ValuesClause`. This will simplify later patch to fix the handling of scalar tuples. Release note: None Co-authored-by: Raphael 'kena' Poss <[email protected]>
28192: sql/parser: parsing ROW produces *Tuple, not Tuple r=knz a=knz Forked off from #28143. Needed for #26624. The tree.Tuple result of parsing tuples was immediately re-allocated on the heap in the parent action rule. This patch simplifies this by allocating on the heap upfront. Release note: None Co-authored-by: Raphael 'kena' Poss <[email protected]>
28143: sql: fix the handling of tuples in distsql r=knz a=knz Fixes #26624. Supersedes #28100. This patch fixes the bug where 0-valued and 1-valued tuples were not properly serialized in distsql processor/flow specs, causing these special tuples to not be properly supported for distributed execution. It also fixes the bug where labeled DTuples were not serialized with their tuples, causing labeled tuples to be broken with distributed execution. Release note: None 28217: storage: dissallow empty HeartbeatRequest.Now r=andreimatei a=andreimatei Release note: None 28219: distsql: fix a missing context in log message r=arjunravinarayan a=arjunravinarayan Release note: None Co-authored-by: Raphael 'kena' Poss <[email protected]> Co-authored-by: Andrei Matei <[email protected]> Co-authored-by: Arjun Narayan <[email protected]>
Found while investigating #26621.
The expression
ROW(x)
gets serialized after normalization (format withFmtParsable
) to(x)
which has a completely different meaning. This causes the following error when distribution is enabled, but not with local execution:Also all the labeled tuples lose their labels during serialization. This likely breaks distribution of queries with labeled tuples.
The text was updated successfully, but these errors were encountered: