Fix column's statistics errors

This commit is contained in:
2026-05-22 09:41:08 -04:00
parent 82c8a6bf84
commit 59aa235f3d
4 changed files with 16 additions and 5 deletions
+6 -5
View File
@@ -19,12 +19,13 @@ class _StatsWorker(QThread):
self._column = column
def run(self):
col = self._column
tbl = self._table
q = self._driver.quote_identifier
col = q(self._column)
tbl = q(self._table)
try:
_, rows, _ = self._driver.execute_query(
f'SELECT COUNT(*), COUNT("{col}"), COUNT(DISTINCT "{col}"), '
f'MIN("{col}"), MAX("{col}") FROM "{tbl}"'
f'SELECT COUNT(*), COUNT({col}), COUNT(DISTINCT {col}), '
f'MIN({col}), MAX({col}) FROM {tbl}'
)
total, non_null, distinct, min_val, max_val = rows[0]
null_count = (total or 0) - (non_null or 0)
@@ -35,7 +36,7 @@ class _StatsWorker(QThread):
avg_val = None
try:
_, avg_rows, _ = self._driver.execute_query(
f'SELECT AVG("{col}") FROM "{tbl}"'
f'SELECT AVG({col}) FROM {tbl}'
)
avg_val = avg_rows[0][0]
except Exception: