From 00e84597f8611b1c044df0e7e043a9625c5fe773 Mon Sep 17 00:00:00 2001 From: Jacob Barzee Date: Tue, 10 Dec 2024 14:59:17 -0700 Subject: [PATCH] Don't coalesce closeTime when checking against null --- .../visibility/store/sql/query_converter.go | 20 ++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/common/persistence/visibility/store/sql/query_converter.go b/common/persistence/visibility/store/sql/query_converter.go index d93e4bd9d93..f28f6d10557 100644 --- a/common/persistence/visibility/store/sql/query_converter.go +++ b/common/persistence/visibility/store/sql/query_converter.go @@ -670,13 +670,23 @@ func (c *QueryConverter) convertIsExpr(exprRef *sqlparser.Expr) error { if !ok { return query.NewConverterError("`%s` is not an 'IS' expression", sqlparser.String(*exprRef)) } - _, err := c.convertColName(&expr.Expr) - if err != nil { - return err - } + switch expr.Operator { case sqlparser.IsNullStr, sqlparser.IsNotNullStr: - // no-op + + // skip closeTime to avoid coalesce + if subExpr, ok := (expr.Expr).(*sqlparser.ColName); ok { + saAlias := strings.ReplaceAll(sqlparser.String(subExpr), "`", "") + if saAlias == searchattribute.CloseTime { + expr.Expr = closeTimeSaColName + return nil + } + } + + _, err := c.convertColName(&expr.Expr) + if err != nil { + return err + } default: return query.NewConverterError( "%s: 'IS' operator can only be used with 'NULL' or 'NOT NULL'",