Prints the given runtime profiles to the console, or to a file if --profile_output or profile_output shell option was set. Optionally prints the failed profile if the query was retried. The format the profiles are printed is controlled by the option profile_display_mode, see QueryProfile
(self, profile, failed_profile,
profile_display_mode=QueryAttemptDisplayModes.LATEST)
| 1236 | file_descriptor.flush() |
| 1237 | |
| 1238 | def print_runtime_profile(self, profile, failed_profile, |
| 1239 | profile_display_mode=QueryAttemptDisplayModes.LATEST): |
| 1240 | """Prints the given runtime profiles to the console, or to a file if --profile_output |
| 1241 | or profile_output shell option was set. Optionally prints the failed |
| 1242 | profile if the query was retried. The format the profiles are printed is controlled |
| 1243 | by the option profile_display_mode, see QueryProfileDisplayModes docs above. |
| 1244 | """ |
| 1245 | |
| 1246 | if not profile: return |
| 1247 | |
| 1248 | try: |
| 1249 | out_file = sys.stdout |
| 1250 | if self.profile_output: |
| 1251 | out_file = open(self.profile_output, 'a') |
| 1252 | |
| 1253 | query_profile_prefix = match_string_type("Query Runtime Profile:\n", profile) |
| 1254 | if self.profile_format.upper() == "BASE64": |
| 1255 | # Change prefix so that the output can be read by impala-profile-tool |
| 1256 | timestamp = str(int(time.time())) |
| 1257 | query_id = self.imp_client.get_query_id_str(self.last_query_handle) |
| 1258 | query_profile_prefix = timestamp + " " + query_id + " " |
| 1259 | |
| 1260 | if profile_display_mode == QueryAttemptDisplayModes.ALL: |
| 1261 | print(query_profile_prefix + profile, file=out_file) |
| 1262 | if failed_profile: |
| 1263 | failed_profile_prefix = \ |
| 1264 | match_string_type("Failed Query Runtime Profile(s):\n", failed_profile) |
| 1265 | print(failed_profile_prefix + failed_profile, file=out_file) |
| 1266 | elif profile_display_mode == QueryAttemptDisplayModes.LATEST: |
| 1267 | print(query_profile_prefix + profile, file=out_file) |
| 1268 | elif profile_display_mode == QueryAttemptDisplayModes.ORIGINAL: |
| 1269 | query_profile = failed_profile if failed_profile else profile |
| 1270 | print(query_profile_prefix + query_profile, file=out_file) |
| 1271 | else: |
| 1272 | raise FatalShellException("Invalid value for query profile display mode") |
| 1273 | finally: |
| 1274 | if self.profile_output: |
| 1275 | out_file.close() |
| 1276 | |
| 1277 | def _parse_table_name_arg(self, arg): |
| 1278 | """ Parses an argument string and returns the result as a db name, table name combo. |
no test coverage detected