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(db_engine_specs): Allow uploaded columns of dtype datetime to be stored as TIMESTAMP in the Hive schema #21850

Closed
wants to merge 3 commits into from

Conversation

GerbenvdHuizen
Copy link

@GerbenvdHuizen GerbenvdHuizen commented Oct 18, 2022

SUMMARY

The views for uploading data files (csv, excel etc.) to a database have form options to pass and/or infer datetime columns. However, the hive df_to_sql method does not support storing datetime columns as TIMESTAMPs in the Hive schema. It would be a nice for the _get_hive_type functionality to at least support the basic datetime64[ns] dtype.

TESTING INSTRUCTIONS

The following steps require you to be able to upload files to a schema on Superset (allow_file_upload) + use Hive as DB engine.
Steps:

  1. Upload a csv with an inferable timestamp:
test_column,timestamp
something,2022-01-01T01:01:01.000000
  1. Make sure parse_dates is set to the timestamp column in your csv file and infer_datetime_format is set to true within the form.
  2. Submit the CSV and confirm that the new table has a column with type TIMESTAMP.

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

… schema

The views for uploading data files (csv, excel etc.) to a database have form options to pass and/or infer datetime columns. However, the hive `df_to_sql` method does not support storing datetime columns as TIMESTAMPs in the Hive schema. It would be a nice for the `_get_hive_type` functionality to at least support the basic `datetime64[ns]` dtype.
@GerbenvdHuizen GerbenvdHuizen changed the title feat(db_engine_specs): Allow columns of dtype datetime to be stored as TIMESTAMP in the Hive schema feat(db_engine_specs): Allow uploaded columns of dtype datetime to be stored as TIMESTAMP in the Hive schema Oct 18, 2022
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!

@john-bodley
Copy link
Member

Thanks @GerbenvdHuizen for the PR. Would you mind formalizing your testing strategy as either a unit or integration test?

@GerbenvdHuizen
Copy link
Author

@john-bodley Added an integration test for all the schema definition types, since there didn't seem to be any yet.

@codecov
Copy link

codecov bot commented Oct 28, 2022

Codecov Report

All modified and coverable lines are covered by tests ✅

Comparison is base (8f4415b) 66.18% compared to head (40a5454) 65.96%.
Report is 2199 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master   #21850      +/-   ##
==========================================
- Coverage   66.18%   65.96%   -0.22%     
==========================================
  Files        1805     1987     +182     
  Lines       69066    90890   +21824     
  Branches     7369     7369              
==========================================
+ Hits        45712    59959   +14247     
- Misses      21448    29025    +7577     
  Partials     1906     1906              
Flag Coverage Δ
hive 54.50% <ø> (+1.58%) ⬆️
mysql 78.35% <ø> (?)
postgres 78.42% <ø> (?)
presto 54.46% <ø> (+1.63%) ⬆️
python 74.13% <ø> (-5.79%) ⬇️
sqlite 76.90% <ø> (+<0.01%) ⬆️
unit 55.00% <ø> (+3.93%) ⬆️

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.

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.

3 participants