Skip to content

feat(sql): add support for TINYINT type in BaseEngineSpec - #45496

Open
greg-om wants to merge 3 commits into
apache:masterfrom
greg-om:fix/tinyint-column-type-mapping
Open

greg-om wants to merge 3 commits into
apache:masterfrom
greg-om:fix/tinyint-column-type-mapping

Conversation

@greg-om

@greg-om greg-om commented Oct 19, 2026 •

Copy link
Copy Markdown

SUMMARY

BaseEngineSpec._default_column_type_mappings maps SMALLINT, INT/INTEGER and BIGINT to GenericDataType.NUMERIC, but has no entry for TINYINT. Engines that rely on the default mappings, such as Amazon Athena, therefore report TINYINT columns with type_generic: null.

With no generic type, filters on these columns are treated as strings and the value is sent quoted. Strictly typed engines reject the query:

TYPE_MISMATCH: Cannot apply operator: tinyint <= varchar(1)

This PR adds a ^tinyint entry right after ^smallint, mapped to types.SmallInteger() / GenericDataType.NUMERIC. SmallInteger is the narrowest integer type SQLAlchemy provides generically, so it holds the full TINYINT range.

Presto and Trino already map tinyint in their own specs, so they aren't affected. Engines that override this mapping keep their own behavior.

BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF

Filtering a TINYINT column flag with flag >= 2:

Before

WHERE flag >= '2'
Dataset API (GET /api/v1/dataset/<id>), column flag:
{ "column_name": "flag", "type": "TINYINT", "type_generic": null }

After
WHERE flag >= 2
{ "column_name": "flag", "type": "TINYINT", "type_generic": 0 }

TESTING INSTRUCTIONS

  1. Unit test: pytest tests/unit_tests/db_engine_specs/test_base.py -k get_column_spec. A TINYINT case was added to the column-spec parametrization.
  2. Manual (Athena, or any engine using the default mappings):
    • Create a dataset on a table with a TINYINT column, e.g. flag.
    • Sync columns and confirm type_generic is 0 (NUMERIC) in GET /api/v1/dataset/.
    • Add a filter such as flag >= 2 to a chart and check that the generated SQL has an unquoted 2 and the query succeeds.

ADDITIONAL INFORMATION

  • Has associated issue: Fixes TYPE_MISMATCH: line 12:29: Cannot apply operator: tinyint < varchar #45481
  • 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

@netlify

netlify Bot commented Oct 19, 2026 •

Copy link
Copy Markdown

✅ Deploy Preview for superset-docs-preview ready!

Name Link
🔨 Latest commit 0c351ae
🔍 Latest deploy log https://app.netlify.com/projects/superset-docs-preview/deploys/6ae50e534ff0a9fdcf1a30cc
😎 Deploy Preview https://deploy-preview-45496--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.

@codeant-ai-for-open-source

codeant-ai-for-open-source Bot commented Oct 19, 2026 •

Copy link
Copy Markdown
Contributor

CodeAnt  CodeAnt PR Risk

🟢  Low Risk

  • The PR appears safe to merge; no actionable issues were identified in the review.

Assessed commit: 0c351aea39cf

@codecov

codecov Bot commented Oct 19, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 84.65%. Comparing base (2350348) to head (0c351ae).
⚠️ Report is 54 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master   #45496      +/-   ##
==========================================
+ Coverage   84.63%   84.65%   +0.02%     
==========================================
  Files        3069     3069              
  Lines      205446   205679     +233     
  Branches    48306    48338      +32     
==========================================
+ Hits       173879   174122     +243     
+ Misses      28277    28265      -12     
- Partials     3290     3292       +2     
Flag Coverage Δ
hive 34.50% <ø> (-0.03%) ⬇️
mysql 52.60% <ø> (+0.04%) ⬆️
postgres 52.60% <ø> (+0.04%) ⬆️
presto 36.23% <ø> (-0.03%) ⬇️
python 87.77% <ø> (+0.03%) ⬆️
sqlite 52.37% <ø> (+0.04%) ⬆️
unit 82.52% <ø> (+0.07%) ⬆️

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.

@rusackas rusackas left a comment •

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Clean and minimal, mirrors the existing SMALLINT pattern exactly. Mapping TINYINT to SmallInteger is the right call since SQLAlchemy has no dedicated tiny-int generic type. CI failure is the same stale-master semantic-layer breakage as several other PRs today (semantic_view.implementation = ... AttributeError), unrelated to this change. LGTM.

@greg-om greg-om closed this Oct 21, 2026
@greg-om
greg-om deleted the fix/tinyint-column-type-mapping branch October 21, 2026 23:07
@greg-om
greg-om restored the fix/tinyint-column-type-mapping branch October 21, 2026 23:10
@greg-om greg-om reopened this Oct 21, 2026
@greg-om
greg-om force-pushed the fix/tinyint-column-type-mapping branch from 27d299d to a18c40e Compare October 22, 2026 18:04
@greg-om
greg-om force-pushed the fix/tinyint-column-type-mapping branch from a18c40e to 10b7058 Compare October 22, 2026 18:13
@github-actions github-actions Bot removed the packages label Oct 22, 2026
hainenber
hainenber previously approved these changes Oct 25, 2026
@hainenber
hainenber dismissed their stale review October 25, 2026 05:01

failed unit test found

@greg-om

greg-om commented Oct 30, 2026 •

Copy link
Copy Markdown
Author

@hainenber I updated the unit test now so it's no longer failing :) Please let me know if there's anything else I need to do for this PR, thanks!!

This branch has not been deployed

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

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

TYPE_MISMATCH: line 12:29: Cannot apply operator: tinyint < varchar

3 participants