Skip to content

Commit

Permalink
Merge #43988
Browse files Browse the repository at this point in the history
43988: distsql: fix columnar operators test harness r=yuzefovich a=yuzefovich

Previously, we incorrectly surrounded a randomly generated constant
datum with single quotes if its string representation contained `NaN`
or `Inf`, regardless of the type. However, this surrounding should only
happen when we're working with numeric types.

Fixes: #43945.

Release note: None

Co-authored-by: Yahor Yuzefovich <yahor@cockroachlabs.com>
  • Loading branch information
craig[bot] and yuzefovich committed Jan 16, 2020
2 parents 7fa1936 + 4cc7777 commit e2c2be6
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions pkg/sql/distsql/columnar_operators_test.go
Expand Up @@ -606,9 +606,13 @@ func generateFilterExpr(
}
constDatum := sqlbase.RandDatum(rng, &colTypes[colIdx], true /* nullOk */)
constDatumString := constDatum.String()
if strings.Contains(constDatumString, "NaN") || strings.Contains(constDatumString, "Inf") {
// We need to surround special values with quotes.
constDatumString = fmt.Sprintf("'%s'", constDatumString)
switch colTypes[colIdx].Family() {
case types.FloatFamily, types.DecimalFamily:
if strings.Contains(strings.ToLower(constDatumString), "nan") ||
strings.Contains(strings.ToLower(constDatumString), "inf") {
// We need to surround special numerical values with quotes.
constDatumString = fmt.Sprintf("'%s'", constDatumString)
}
}
return execinfrapb.Expression{Expr: fmt.Sprintf("@%d %s %s", colIdx+1, comparison, constDatumString)}
}
Expand Down

0 comments on commit e2c2be6

Please sign in to comment.