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

feat: command to test DB engine specs #24918

Merged
merged 14 commits into from
Aug 11, 2023
Merged

feat: command to test DB engine specs #24918

merged 14 commits into from
Aug 11, 2023

Conversation

betodealmeida
Copy link
Member

@betodealmeida betodealmeida commented Aug 8, 2023

SUMMARY

This PR adds a README for DB engine specs, describing all their features and functionality. It also adds a new command to test DB engine specs, SQLAlchemy dialects, and database connections:

$ superset test-db sqlite://
Loaded your LOCAL configuration at [/Users/beto/Projects/github/superset/superset_config.py]
Collecting additional connection information...
SQLAlchemy URI: sqlite://
> Do you want to configure connection arguments? [y/N] 
Checking for a DB engine spec...
👍 Found DB engine spec: SQLite
About the database:
  - Method used to apply LIMIT to queries: FORCE_LIMIT
    - FORCE_LIMIT: modifies the query, replacing an existing LIMIT or adding a new one
    - WRAP_SQL: wraps the original query in a SELECT * with a LIMIT
    - FETCH_MANY: runs the query unmodified but fetchs only LIMIT rows from the cursor
  - Method used to limit the rows in the subquery: FORCE_LIMIT
  - Supports JOINs: True
  - Supports subqueries: True
  - Allows aliases in the SELECT statement: True
  - Allows referencing aliases in the ORDER BY statement: True
  - Supports secondary time columns: False
  - Allows ommiting time filters from inline GROUP BYs: False
  - Able to use source column when an alias overshadows it: False
  - Allows aggregations in ORDER BY not present in the SELECT: True
  - Allows expressions in ORDER BY: False
  - Allows CTE as a subquery: True
  - Allows LIMIT clause (instead of TOP): True
  - Maximum column name: None
  - Allows comments: True
  - Colons must be escaped: True
Checking for basic features...
Supported time grains:
  - SECOND: True (+1)
  - FIVE_SECONDS: True (+1)
  - THIRTY_SECONDS: True (+1)
  - MINUTE: True (+1)
  - FIVE_MINUTES: True (+1)
  - TEN_MINUTES: True (+1)
  - FIFTEEN_MINUTES: True (+1)
  - THIRTY_MINUTES: True (+1)
  - HALF_HOUR: True (+1)
  - HOUR: True (+1)
  - SIX_HOURS: True (+1)
  - DAY: True (+1)
  - WEEK: True (+1)
  - WEEK_STARTING_SUNDAY: True (+1)
  - WEEK_STARTING_MONDAY: True (+1)
  - WEEK_ENDING_SATURDAY: True (+1)
  - WEEK_ENDING_SUNDAY: True (+1)
  - MONTH: True (+1)
  - QUARTER: True (+1)
  - QUARTER_YEAR: True (+1)
  - YEAR: True (+1)
Masks/unmasks encrypted_extra: False
Has column type mappings: False
Returns a list of function names: True (+10)
Checking for nice-to-have features...
Supports user impersonation: False
Support file upload: True (+10)
Returns extra table metadata: False
Maps driver exceptions to Superset exceptions: False
Parses error messages and returns Superset errors: False
Supports changing the schema per-query: False
Supports catalogs: False
Supports changing the catalog per-query: False
Can be connected thru an SSH tunnel: False
Allows query to be canceled: False
Returns additional metrics on dataset creation: False
Supports querying the latest partition only: False
Checking for advanced features...
Expands complex types (arrays, structs) into rows/columns: False
Supports query cost estimation: False
Supports validating SQL before running query: False
Overall score: 41/201

Testing the SQLAlchemy dialect...
Checking functions used by the inspector...
  - get_schema_names: True
  - get_table_names: True
  - get_view_names: True
  - get_indexes: True
  - get_table_comment: True
  - get_columns: True
  - get_unique_constraints: True
  - get_check_constraints: True
  - get_pk_constraint: True
  - get_foreign_keys: True
Checking dialect attributes...
  - dbapi: sqlite3.dbapi2
  - name: sqlite
  - driver: pysqlite
  - supports_multivalues_insert: True
Supports do_ping: True
Can quote identifiers: True
Doesn't require name normalization: True

Testing the database connectivity...
👍 Connected successfully!
Checking that we can run queries...
sql> SELECT 1;
> 1
Checking that we can create tables...
Tables created!
Checking that we can insert data...
sql> INSERT INTO user (user_name, email_address, nickname) VALUES ('beto', 'beto@example.org', 'Beto')
Checking that we can read data...
sql> SELECT user.user_id, user.user_name, user.email_address, user.nickname 
FROM user 
WHERE user.user_name = 'beto'
> [(1, 'beto', 'beto@example.org', 'Beto')]
Checking that we can drop tables...
Done!
Running engine-specific tests...
Testing datetime support...
Creating a table with a timestamp column...
Table created!
Inserting timestamp value...
Reading timestamp value...
👍 Succcess!

BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF

TESTING INSTRUCTIONS

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

@codecov
Copy link

codecov bot commented Aug 8, 2023

Codecov Report

Merging #24918 (13154e7) into master (eb7c145) will increase coverage by 1.54%.
Report is 2 commits behind head on master.
The diff coverage is 6.06%.

❗ Current head 13154e7 differs from pull request most recent head 478fbe0. Consider uploading reports for the commit 478fbe0 to get more accurate results

@@            Coverage Diff             @@
##           master   #24918      +/-   ##
==========================================
+ Coverage   67.22%   68.77%   +1.54%     
==========================================
  Files        1906     1908       +2     
  Lines       74134    74390     +256     
  Branches     8208     8208              
==========================================
+ Hits        49840    51165    +1325     
+ Misses      22171    21102    -1069     
  Partials     2123     2123              
Flag Coverage Δ
hive 53.82% <6.06%> (-0.36%) ⬇️
mysql 78.67% <6.06%> (-0.55%) ⬇️
postgres 78.77% <6.06%> (-0.55%) ⬇️
presto 53.72% <6.06%> (?)
python 82.79% <6.06%> (+3.13%) ⬆️
sqlite 77.35% <6.06%> (-0.54%) ⬇️
unit 54.69% <6.06%> (?)

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

Files Changed Coverage Δ
.../src/dashboard/components/gridComponents/Chart.jsx 59.25% <ø> (+0.99%) ⬆️
superset/cli/test_db.py 0.00% <0.00%> (ø)
superset/db_engine_specs/sqlite.py 97.22% <ø> (+2.77%) ⬆️
superset/db_engine_specs/lib.py 21.73% <21.73%> (ø)
superset/db_engine_specs/base.py 91.02% <100.00%> (+8.68%) ⬆️

... and 99 files with indirect coverage changes

📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more

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.

Very nice, this will be a big help for people developing new specs! Just a few minor comments, LGTM

superset/cli/test_db.py Outdated Show resolved Hide resolved
superset/cli/test_db.py Outdated Show resolved Hide resolved
@betodealmeida betodealmeida merged commit a1e32db into master Aug 11, 2023
54 checks passed
@mistercrunch mistercrunch added 🏷️ bot A label used by `supersetbot` to keep track of which PR where auto-tagged with release labels 🚢 3.1.0 labels Mar 8, 2024
@mistercrunch mistercrunch deleted the db-diagnostics branch March 26, 2024 16:24
@betodealmeida betodealmeida restored the db-diagnostics branch July 5, 2024 16:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🏷️ bot A label used by `supersetbot` to keep track of which PR where auto-tagged with release labels size/XXL 🚢 3.1.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants