Query Filters

Query filters are used in conditions to:

  • narrow down the scope of affected queries

  • narrow down the scope of queries which can be killed

Example usage:

QueryFilter(
    # Include users with names with specific prefixes
    include_user_name=["ANALYST_*", "DATA_SCIENCE_*"],
    # Exclude user with specific name 
    exclude_user_name=["ANALYST_JOHN_DOE"],
)
QueryFilter(
    # Include queries running on warehouses with specific suffixes
    include_warehouse=["*_SMALL_WH", "*_MEDIUM_WH"],
    # Include users with emails from specific org
    include_user_email=["*@myorg.com"]
)
QueryFilter(
    # Exclude queries with comment "--no-kill" in SQL text
    exclude_sql_text=["*--no-kill"]
)

Filter Arguments

  • include_user_name (str|Pattern) - include users with names matching patterns

  • exclude_user_name (str|Pattern) - exclude users with names matching patterns

  • include_user_login_name (str|Pattern) - include users with login names matching patterns

  • exclude_user_login_name (str|Pattern) - exclude users with login names matching patterns

  • include_user_email (str|Pattern) - include users with emails matching patterns

  • exclude_user_email (str|Pattern) - exclude users with emails matching patterns

  • include_warehouse_name (str|Pattern) - include queries running on warehouses with names matching patterns

  • exclude_warehouse_name (str|Pattern) - exclude queries running on warehouses with names matching patterns

  • include_sql_text (str|Pattern) - include queries with SQL text matching patterns

  • exclude_sql_text (str|Pattern) - exclude queries with SQL text matching patterns

  • include_query_tag (str|Pattern) - include queries with Query Tag matching patterns

  • exclude_query_tag (str|Pattern) - exclude queries with Query Tag matching patterns

Usage notes

  1. Individual patterns in one argument are combined with OR-logic. If at least one pattern returns true, the whole argument check returns true.

  2. Multiple arguments are combined with AND-logic. All specified arguments should return true in order for query to match filter.

  3. String patterns are interpreted as basic Unix filename patterns , with * matching everything and ? matching single character.

  4. For more complex cases, it is allowed to use free-form Pattern objects produced by re.compile function. Such patterns should match the full string.

Last updated