Skip to content

fix(core): reduce metric expression log noise - #42619

Open
aminghadersohi wants to merge 3 commits into
apache:masterfrom
aminghadersohi:amin/reduce-metric-expression-log-noise
Open

fix(core): reduce metric expression log noise#42619
aminghadersohi wants to merge 3 commits into
apache:masterfrom
aminghadersohi:amin/reduce-metric-expression-log-noise

Conversation

@aminghadersohi

Copy link
Copy Markdown
Contributor

SUMMARY

Metric expressions that do not match the built-in aggregation pattern are a supported fallback: get_metric_type_from_column returns an empty inferred type for them. Logging this case at warning level creates repeated noise when dataframe types are inferred across query result columns.

This changes the existing message from warning to debug level while preserving its text and arguments. The unit test is updated to verify the debug call.

TESTING INSTRUCTIONS

Run:

pytest -q tests/unit_tests/utils/map_type_tests.py
pre-commit run --files superset/utils/core.py tests/unit_tests/utils/map_type_tests.py

Verified locally: 11 tests passed, and all pre-commit hooks applicable to the changed files passed.

ADDITIONAL INFORMATION

  • Has associated issue:
  • Required feature flags:
  • Changes UI
  • Includes DB Migration (follow approval process in SIP-59)
    • Migration is atomic, supports rollback & is backwards-compatible
    • Confirm DB migration upgrade and downgrade tested
    • Runtime estimates and downtime expectations provided
  • Introduces new feature or API
  • Removes existing feature or API

Blast radius

Backend logging only. There are no behavior, API, database, security, or UI changes.

Risk and rollback

Low risk: unexpected metric expressions remain observable at debug level. Roll back by reverting the commit.

Review guidance

Review the log-level change in superset/utils/core.py and its matching unit-test expectation.

@netlify

netlify Bot commented Jul 30, 2026

Copy link
Copy Markdown

Deploy Preview for superset-docs-preview ready!

Name Link
🔨 Latest commit 9b65479
🔍 Latest deploy log https://app.netlify.com/projects/superset-docs-preview/deploys/6a6cbd78a897f500084a18bc
😎 Deploy Preview https://deploy-preview-42619--superset-docs-preview.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.
🤖 Make changes Run an agent on this branch

To edit notification comments on pull requests, go to your Netlify project configuration.

@codecov

codecov Bot commented Jul 30, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 65.44%. Comparing base (7d2b184) to head (e84f2e0).

Additional details and impacted files
@@            Coverage Diff             @@
##           master   #42619      +/-   ##
==========================================
- Coverage   65.44%   65.44%   -0.01%     
==========================================
  Files        2810     2810              
  Lines      159362   159362              
  Branches    36372    36372              
==========================================
- Hits       104301   104291      -10     
- Misses      53019    53028       +9     
- Partials     2042     2043       +1     
Flag Coverage Δ
hive 38.09% <0.00%> (ø)
mysql 57.82% <100.00%> (ø)
postgres 57.86% <100.00%> (-0.01%) ⬇️
presto 39.98% <0.00%> (ø)
python 59.25% <100.00%> (-0.01%) ⬇️
sqlite 57.49% <100.00%> (ø)
unit 100.00% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@sadpandajoe sadpandajoe added review:checkpoint Last PR reviewed during the daily review standup review:draft labels Jul 30, 2026
@aminghadersohi
aminghadersohi marked this pull request as ready for review July 31, 2026 15:21
@dosubot dosubot Bot added the logging Creates a UI or API endpoint that could benefit from logging. label Jul 31, 2026
Comment thread tests/unit_tests/utils/map_type_tests.py Outdated
@bito-code-review

Copy link
Copy Markdown
Contributor

The suggestion is valid. The current test only verifies that logger.debug was called, which is insufficient to ensure the correct diagnostic message and expression are logged. You can improve the test by asserting the specific arguments passed to the logger.

Here is the updated test code:

    with patch("superset.utils.core.logger.debug") as mock_debug:
        assert (get_metric_type_from_column(column, datasource)) == ""
        mock_debug.assert_called_once_with(
            "Unexpected metric expression type: %s", "INVALID(my_column)"
        )

I have checked the PR and there are no other comments to address. Would you like me to help with anything else?

tests/unit_tests/utils/map_type_tests.py

with patch("superset.utils.core.logger.debug") as mock_debug:
        assert (get_metric_type_from_column(column, datasource)) == ""
        mock_debug.assert_called_once_with(
            "Unexpected metric expression type: %s", "INVALID(my_column)"
        )

@rusackas rusackas removed the review:checkpoint Last PR reviewed during the daily review standup label Jul 31, 2026
@bito-code-review

bito-code-review Bot commented Jul 31, 2026

Copy link
Copy Markdown
Contributor

Code Review Agent Run #ab286b

Actionable Suggestions - 0
Review Details
  • Files reviewed - 2 · Commit Range: 533177a..e84f2e0
    • superset/utils/core.py
    • tests/unit_tests/utils/map_type_tests.py
  • Files skipped - 0
  • Tools
    • MyPy (Static Code Analysis) - ✔︎ Successful
    • Astral Ruff (Static Code Analysis) - ✔︎ Successful
    • Whispers (Secret Scanner) - ✔︎ Successful
    • Detect-secrets (Secret Scanner) - ✔︎ Successful

Bito Usage Guide

Commands

Type the following command in the pull request comment and save the comment.

  • /review - Manually triggers a full AI review.

  • /pause - Pauses automatic reviews on this pull request.

  • /resume - Resumes automatic reviews.

  • /resolve - Marks all Bito-posted review comments as resolved.

  • /abort - Cancels all in-progress reviews.

Refer to the documentation for additional commands.

Configuration

This repository uses Superset You can customize the agent settings here or contact your Bito workspace admin at evan@preset.io.

Documentation & Help

AI Code Review powered by Bito Logo

@rebenitez1802 rebenitez1802 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

logging Creates a UI or API endpoint that could benefit from logging. review:draft size/XS

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants