def add(
        self,
        table,
        check,
        violations=-1,
        rc=-1,
        check_status="active",
        check_type="rule",
        check_policy_type="quality",
        check_mode="full",
        check_unit="rows",
        check_scope=-1,
        check_severity_score=-1,
        run_start_timestamp=None,
        run_stop_timestamp=None,
        data_start_timestamp=None,
        data_stop_timestamp=None,
        setup_vars=None,
    ):
        assert core.isnumeric(rc)
        assert violations is None or core.isnumeric(violations), "Invalid violations: %s" % violations
        assert check_type in ("rule", "profile", "setup", "teardown")
        assert check_policy_type in ("quality", "consistency", "data-management"), (
            "invalid policy_type: %s" % check_policy_type
        )
        assert check_unit in ("rows", "tables")
        assert check_mode in ("full", "incremental", "auto", None), "invalid check_mode: %s" % check_mode
        assert check_status in (None, "active", "inactive")
        assert core.isnumeric(check_scope)
        assert core.isnumeric(check_severity_score)
        assert isinstance(run_start_timestamp, datetime.datetime)
        assert isinstance(run_stop_timestamp, datetime.datetime)

        if table not in self.results:
            self.results[table] = {}
        if check not in self.results[table]:
            self.results[table][check] = {}

        self.results[table][check]["violation_cnt"] = violations
        self.results[table][check]["rc"] = int(rc)
        self.results[table][check]["check_status"] = check_status
        self.results[table][check]["check_unit"] = check_unit
        self.results[table][check]["check_type"] = check_type
        self.results[table][check]["check_policy_type"] = check_type
        self.results[table][check]["check_mode"] = "" if check_mode is None else check_mode
        self.results[table][check]["check_scope"] = check_scope
        self.results[table][check]["check_severity_score"] = check_severity_score
        self.results[table][check]["run_start_timestamp"] = run_start_timestamp
        self.results[table][check]["run_stop_timestamp"] = run_stop_timestamp
        self.results[table][check]["data_start_timestamp"] = data_start_timestamp
        self.results[table][check]["data_stop_timestamp"] = data_stop_timestamp
        self.results[table][check]["setup_vars"] = "" if setup_vars is None else json.dumps(setup_vars)
    def _parse_raw_output(self):
        try:
            output_vars = json.loads(self.raw_output)
        except (TypeError, ValueError):
            self.check_logger.error("invalid check results: %s" % self.raw_output)
            if self.raw_output is None:
                self.check_logger.error("check results raw_output is None")
            raise

        for key, val in output_vars.items():
            if self._is_reserved_var(key):
                if key == 'rc':
                    self.internal_rc = val
                elif key == 'mode':
                    self.mode = val
                elif key == 'log':
                    self.check_logger.info(val)
                    self.log = val
                elif key == 'violations':
                    self.violation_cnt = val
                    if not core.isnumeric(val):
                        self.check_logger.error("invalid violations field")
                        self.violations_cnt = -1
            elif key.startswith('hapinsp_tablecustom_'):
                self.check_logger.debug('%s=%s', key, val)
            elif key.startswith('hapinsp_'):
                self.check_logger.debug('%s=%s', key, val)
            else:
                msg = "Invalid check result - key has bad name: %s" % key
                self.check_logger.error(msg)
                raise ValueError(msg)

        if self.violation_cnt is None:
            raise ValueError('invalid violation_cnt')
        elif self.internal_rc is None:
            raise ValueError('invalid internal_rc')