def apply_metaquery_filter(session, query, metaquery):
 for (k, value) in six.iteritems(metaquery):
  key = k[9:]
  try:
   _model = sql_utils.META_TYPE_MAP[type(value)]
  except KeyError:
   raise ceilometer.NotImplementedError(('Query on %(key)s is of %(value)s type and is not supported' % {'key': k, 'value': type(value)}))
  else:
   meta_alias = aliased(_model)
   on_clause = and_((models.Resource.internal_id == meta_alias.id), (meta_alias.meta_key == key))
   query = query.outerjoin(meta_alias, on_clause)
   query = query.filter((meta_alias.value == value))
 return query

def apply_metaquery_filter ( session , query , metaquery ) : for ( k , value ) in six . iteritems ( metaquery ) : key = k [ 9 : ] try : _model = sql_utils . META_TYPE_MAP [ type ( value ) ] except KeyError : raise ceilometer . NotImplementedError ( ( 'Query on %(key)s is of %(value)s type and is not supported' % { 'key' : k , 'value' : type ( value ) } ) ) else : meta_alias = aliased ( _model ) on_clause = and_ ( ( models . Resource . internal_id == meta_alias . id ) , ( meta_alias . meta_key == key ) ) query = query . outerjoin ( meta_alias , on_clause ) query = query . filter ( ( meta_alias . value == value ) ) return query
apply provided metaquery filter to existing query .