MCPcopy Create free account
hub / github.com/apache/impala / format_sql_for_logging

Function format_sql_for_logging

tests/common/impala_connection.py:95–110  ·  view source on GitHub ↗

If the 'sql_stmt' is shorter than MAX_SQL_LOGGING_LENGTH, only wrap sql_stmt with new lines and semicolon. If it is larger than MAX_SQL_LOGGING_LENGTH, truncate it and comment it out. This function returns a unicode string.

(sql_stmt)

Source from the content-addressed store, hash-verified

93# the size of the JUnitXML files, causing problems for users of JUnitXML like Jenkins.
94# This function limits the size of the returned string if it is larger than 128KB.
95def format_sql_for_logging(sql_stmt):
96 """If the 'sql_stmt' is shorter than MAX_SQL_LOGGING_LENGTH, only wrap sql_stmt with
97 new lines and semicolon. If it is larger than MAX_SQL_LOGGING_LENGTH, truncate it
98 and comment it out. This function returns a unicode string."""
99 # sql_stmt could contain Unicode characters, so explicitly use unicode literals
100 # so that Python 2 works.
101 if (len(sql_stmt) <= MAX_SQL_LOGGING_LENGTH):
102 return u"\n{0};\n".format(sql_stmt)
103 else:
104 # The logging output should be valid SQL, so the truncated SQL is commented out.
105 truncated_sql = u'\n--'.join(
106 [line for line in sql_stmt[0:MAX_SQL_LOGGING_LENGTH].split("\n")])
107 return (u"\n-- Skip logging full SQL statement of length {0}"
108 u"\n-- Logging a truncated version, commented out:"
109 u"\n-- {1}"
110 u"\n-- [...]\n").format(len(sql_stmt), truncated_sql)
111
112
113def build_summary_table_from_thrift(thrift_exec_summary):

Callers 4

executeMethod · 0.85
execute_asyncMethod · 0.85
__log_executeMethod · 0.85
__log_executeMethod · 0.85

Calls 2

formatMethod · 0.45
joinMethod · 0.45

Tested by

no test coverage detected