Skip to content

Commit

Permalink
opt: print error details in expropt test directive
Browse files Browse the repository at this point in the history
Error details are now printed in the output of the `expropt` optimizer
test directive. This is helpful for seeing the formatted memo that is
included in the detail of the error that occurs when a memo cycle is
detected.

Release note: None
  • Loading branch information
mgartner committed May 7, 2022
1 parent 40d8803 commit dd35ff8
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
3 changes: 3 additions & 0 deletions pkg/sql/opt/testutils/opttester/opt_tester.go
Original file line number Diff line number Diff line change
Expand Up @@ -739,6 +739,9 @@ func (ot *OptTester) RunCommand(tb testing.TB, d *datadriven.TestData) string {
case "expropt":
e, err := ot.ExprOpt()
if err != nil {
if len(errors.GetAllDetails(err)) > 0 {
return fmt.Sprintf("error: %s\ndetails:\n%s", err, errors.FlattenDetails(err))
}
return fmt.Sprintf("error: %s\n", err)
}
ot.postProcess(tb, d, e)
Expand Down
11 changes: 11 additions & 0 deletions pkg/sql/opt/xform/testdata/rules/cycle
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,14 @@ expropt
)
----
error: memo group optimization passes surpassed limit of 100000; there may be a cycle in the memo
details:
memo (not optimized, ~3KB, required=[])
├── G1: (memo-cycle-test-rel G2 G3) (memo-cycle-test-rel G1 G3)
├── G2: (scan ab,cols=(1,2)) (scan ab@ab_b_idx,cols=(1,2))
│ └── []
│ ├── best: (scan ab,cols=(1,2))
│ └── cost: 1064.42
├── G3: (filters G4)
├── G4: (eq G5 G6)
├── G5: (variable b)
└── G6: (const 1)

0 comments on commit dd35ff8

Please sign in to comment.