diff --git a/common/pinot/pinotQueryValidator.go b/common/pinot/pinotQueryValidator.go index 3386c2bcb08..d869ff1c06c 100644 --- a/common/pinot/pinotQueryValidator.go +++ b/common/pinot/pinotQueryValidator.go @@ -437,8 +437,13 @@ func parseCloseStatus(original *sqlparser.SQLVal) (*sqlparser.SQLVal, error) { statusStr := string(original.Val) // first check if already in int64 format - if _, err := strconv.ParseInt(statusStr, 10, 64); err == nil { - return original, nil + if status, err := strconv.ParseInt(statusStr, 10, 64); err == nil { + // Instead of returning the original value, return a new SQLVal that holds the integer value + // Or it will fail the case CloseStatus = '1' + return &sqlparser.SQLVal{ + Type: sqlparser.IntVal, + Val: []byte(strconv.FormatInt(status, 10)), + }, nil } // try to parse close status string diff --git a/common/pinot/pinotQueryValidator_test.go b/common/pinot/pinotQueryValidator_test.go index fd4a99e07c3..b7c7b1025b5 100644 --- a/common/pinot/pinotQueryValidator_test.go +++ b/common/pinot/pinotQueryValidator_test.go @@ -219,15 +219,22 @@ func TestValidateQuery(t *testing.T) { query: "CustomKeywordField < 0", validated: "(JSON_MATCH(Attr, '\"$.CustomKeywordField\"<''0''') or JSON_MATCH(Attr, '\"$.CustomKeywordField[*]\"<''0'''))", }, - // TODO "Case18: custom int order by. Will have errors at run time. Doesn't support for now": { query: "CustomIntField = 0 order by CustomIntField desc", validated: "JSON_MATCH(Attr, '\"$.CustomIntField\"=''0''') order by CustomIntField desc", }, - "case 19: close status parse": { + "case19-1: close status parse string": { query: "CloseStatus = 'CONTINUED_AS_NEW'", validated: "CloseStatus = 4", }, + "case19-2: close status parse number": { + query: "CloseStatus = '1'", + validated: "CloseStatus = 1", + }, + "case19-3: close status parse normal case": { + query: "CloseStatus = 1", + validated: "CloseStatus = 1", + }, } for name, test := range tests {