'Optionally mask out the query from being saved to the database. This is because if the database contains sensitive
information like personally identifiable information, that information could be leaked into the Hue database and
logfiles.'

def _redact_query(self):

    if (global_redaction_engine.is_enabled() and ((self.type == 'notebook') or self.type.startswith('query'))):
        data_dict = self.data_dict
        snippets = data_dict.get('snippets', [])
        for snippet in snippets:
            if (snippet['type'] in ('hive', 'impala')):
                redacted_statement_raw = global_redaction_engine.redact(snippet['statement_raw'])
                if (snippet['statement_raw'] != redacted_statement_raw):
                    snippet['statement_raw'] = redacted_statement_raw
                    snippet['statement'] = global_redaction_engine.redact(snippet['statement'])
                    snippet['is_redacted'] = True
        self.data = json.dumps(data_dict)
        self.search = global_redaction_engine.redact(self.search)
