-- email-validation.org for Snowflake 1.0.0: Path B, a Python UDF with external network access (no cloud account). -- Docs: integrations/snowflake/README.md ("Path B"). Then check each address once with 3-check-once.sql. -- -- CREDITS: every non-NULL row a query passes to these functions is checked each time the query runs (the same -- address twice in one batch once), and a definite result costs one credit (results with status unknown, malformed -- addresses and test addresses are free). -- SELECT validate_email(email) FROM a table of 1,000,000 rows can spend up to 1,000,000 credits, and running it again -- spends them again. Check each address once into a table instead: 3-check-once.sql. Give the API key a daily credit -- cap in the dashboard. -- -- Needs: external access on your account (Snowflake turns it on for trial accounts only on request), CREATE -- INTEGRATION on the account (ACCOUNTADMIN has it) for step 3, and CREATE NETWORK RULE, CREATE SECRET and CREATE -- FUNCTION on the schema. Run it in the database and schema where the functions should live. -- 1. Where the functions may connect: our API only. For EU data residency use 'api-eu.email-validation.org' and set -- EV_REGION = "eu" in both copies of the code below. CREATE OR REPLACE NETWORK RULE ev_api_network_rule MODE = EGRESS TYPE = HOST_PORT VALUE_LIST = ('api.email-validation.org'); -- 2. The API key, as a Snowflake secret. This is the one statement that holds the key: run it on its own, typing the -- key in place of the placeholder, and do not save it in a shared worksheet. Snowflake's docs do not say whether -- its text is hidden in query history, so treat that history entry as holding the key (README, "Where the key -- lives"). CREATE OR REPLACE SECRET ev_api_key TYPE = GENERIC_STRING SECRET_STRING = ''; -- 3. The integration that lets the functions use the rule and the secret. CREATE OR REPLACE EXTERNAL ACCESS INTEGRATION ev_api_access ALLOWED_NETWORK_RULES = (ev_api_network_rule) ALLOWED_AUTHENTICATION_SECRETS = (ev_api_key) ENABLED = TRUE COMMENT = 'email-validation.org checks'; -- 4. The functions. Both hold the same code (external-access/ev_validate.py); only HANDLER differs. -- An OBJECT with status, reason, action, did_you_mean, domain, free_email, role_account, disposable, -- catch_all_domain, mx_found, processed_at, credits_used, request_id, error and error_detail. CREATE OR REPLACE FUNCTION validate_email_details(email VARCHAR) RETURNS VARIANT LANGUAGE PYTHON RETURNS NULL ON NULL INPUT VOLATILE RUNTIME_VERSION = '3.11' COMMENT = 'email-validation.org result of an address, with reason and error. Every non-NULL row is checked each run (a repeat in one batch once): see 3-check-once.sql.' PACKAGES = ('pandas') HANDLER = 'details' EXTERNAL_ACCESS_INTEGRATIONS = (ev_api_access) SECRETS = ('ev_api_key' = ev_api_key) AS $$ # email-validation.org for Snowflake 1.0.0: the Python UDF handler for the external access path (no cloud account # needed). sql/external-access.sql holds this exact code inline, twice: validate_email_details (HANDLER = 'details') # and validate_email (HANDLER = 'status'). Docs: integrations/snowflake/README.md # # Snowflake hands the handler a batch of rows at a time (a vectorized UDF). It checks each distinct non-empty address # of the batch once with POST /v1/validate, a few at a time, and returns one value per row, in the same order. Rows it # could not check get status None and an error code, never an invented status. It never retries a check: a check # that got no answer may have been charged, so it comes back as error "no_answer". # # Credits: every non-empty row is checked each time the function runs (the same address twice in one batch # once), and a definite result costs one credit (results with status unknown, malformed addresses and test # addresses are free). # # The API key comes from the Snowflake secret bound as 'ev_api_key' (SECRETS clause). Nothing is printed or logged. import json import re import threading import time import urllib.error import urllib.request from concurrent.futures import ThreadPoolExecutor try: import pandas except ImportError: # only outside Snowflake pandas = None EV_VERSION = "1.0.0" EV_USER_AGENT = "email-validation-snowflake/" + EV_VERSION # "eu" for EU data residency (then the network rule names api-eu.email-validation.org). EV_REGION = "us" EV_ORIGINS = {"us": "https://api.email-validation.org", "eu": "https://api-eu.email-validation.org"} EV_STATUSES = ("valid", "invalid", "catch_all", "unknown", "disposable") EV_ACTIONS = ("send", "send_with_caution", "remove", "retry_later") EV_SECRET_ALIAS = "ev_api_key" # Checks in flight at once per batch. EV_CONCURRENCY = 8 # The time our API may spend on one check (5 to 15 seconds), and how much longer the handler waits for its answer. EV_CHECK_TIMEOUT_S = 10 EV_ANSWER_MARGIN_S = 2 # Snowflake stops a vectorized handler call after 180 seconds: no check starts that could end after this. EV_BATCH_TIME_LIMIT_S = 150 # Rows per batch at most (Snowflake may send fewer). EV_MAX_BATCH_SIZE = 100 EV_API_ERROR_CODES = ( "invalid_request", "unauthorized", "insufficient_credits", "forbidden", "forbidden_origin", "not_found", "conflict", "length_required", "payload_too_large", "rate_limited", "abuse_throttled", "key_daily_cap", "internal_error", "service_unavailable", "upstream_capacity", ) # After one of these no further address of the batch is sent: the same answer would come back for each. EV_STOP_CODES = ( "rate_limited", "abuse_throttled", "key_daily_cap", "insufficient_credits", "service_unavailable", "upstream_capacity", ) # The key itself is wrong or may not validate: the query fails with a message (never the key). EV_KEY_CODES = ("unauthorized", "forbidden", "forbidden_origin") EV_DETAIL_FIELDS = ( "reason", "action", "did_you_mean", "domain", "free_email", "role_account", "disposable", "catch_all_domain", "mx_found", "processed_at", ) # A value our API sends back is kept only in our own shape, and never with 12 characters of the key in a row (a broken # or hostile proxy could quote the request back): a request id is req_ and letters or digits, a reason is in our # vocabulary's shape, and a detail field is a plain value. EV_REQUEST_ID = re.compile(r"req_[A-Za-z0-9]{1,60}") EV_REASON = re.compile(r"[a-z_]{1,64}") EV_PROCESSED_AT = re.compile(r"\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}(\.\d{1,9})?Z", re.ASCII) EV_KEY_RUN = 12 class EvKeyError(Exception): pass class _NoRedirect(urllib.request.HTTPRedirectHandler): # A redirect is never followed: the Authorization header must not travel to another host. def redirect_request(self, req, fp, code, msg, headers, newurl): return None _OPENER = urllib.request.build_opener(urllib.request.ProxyHandler({}), _NoRedirect) def ev_send(url, headers, body, timeout): """One POST. Returns (status, headers, body bytes); raises when no answer arrived.""" request = urllib.request.Request(url, data=body, headers=headers, method="POST") try: with _OPENER.open(request, timeout=timeout) as response: return response.status, response.headers, response.read() except urllib.error.HTTPError as error: try: data = error.read() except Exception: data = b"" return error.code, error.headers, data def _api_key(): try: from snowflake.snowpark.secrets import get_generic_secret_string except ImportError: from _snowflake import get_generic_secret_string key = get_generic_secret_string(EV_SECRET_ALIAS) key = key.strip() if isinstance(key, str) else "" if not key or any(c.isspace() for c in key): raise EvKeyError("email-validation.org: the secret ev_api_key holds no usable API key.") return key def _header(headers, name): try: value = headers.get(name) if headers is not None else None except Exception: value = None return value if isinstance(value, str) else None def _check_one(address, api_key, send, region): body = json.dumps({"email": address, "timeout": EV_CHECK_TIMEOUT_S}).encode("utf-8") headers = { "Authorization": "Bearer " + api_key, "Content-Type": "application/json", "Accept": "application/json", "User-Agent": EV_USER_AGENT, } try: status, answer_headers, data = send( EV_ORIGINS[region] + "/v1/validate", headers, body, EV_CHECK_TIMEOUT_S + EV_ANSWER_MARGIN_S ) except Exception: return {"error": "no_answer", "charged": None} try: parsed = json.loads(data.decode("utf-8")) except Exception: parsed = None if not isinstance(parsed, dict): parsed = None envelope = parsed.get("error") if parsed is not None else None if not isinstance(envelope, dict): envelope = None request_id = ( (_request_id_of(parsed.get("request_id"), api_key) if parsed is not None else None) or (_request_id_of(envelope.get("request_id"), api_key) if envelope is not None else None) or _request_id_of(_header(answer_headers, "X-Request-Id"), api_key) ) if status == 200 and parsed is not None and parsed.get("status") in EV_STATUSES: result = _key_free(parsed, api_key) return {"result": result, "charged": 1 if parsed.get("credits_used") == 1 else 0, "request_id": request_id} code = envelope.get("code") if envelope is not None else None if code not in EV_API_ERROR_CODES or status < 400: # Not a result and not our error envelope: it may have been charged. return {"error": "unexpected_response", "charged": None, "request_id": request_id, "http_status": status} # Our API charges nothing for an error answer. return {"error": code, "charged": 0, "request_id": request_id, "http_status": status} def _shares_key(text, key): """True when text holds EV_KEY_RUN or more characters of the key in a row: such a value is never kept.""" if len(key) < EV_KEY_RUN: return key != "" and key in text return any(key[i : i + EV_KEY_RUN] in text for i in range(len(key) - EV_KEY_RUN + 1)) def _request_id_of(value, key): """A request id of our shape, else None.""" if isinstance(value, str) and EV_REQUEST_ID.fullmatch(value) and not _shares_key(value, key): return value return None def _key_free(parsed, key): """The status and detail fields as plain values without the key; reason, action, processed_at in our shape.""" result = {"status": parsed["status"]} for field in EV_DETAIL_FIELDS: value = parsed.get(field) if isinstance(value, str): value = None if _shares_key(value, key) else value elif not (value is None or isinstance(value, (bool, int, float))): value = None result[field] = value if isinstance(result["reason"], str) and not EV_REASON.fullmatch(result["reason"]): result["reason"] = None if result["action"] not in EV_ACTIONS: result["action"] = None if not (isinstance(result["processed_at"], str) and EV_PROCESSED_AT.fullmatch(result["processed_at"])): result["processed_at"] = None return result def _details(outcome): value = {"status": None} result = outcome.get("result") for field in EV_DETAIL_FIELDS: value[field] = result.get(field) if result is not None else None if result is not None: value["status"] = result["status"] value["credits_used"] = outcome.get("charged") value["request_id"] = outcome.get("request_id") value["error"] = outcome.get("error") value["error_detail"] = outcome.get("detail") return value def ev_check_many(values, api_key_reader=_api_key, send=None, now=time.monotonic, region=None): """One validate_email_details value per input value (None for None or an empty string).""" send = send or ev_send region = region or EV_REGION if region not in EV_ORIGINS: raise ValueError('email-validation.org: EV_REGION must be "us" or "eu".') distinct = [] seen = set() for value in values: if isinstance(value, str) and value.strip() and value not in seen: seen.add(value) distinct.append(value) outcomes = {} if distinct: api_key = api_key_reader() deadline = now() + EV_BATCH_TIME_LIMIT_S queue = list(distinct) lock = threading.Lock() state = {"stop": None, "key": None, "time_up": False} def worker(): while True: with lock: if not queue or state["stop"] or state["key"]: return if now() + EV_CHECK_TIMEOUT_S + EV_ANSWER_MARGIN_S > deadline: state["time_up"] = True return address = queue.pop(0) outcome = _check_one(address, api_key, send, region) with lock: outcomes[address] = outcome code = outcome.get("error") if code in EV_KEY_CODES: state["key"] = state["key"] or outcome elif code in EV_STOP_CODES: state["stop"] = state["stop"] or code workers = max(1, min(EV_CONCURRENCY, len(distinct))) with ThreadPoolExecutor(max_workers=workers) as pool: for future in [pool.submit(worker) for _ in range(workers)]: future.result() failure = state["key"] if failure: why = ( "the API key was refused" if failure["error"] == "unauthorized" else 'the API key may not validate addresses (give it the "Validate addresses" permission)' ) where = "HTTP %s %s" % (failure.get("http_status"), failure["error"]) if failure.get("request_id"): where += ", request " + failure["request_id"] raise EvKeyError("email-validation.org: %s (%s). Check the secret ev_api_key." % (why, where)) if state["stop"]: detail = "not sent: the batch stopped after " + state["stop"] elif state["time_up"]: detail = "not sent: the batch time limit was reached" else: detail = "not sent" for address in distinct: if address not in outcomes: outcomes[address] = {"error": "not_sent", "charged": 0, "detail": detail} results = [] for value in values: outcome = outcomes.get(value) if isinstance(value, str) else None results.append(_details(outcome) if outcome is not None else None) return results def _column(frame): return [value if isinstance(value, str) else None for value in list(frame[0])] def _series(values): return pandas.Series(values) if pandas is not None else values def details(frame): return _series(ev_check_many(_column(frame))) def status(frame): return _series([value["status"] if value is not None else None for value in ev_check_many(_column(frame))]) for _handler in (details, status): _handler._sf_vectorized_input = pandas.DataFrame if pandas is not None else None _handler._sf_max_batch_size = EV_MAX_BATCH_SIZE $$; -- The status: valid, invalid, catch_all, unknown or disposable; NULL for a NULL or empty address or a row not checked. CREATE OR REPLACE FUNCTION validate_email(email VARCHAR) RETURNS VARCHAR LANGUAGE PYTHON RETURNS NULL ON NULL INPUT VOLATILE RUNTIME_VERSION = '3.11' COMMENT = 'email-validation.org status of an address. Every non-NULL row is checked each run (a repeat in one batch once): see 3-check-once.sql.' PACKAGES = ('pandas') HANDLER = 'status' EXTERNAL_ACCESS_INTEGRATIONS = (ev_api_access) SECRETS = ('ev_api_key' = ev_api_key) AS $$ # email-validation.org for Snowflake 1.0.0: the Python UDF handler for the external access path (no cloud account # needed). sql/external-access.sql holds this exact code inline, twice: validate_email_details (HANDLER = 'details') # and validate_email (HANDLER = 'status'). Docs: integrations/snowflake/README.md # # Snowflake hands the handler a batch of rows at a time (a vectorized UDF). It checks each distinct non-empty address # of the batch once with POST /v1/validate, a few at a time, and returns one value per row, in the same order. Rows it # could not check get status None and an error code, never an invented status. It never retries a check: a check # that got no answer may have been charged, so it comes back as error "no_answer". # # Credits: every non-empty row is checked each time the function runs (the same address twice in one batch # once), and a definite result costs one credit (results with status unknown, malformed addresses and test # addresses are free). # # The API key comes from the Snowflake secret bound as 'ev_api_key' (SECRETS clause). Nothing is printed or logged. import json import re import threading import time import urllib.error import urllib.request from concurrent.futures import ThreadPoolExecutor try: import pandas except ImportError: # only outside Snowflake pandas = None EV_VERSION = "1.0.0" EV_USER_AGENT = "email-validation-snowflake/" + EV_VERSION # "eu" for EU data residency (then the network rule names api-eu.email-validation.org). EV_REGION = "us" EV_ORIGINS = {"us": "https://api.email-validation.org", "eu": "https://api-eu.email-validation.org"} EV_STATUSES = ("valid", "invalid", "catch_all", "unknown", "disposable") EV_ACTIONS = ("send", "send_with_caution", "remove", "retry_later") EV_SECRET_ALIAS = "ev_api_key" # Checks in flight at once per batch. EV_CONCURRENCY = 8 # The time our API may spend on one check (5 to 15 seconds), and how much longer the handler waits for its answer. EV_CHECK_TIMEOUT_S = 10 EV_ANSWER_MARGIN_S = 2 # Snowflake stops a vectorized handler call after 180 seconds: no check starts that could end after this. EV_BATCH_TIME_LIMIT_S = 150 # Rows per batch at most (Snowflake may send fewer). EV_MAX_BATCH_SIZE = 100 EV_API_ERROR_CODES = ( "invalid_request", "unauthorized", "insufficient_credits", "forbidden", "forbidden_origin", "not_found", "conflict", "length_required", "payload_too_large", "rate_limited", "abuse_throttled", "key_daily_cap", "internal_error", "service_unavailable", "upstream_capacity", ) # After one of these no further address of the batch is sent: the same answer would come back for each. EV_STOP_CODES = ( "rate_limited", "abuse_throttled", "key_daily_cap", "insufficient_credits", "service_unavailable", "upstream_capacity", ) # The key itself is wrong or may not validate: the query fails with a message (never the key). EV_KEY_CODES = ("unauthorized", "forbidden", "forbidden_origin") EV_DETAIL_FIELDS = ( "reason", "action", "did_you_mean", "domain", "free_email", "role_account", "disposable", "catch_all_domain", "mx_found", "processed_at", ) # A value our API sends back is kept only in our own shape, and never with 12 characters of the key in a row (a broken # or hostile proxy could quote the request back): a request id is req_ and letters or digits, a reason is in our # vocabulary's shape, and a detail field is a plain value. EV_REQUEST_ID = re.compile(r"req_[A-Za-z0-9]{1,60}") EV_REASON = re.compile(r"[a-z_]{1,64}") EV_PROCESSED_AT = re.compile(r"\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}(\.\d{1,9})?Z", re.ASCII) EV_KEY_RUN = 12 class EvKeyError(Exception): pass class _NoRedirect(urllib.request.HTTPRedirectHandler): # A redirect is never followed: the Authorization header must not travel to another host. def redirect_request(self, req, fp, code, msg, headers, newurl): return None _OPENER = urllib.request.build_opener(urllib.request.ProxyHandler({}), _NoRedirect) def ev_send(url, headers, body, timeout): """One POST. Returns (status, headers, body bytes); raises when no answer arrived.""" request = urllib.request.Request(url, data=body, headers=headers, method="POST") try: with _OPENER.open(request, timeout=timeout) as response: return response.status, response.headers, response.read() except urllib.error.HTTPError as error: try: data = error.read() except Exception: data = b"" return error.code, error.headers, data def _api_key(): try: from snowflake.snowpark.secrets import get_generic_secret_string except ImportError: from _snowflake import get_generic_secret_string key = get_generic_secret_string(EV_SECRET_ALIAS) key = key.strip() if isinstance(key, str) else "" if not key or any(c.isspace() for c in key): raise EvKeyError("email-validation.org: the secret ev_api_key holds no usable API key.") return key def _header(headers, name): try: value = headers.get(name) if headers is not None else None except Exception: value = None return value if isinstance(value, str) else None def _check_one(address, api_key, send, region): body = json.dumps({"email": address, "timeout": EV_CHECK_TIMEOUT_S}).encode("utf-8") headers = { "Authorization": "Bearer " + api_key, "Content-Type": "application/json", "Accept": "application/json", "User-Agent": EV_USER_AGENT, } try: status, answer_headers, data = send( EV_ORIGINS[region] + "/v1/validate", headers, body, EV_CHECK_TIMEOUT_S + EV_ANSWER_MARGIN_S ) except Exception: return {"error": "no_answer", "charged": None} try: parsed = json.loads(data.decode("utf-8")) except Exception: parsed = None if not isinstance(parsed, dict): parsed = None envelope = parsed.get("error") if parsed is not None else None if not isinstance(envelope, dict): envelope = None request_id = ( (_request_id_of(parsed.get("request_id"), api_key) if parsed is not None else None) or (_request_id_of(envelope.get("request_id"), api_key) if envelope is not None else None) or _request_id_of(_header(answer_headers, "X-Request-Id"), api_key) ) if status == 200 and parsed is not None and parsed.get("status") in EV_STATUSES: result = _key_free(parsed, api_key) return {"result": result, "charged": 1 if parsed.get("credits_used") == 1 else 0, "request_id": request_id} code = envelope.get("code") if envelope is not None else None if code not in EV_API_ERROR_CODES or status < 400: # Not a result and not our error envelope: it may have been charged. return {"error": "unexpected_response", "charged": None, "request_id": request_id, "http_status": status} # Our API charges nothing for an error answer. return {"error": code, "charged": 0, "request_id": request_id, "http_status": status} def _shares_key(text, key): """True when text holds EV_KEY_RUN or more characters of the key in a row: such a value is never kept.""" if len(key) < EV_KEY_RUN: return key != "" and key in text return any(key[i : i + EV_KEY_RUN] in text for i in range(len(key) - EV_KEY_RUN + 1)) def _request_id_of(value, key): """A request id of our shape, else None.""" if isinstance(value, str) and EV_REQUEST_ID.fullmatch(value) and not _shares_key(value, key): return value return None def _key_free(parsed, key): """The status and detail fields as plain values without the key; reason, action, processed_at in our shape.""" result = {"status": parsed["status"]} for field in EV_DETAIL_FIELDS: value = parsed.get(field) if isinstance(value, str): value = None if _shares_key(value, key) else value elif not (value is None or isinstance(value, (bool, int, float))): value = None result[field] = value if isinstance(result["reason"], str) and not EV_REASON.fullmatch(result["reason"]): result["reason"] = None if result["action"] not in EV_ACTIONS: result["action"] = None if not (isinstance(result["processed_at"], str) and EV_PROCESSED_AT.fullmatch(result["processed_at"])): result["processed_at"] = None return result def _details(outcome): value = {"status": None} result = outcome.get("result") for field in EV_DETAIL_FIELDS: value[field] = result.get(field) if result is not None else None if result is not None: value["status"] = result["status"] value["credits_used"] = outcome.get("charged") value["request_id"] = outcome.get("request_id") value["error"] = outcome.get("error") value["error_detail"] = outcome.get("detail") return value def ev_check_many(values, api_key_reader=_api_key, send=None, now=time.monotonic, region=None): """One validate_email_details value per input value (None for None or an empty string).""" send = send or ev_send region = region or EV_REGION if region not in EV_ORIGINS: raise ValueError('email-validation.org: EV_REGION must be "us" or "eu".') distinct = [] seen = set() for value in values: if isinstance(value, str) and value.strip() and value not in seen: seen.add(value) distinct.append(value) outcomes = {} if distinct: api_key = api_key_reader() deadline = now() + EV_BATCH_TIME_LIMIT_S queue = list(distinct) lock = threading.Lock() state = {"stop": None, "key": None, "time_up": False} def worker(): while True: with lock: if not queue or state["stop"] or state["key"]: return if now() + EV_CHECK_TIMEOUT_S + EV_ANSWER_MARGIN_S > deadline: state["time_up"] = True return address = queue.pop(0) outcome = _check_one(address, api_key, send, region) with lock: outcomes[address] = outcome code = outcome.get("error") if code in EV_KEY_CODES: state["key"] = state["key"] or outcome elif code in EV_STOP_CODES: state["stop"] = state["stop"] or code workers = max(1, min(EV_CONCURRENCY, len(distinct))) with ThreadPoolExecutor(max_workers=workers) as pool: for future in [pool.submit(worker) for _ in range(workers)]: future.result() failure = state["key"] if failure: why = ( "the API key was refused" if failure["error"] == "unauthorized" else 'the API key may not validate addresses (give it the "Validate addresses" permission)' ) where = "HTTP %s %s" % (failure.get("http_status"), failure["error"]) if failure.get("request_id"): where += ", request " + failure["request_id"] raise EvKeyError("email-validation.org: %s (%s). Check the secret ev_api_key." % (why, where)) if state["stop"]: detail = "not sent: the batch stopped after " + state["stop"] elif state["time_up"]: detail = "not sent: the batch time limit was reached" else: detail = "not sent" for address in distinct: if address not in outcomes: outcomes[address] = {"error": "not_sent", "charged": 0, "detail": detail} results = [] for value in values: outcome = outcomes.get(value) if isinstance(value, str) else None results.append(_details(outcome) if outcome is not None else None) return results def _column(frame): return [value if isinstance(value, str) else None for value in list(frame[0])] def _series(values): return pandas.Series(values) if pandas is not None else values def details(frame): return _series(ev_check_many(_column(frame))) def status(frame): return _series([value["status"] if value is not None else None for value in ev_check_many(_column(frame))]) for _handler in (details, status): _handler._sf_vectorized_input = pandas.DataFrame if pandas is not None else None _handler._sf_max_batch_size = EV_MAX_BATCH_SIZE $$; -- A first test, free: addresses on the sandbox domain answer the reason they name and cost nothing. SELECT validate_email('no_mailbox@sandbox.email-validation.org') AS status, validate_email_details('accepted@sandbox.email-validation.org') AS details; -- Who may call them (each call can spend credits): -- GRANT USAGE ON FUNCTION validate_email(VARCHAR) TO ROLE ; -- GRANT USAGE ON FUNCTION validate_email_details(VARCHAR) TO ROLE ;