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

opt: don't report invalid PruneCols from WithScan #40937

Merged
merged 1 commit into from
Sep 20, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions pkg/sql/opt/memo/logical_props_builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -751,6 +751,9 @@ func (b *logicalPropsBuilder) buildWithScanProps(ref *WithScanExpr, rel *props.R
// references.
*rel = *ref.BindingProps

// Things like PruneCols are not valid here.
rel.Rule = props.Relational{}.Rule

// Has Placeholder
// ---------------
// Overwrite this from the copied props.
Expand Down
33 changes: 33 additions & 0 deletions pkg/sql/opt/memo/testdata/logprops/with
Original file line number Diff line number Diff line change
Expand Up @@ -196,3 +196,36 @@ inner-join-apply
│ ├── fd: ()-->(3)
│ └── cte-uses: map[1:1]
└── filters (true)

# Regression test for #40930.

exec-ddl
CREATE TABLE t40930 (
s string
)
----

opt
WITH
with_4189
AS (
SELECT
tab_10102.s
FROM
t40930 AS tab_10102, (SELECT NULL) AS tab_10103 (col_24444)
)
SELECT
NULL
FROM
t40930, with_4189
----
project
├── columns: "?column?":7(unknown)
├── fd: ()-->(7)
├── prune: (7)
├── inner-join (hash)
│ ├── scan t40930
│ ├── scan tab_10102
│ └── filters (true)
└── projections
└── null [type=unknown]
6 changes: 6 additions & 0 deletions pkg/sql/opt/props/logical.go
Original file line number Diff line number Diff line change
Expand Up @@ -464,6 +464,12 @@ func (r *Relational) Verify() {
"max cardinality must be <= 1 if FDs have max 1 row: %s", r.Cardinality))
}
}
if r.IsAvailable(PruneCols) {
if !r.Rule.PruneCols.SubsetOf(r.OutputCols) {
panic(errors.AssertionFailedf("prune cols %s must be a subset of output cols %s",
log.Safe(r.Rule.PruneCols), log.Safe(r.OutputCols)))
}
}
}

// VerifyAgainst checks that the two properties don't contradict each other.
Expand Down