Skip to content

sql,opt: propagate composite types (labeled tuples)#26621

Merged
craig[bot] merged 2 commits intocockroachdb:masterfrom
knz:20180612-composite-types
Jun 13, 2018
Merged

sql,opt: propagate composite types (labeled tuples)#26621
craig[bot] merged 2 commits intocockroachdb:masterfrom
knz:20180612-composite-types

Conversation

@knz
Copy link
Copy Markdown
Contributor

@knz knz commented Jun 12, 2018

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

@knz knz requested review from a team, RaduBerinde and rytaft June 12, 2018 11:15
@knz knz requested a review from a team as a code owner June 12, 2018 11:15
@knz knz requested review from a team June 12, 2018 11:15
@cockroach-teamcity
Copy link
Copy Markdown
Member

This change is Reviewable

@knz
Copy link
Copy Markdown
Contributor Author

knz commented Jun 12, 2018

@RaduBerinde @rytaft can you help me with the last remaining bit: the derived scalar type for a subquery in scalar context is not computed properly in the optimizer. Where is that type computed today?

@knz knz requested a review from BramGruneir June 12, 2018 11:19
@knz knz force-pushed the 20180612-composite-types branch from 55883bc to b4d7964 Compare June 12, 2018 11:59
@knz knz force-pushed the 20180612-composite-types branch 2 times, most recently from 855eb6a to 6b42768 Compare June 12, 2018 12:05
@knz
Copy link
Copy Markdown
Contributor Author

knz commented Jun 12, 2018

can you help me with the last remaining bit: the derived scalar type for a subquery in scalar context is not computed properly in the optimizer. Where is that type computed today?

Never mind, found it!

RFAL

@knz knz force-pushed the 20180612-composite-types branch from 6b42768 to b49c796 Compare June 12, 2018 12:46
@knz knz requested a review from a team June 12, 2018 12:46
@knz knz force-pushed the 20180612-composite-types branch from b49c796 to ba302d0 Compare June 12, 2018 14:42
@RaduBerinde
Copy link
Copy Markdown
Member

opt part LGTM


Review status: :shipit: complete! 0 of 0 LGTMs obtained


Comments from Reviewable

@knz
Copy link
Copy Markdown
Contributor Author

knz commented Jun 12, 2018

@BramGruneir can you propagate the comments you made on #26628 that really pertain to this PR here? I'd like to iterate and merge this one before I rebase the other one.

knz added 2 commits June 13, 2018 11:50
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
@knz knz force-pushed the 20180612-composite-types branch from ba302d0 to 5947420 Compare June 13, 2018 09:50
@knz
Copy link
Copy Markdown
Contributor Author

knz commented Jun 13, 2018

@BramGruneir I have replied to your comments that pertain to this PR over in #26628 (comment).

@BramGruneir
Copy link
Copy Markdown
Member

:lgtm:


Comments from Reviewable

@knz
Copy link
Copy Markdown
Contributor Author

knz commented Jun 13, 2018

TFYR!

bors r+

craig bot pushed a commit that referenced this pull request Jun 13, 2018
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 <knz@cockroachlabs.com>
Co-authored-by: Radu Berinde <radu@cockroachlabs.com>
@craig
Copy link
Copy Markdown
Contributor

craig bot commented Jun 13, 2018

Build succeeded

@craig craig bot merged commit 5947420 into cockroachdb:master Jun 13, 2018
@knz knz deleted the 20180612-composite-types branch June 13, 2018 15:35
craig bot pushed a commit that referenced this pull request Jun 14, 2018
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 <knz@cockroachlabs.com>
Co-authored-by: Bram Gruneir <bram@cockroachlabs.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

sql: support lightweight composite types for in-flight values

4 participants