Skip to content

opt: don't push limit through project when ordering on synthesized column#26683

Merged
craig[bot] merged 1 commit intocockroachdb:masterfrom
RaduBerinde:limit-project-ordering
Jun 13, 2018
Merged

opt: don't push limit through project when ordering on synthesized column#26683
craig[bot] merged 1 commit intocockroachdb:masterfrom
RaduBerinde:limit-project-ordering

Conversation

@RaduBerinde
Copy link
Copy Markdown
Member

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

@RaduBerinde RaduBerinde requested a review from a team as a code owner June 13, 2018 12:39
@RaduBerinde RaduBerinde requested a review from a team June 13, 2018 12:39
@cockroach-teamcity
Copy link
Copy Markdown
Member

This change is Reviewable

@andy-kimball
Copy link
Copy Markdown
Contributor

:lgtm:


Review status: :shipit: complete! 0 of 0 LGTMs obtained (and 1 stale)


pkg/sql/opt/norm/custom_funcs.go, line 401 at r1 (raw file):

// HasColumnsInOrdering returns true if all columns that appear in an ordering
// are output columns of the given group.
func (c *CustomFuncs) HasColumnsInOrdering(input memo.GroupID, ordering memo.PrivateID) bool {

NIT: elsewhere in the custom functions we'd abbreviate as HasColsInOrdering .


pkg/sql/opt/norm/custom_funcs.go, line 403 at r1 (raw file):

func (c *CustomFuncs) HasColumnsInOrdering(input memo.GroupID, ordering memo.PrivateID) bool {
	ord := c.f.mem.LookupPrivate(ordering).(props.Ordering)
	outCols := c.f.mem.GroupProperties(input).Relational.OutputCols

NIT: you can use the ord := c.ExtractOrdering(ordering) and outCols := c.OutputCols(input) helper methods.


Comments from Reviewable

@RaduBerinde RaduBerinde force-pushed the limit-project-ordering branch from 0d9e3d4 to 372b5d3 Compare June 13, 2018 13:17
…lumn

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
@RaduBerinde RaduBerinde force-pushed the limit-project-ordering branch from 372b5d3 to 0a51b15 Compare June 13, 2018 13:19
@RaduBerinde
Copy link
Copy Markdown
Member Author

TFTR! Updated.


Review status: :shipit: complete! 0 of 0 LGTMs obtained (and 1 stale)


Comments from Reviewable

@RaduBerinde
Copy link
Copy Markdown
Member Author

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 0a51b15 into cockroachdb:master Jun 13, 2018
@RaduBerinde RaduBerinde deleted the limit-project-ordering branch June 13, 2018 18:40
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.

3 participants