Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(mssql db_engine_spec): adds uniqueidentifier to column_type_mappings #30618

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

rparsonsbb
Copy link

SUMMARY

Fix for #30612: adds uniqueidentifier column_type_mapping to class MssqlEngineSpec

BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF

TESTING INSTRUCTIONS

Can test using reproduction steps in issue:

  1. Create a few dummy tables in a sql server database:
-- Create the TestUsers table with a uniqueidentifier column
CREATE TABLE Users (
    UserID UNIQUEIDENTIFIER DEFAULT NEWID() NOT NULL,  -- uniqueidentifier column
    FirstName NVARCHAR(50) NOT NULL,
    LastName NVARCHAR(50) NOT NULL,
    Email NVARCHAR(100) NOT NULL
);

-- Create the TestProducts table without a uniqueidentifier column
CREATE TABLE Products (
    ProductID INT IDENTITY(1,1) NOT NULL PRIMARY KEY,  -- Auto-incrementing integer column
    ProductName NVARCHAR(100) NOT NULL,
    Price DECIMAL(10, 2) NOT NULL
);
  1. Add data
-- Insert 10 rows of dummy data into the Users table
INSERT INTO TestUsers (FirstName, LastName, Email)
VALUES 
('John', 'Doe', 'john.doe@example.com'),
('Jane', 'Smith', 'jane.smith@example.com'),
('Bob', 'Johnson', 'bob.johnson@example.com'),
('Alice', 'Williams', 'alice.williams@example.com'),
('Tom', 'Brown', 'tom.brown@example.com'),
('Nancy', 'Davis', 'nancy.davis@example.com'),
('Chris', 'Miller', 'chris.miller@example.com'),
('Megan', 'Wilson', 'megan.wilson@example.com'),
('Luke', 'Moore', 'luke.moore@example.com'),
('Emily', 'Taylor', 'emily.taylor@example.com');

-- Insert 10 rows of dummy data into the Products table
INSERT INTO TestProducts (ProductName, Price)
VALUES 
('Laptop', 999.99),
('Smartphone', 699.99),
('Tablet', 299.99),
('Monitor', 199.99),
('Keyboard', 49.99),
('Mouse', 29.99),
('Headphones', 89.99),
('Smartwatch', 199.99),
('Printer', 149.99),
('Camera', 549.99);
  1. Create the connection for the database in superset
  2. Select from the SQL Lab using the MSSQL connection
  3. Select the data using the meta database

ADDITIONAL INFORMATION

  • Has associated issue: SQL Server type uniqueidentifier causes error in meta database #30612
  • 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

@dosubot dosubot bot added the data:connect:mssql Related to MSSSQL label Oct 15, 2024
Copy link
Contributor

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

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

Congrats on making your first PR and thank you for contributing to Superset! 🎉 ❤️

We hope to see you in our Slack community too! Not signed up? Use our Slack App to self-register.

Copy link
Member

@villebro villebro left a comment

Choose a reason for hiding this comment

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

Thanks for the improvement! LGTM, but please add a unit test.

superset/db_engine_specs/mssql.py Outdated Show resolved Hide resolved
@rparsonsbb rparsonsbb force-pushed the fix/30612-mssql-adds-uniqueidentifier-column-mapping branch from 9a71c77 to 5d2afaa Compare October 16, 2024 13:21
@pull-request-size pull-request-size bot added size/M and removed size/S labels Oct 16, 2024
Copy link

codecov bot commented Oct 16, 2024

Codecov Report

Attention: Patch coverage is 61.53846% with 10 lines in your changes missing coverage. Please review.

Project coverage is 83.90%. Comparing base (76d897e) to head (8748a98).
Report is 864 commits behind head on master.

Files with missing lines Patch % Lines
superset/models/sql_types/mssql_sql_types.py 58.33% 10 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff             @@
##           master   #30618       +/-   ##
===========================================
+ Coverage   60.48%   83.90%   +23.41%     
===========================================
  Files        1931      534     -1397     
  Lines       76236    38636    -37600     
  Branches     8568        0     -8568     
===========================================
- Hits        46114    32418    -13696     
+ Misses      28017     6218    -21799     
+ Partials     2105        0     -2105     
Flag Coverage Δ
hive 48.97% <61.53%> (-0.20%) ⬇️
javascript ?
mysql 76.75% <61.53%> (?)
postgres 76.85% <61.53%> (?)
presto 53.44% <61.53%> (-0.36%) ⬇️
python 83.90% <61.53%> (+20.41%) ⬆️
sqlite 76.30% <61.53%> (?)
unit 60.93% <61.53%> (+3.30%) ⬆️

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

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

@villebro
Copy link
Member

There's some linting issues, see the CI logs:

image

I suggest looking into enabling pre-commit hooks, they're very handy for this.

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.

2 participants