示例#1
0
 def apply_rule(self, context, dq_cls, rule):
     e = get_executor(rule)
     logging.info(f"Executing rule `{rule}`.")
     results = e.execute(rule)
     obj = dq_cls()
     obj.init_row(rule, results, self.conn, context)
     return obj
示例#2
0
 def sql_with_where(self):
     """
     Adds `where` statement with time filter and/or user-defined condition to SQL statement.
     Could be tricky, you need to format your SQL query so WHERE statement fits to the end of it
     :return:
     """
     e = get_executor(SqlRule)
     where_clause = "WHERE "
     where_time_filter = e.compose_where_time_filter(self)
     where_condition = e.compose_where_condition(self)
     if where_time_filter == "" and where_condition == "":
         where_clause = ""
     elif where_time_filter != "" and where_condition != "":
         where_clause = f"{where_clause} {where_time_filter} AND {where_condition}"
     else:
         where_clause = f"{where_clause} {where_time_filter} {where_condition}"
     final_sql = f"{self.sql} {where_clause}"
     return self.render_sql(final_sql)
示例#3
0
 def get_sql_parameters(self):
     e = get_executor(self.__class__)
     return e.context