Skip to content

Commit

Permalink
Fix <field>=* prifix queries in QueryEngine
Browse files Browse the repository at this point in the history
Sometimes <field>=* prefix queries translate to <field> LIKE '%'
where condition in cassandra. Cassandra doesn't allow such where
clauses and returns error. If QE receives such where clause, ignore
it as it effectively translate to no where condition.

Added systemless test to verify the behavior

Change-Id: I893d3036fd22ce399186f4cc67812de2fa46701c
Closes-bug: #1774364
  • Loading branch information
mkheni committed Jul 27, 2018
1 parent d68e7e3 commit 0a2d02e
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
9 changes: 9 additions & 0 deletions contrail-opserver/test/utils/analytics_fixture.py
Expand Up @@ -1316,6 +1316,15 @@ def verify_where_query_prefix(self,generator_obj):
json_qstr = json.dumps(a_query.__dict__)
res = vns.post_query_json(json_qstr)
assert(len(res)>0)
a_query = Query(table="FlowSeriesTable",
start_time=(generator_obj.session_start_time),
end_time=(generator_obj.session_end_time),
select_fields=["destvn","SUM(bytes)"],
where=[[{"name":"sourcevn","value":"","op":7}]])
json_qstr = json.dumps(a_query.__dict__)
res = vns.post_query_json(json_qstr)
assert(len(res)==2)

return True

def verify_flow_table(self, generator_obj):
Expand Down
3 changes: 3 additions & 0 deletions contrail-query-engine/where_query.cc
Expand Up @@ -1534,6 +1534,9 @@ bool WhereQuery::populate_where_vec(AnalyticsQuery *m_query,
default:
break;
}
if (val == "%") {
return true;
}
GenDb::WhereIndexInfo where_info =
boost::make_tuple(columnN, db_op, val);
where_vec->push_back(where_info);
Expand Down

0 comments on commit 0a2d02e

Please sign in to comment.