Skip to content

Commit 4edec25

Browse files
authored
SNOW-1247646: Update the logging level from INFO to DEBUG when logging the executed query using SnowflakeCursor.execute (#1904)
1 parent 253fa6c commit 4edec25

File tree

3 files changed

+10
-11
lines changed

3 files changed

+10
-11
lines changed

DESCRIPTION.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,9 @@ Source code is also available at: https://github.com/snowflakedb/snowflake-conne
2323
- Added support for parsing structured type information in schema queries.
2424
- Bumped platformdirs from >=2.6.0,<4.0.0 to >=2.6.0,<5.0.0
2525
- Updated diagnostics to use system$allowlist instead of system$whitelist.
26-
- Update `write_pandas` to skip TABLE IF NOT EXISTS in truncate mode.
26+
- Updated `write_pandas` to skip TABLE IF NOT EXISTS in truncate mode.
2727
- Improved cleanup logic for connection to rely on interpreter shutdown instead of the `__del__` method.
28+
- Updated the logging level from INFO to DEBUG when logging the executed query using `SnowflakeCursor.execute`.
2829

2930
- v3.7.1(February 21, 2024)
3031

src/snowflake/connector/cursor.py

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -922,6 +922,7 @@ def execute(
922922
if not command:
923923
logger.warning("execute: no query is given to execute")
924924
return None
925+
logger.debug("query: [%s]", self._format_query_for_log(command))
925926

926927
_statement_params = _statement_params or dict()
927928
# If we need to add another parameter, please consider introducing a dict for all extra params
@@ -966,16 +967,13 @@ def execute(
966967
m = DESC_TABLE_RE.match(query)
967968
if m:
968969
query1 = f"describe table {m.group(1)}"
969-
if logger.getEffectiveLevel() <= logging.WARNING:
970-
logger.info(
971-
"query was rewritten: org=%s, new=%s",
972-
" ".join(line.strip() for line in query.split("\n")),
973-
query1,
974-
)
970+
logger.debug(
971+
"query was rewritten: org=%s, new=%s",
972+
" ".join(line.strip() for line in query.split("\n")),
973+
query1,
974+
)
975975
query = query1
976976

977-
if logger.getEffectiveLevel() <= logging.INFO:
978-
logger.info("query: [%s]", self._format_query_for_log(query))
979977
ret = self._execute_helper(query, **kwargs)
980978
self._sfqid = (
981979
ret["data"]["queryId"]
@@ -988,7 +986,7 @@ def execute(
988986
if "data" in ret and "sqlState" in ret["data"]
989987
else None
990988
)
991-
logger.info("query execution done")
989+
logger.debug("query execution done")
992990

993991
self._first_chunk_time = get_time_millis()
994992

test/integ/test_cursor.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1276,7 +1276,7 @@ def test_desc_rewrite(conn, caplog):
12761276
cur.execute(f"desc {table_name}")
12771277
assert (
12781278
"snowflake.connector.cursor",
1279-
20,
1279+
10,
12801280
"query was rewritten: org=desc {table_name}, new=describe table {table_name}".format(
12811281
table_name=table_name
12821282
),

0 commit comments

Comments
 (0)