From 32413984e284c25847a6e4049903287b7aee151d Mon Sep 17 00:00:00 2001 From: Michael Hohn Date: Wed, 1 Jun 2022 17:34:56 -0700 Subject: [PATCH] fix: only concatenate non-empty tables to suppress float conversion --- sarif_cli/scan_tables.py | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/sarif_cli/scan_tables.py b/sarif_cli/scan_tables.py index f6064fe..0753cc5 100644 --- a/sarif_cli/scan_tables.py +++ b/sarif_cli/scan_tables.py @@ -44,11 +44,16 @@ def joins_for_results(basetables, external_info): Form and return the `results` table """ # Get one table per result_type, then stack them, - # (kind_problem, - # kind_pathproblem, - # ) - return pd.concat([_results_from_kind_problem(basetables, external_info), - _results_from_kind_pathproblem(basetables, external_info)]) + # kind_problem + # kind_pathproblem + # + # Concatenation with an empty table triggers type conversion to float, so don't + # include empty tables + res = pd.concat( + [table for table in [_results_from_kind_problem(basetables, external_info), + _results_from_kind_pathproblem(basetables, external_info)] + if len(table) > 0]) + return res def _results_from_kind_problem(basetables, external_info): b = basetables; e = external_info @@ -83,6 +88,7 @@ def _results_from_kind_problem(basetables, external_info): }) # Force column type(s) to avoid floats in output. res1 = res.astype({ 'id' : 'uint64', 'scan_id': 'uint64'}).reset_index(drop=True) + return res1