Skip to content

Fix SQL null handling in space savings query when no compressed files exist #1012

@coderabbitai

Description

@coderabbitai

Description

The space savings SQL query in getSpaceSavingsSql() can return null values when there are no compressed files in the database, causing the application to crash when JavaScript code expects numeric values.

Problem

When the clp_archives table is empty, the SUM() aggregation functions return NULL instead of 0. This causes crashes when the frontend tries to perform operations on these null values.

Solution

Use COALESCE to provide fallback values of 0 and CAST to ensure proper typing in the SQL query.

Location

File: components/log-viewer-webui/client/src/pages/IngestPage/SpaceSavings/sql.ts

References

Reported by: junhaoliao

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions