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: add connector for CouchbaseDB #29225

Merged
merged 5 commits into from
Jul 10, 2024
Merged

Conversation

ayush33143314
Copy link
Contributor

SUMMARY

Add support for couchbase db. https://www.couchbase.com/products/analytics/

TESTING INSTRUCTIONS

mannual Testing

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

@dosubot dosubot bot added data:connect Namespace | Anything related to db connections / integrations enhancement:db Suggest new DB connections labels Jun 12, 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

codecov bot commented Jun 12, 2024

Codecov Report

Attention: Patch coverage is 60.82474% with 38 lines in your changes missing coverage. Please review.

Project coverage is 70.34%. Comparing base (76d897e) to head (9c8016a).
Report is 433 commits behind head on master.

Files Patch % Lines
superset/db_engine_specs/couchbasedb.py 60.82% 38 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master   #29225      +/-   ##
==========================================
+ Coverage   60.48%   70.34%   +9.85%     
==========================================
  Files        1931     1970      +39     
  Lines       76236    78585    +2349     
  Branches     8568     8973     +405     
==========================================
+ Hits        46114    55279    +9165     
+ Misses      28017    21108    -6909     
- Partials     2105     2198      +93     
Flag Coverage Δ
hive 49.12% <54.63%> (-0.05%) ⬇️
javascript 58.05% <ø> (+0.33%) ⬆️
mysql 77.00% <54.63%> (?)
postgres 77.08% <54.63%> (?)
presto 53.71% <54.63%> (-0.10%) ⬇️
python 83.65% <60.82%> (+20.16%) ⬆️
sqlite 76.57% <54.63%> (?)
unit 59.67% <60.82%> (+2.05%) ⬆️

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.

Any
)

class CouchbaseEngineSpec(BaseEngineSpec):
Copy link
Member

Choose a reason for hiding this comment

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

you can you add BasicParametersMixin to this since using MYSQL dialect
https://github.com/apache/superset/blob/master/superset/db_engine_specs/base.py#L2276

@john-bodley
Copy link
Member

Thanks @ayush33143314 for adding the engine. Would you also mind:

  • Adding unit/integration tests (where necessary)
  • Updating the various documentation which outlines which engines we support etc.

@pull-request-size pull-request-size bot added size/L and removed size/M labels Jun 24, 2024
@rusackas
Copy link
Member

Thank you for this! Would it also be possible to add a docs entry here?

@ayush-couchbase
Copy link
Contributor

Thank you for this! Would it also be possible to add a docs entry here?

Hi , yes, I am preparing the doc, I will submit doc along with tests in next patchset. Sorry for this patch. It is still in progress.

@rusackas
Copy link
Member

Ahh, ok, thanks! Feel free to add [WIP] to the title and/or convert it to a draft PR if you need a while to keep working on it, just so others don't assume it's ready for review like I did. Thanks again!

@github-actions github-actions bot added the doc Namespace | Anything related to documentation label Jul 4, 2024
@ayush-couchbase
Copy link
Contributor

@hughhhh @john-bodley Please review my latest patch, and guide me if I need to make any change. Thank you

@huangang
Copy link

huangang commented Jul 9, 2024

Looking forward to this PR being merged

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.

Looks mostly good, but added a few comments/questions.

Comment on lines 100 to 106
@classmethod
def epoch_to_dttm(cls) -> str:
return "MILLIS_TO_STR({col} * 1000, '111')"

@classmethod
def epoch_ms_to_dttm(cls) -> str:
return "MILLIS_TO_STR({col}, '111')"
Copy link
Member

Choose a reason for hiding this comment

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

I tried reading up on the docs, and I didn't fully understand how this format is valid:

To be clear, the idea of these methods is to provide an expression that can convert an epoch (seconds since 1970-01-01 00:00:00 in UTC) into a native temporal format. But if it works it works - if this is the case, maybe adding a comment as to why the format '111' works here would be helpful.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thank you so much for your comments,
If format is unspecified or incorrect it gives combined date and time in result , On querying
SELECT MILLIS_TO_STR(1463284740000,'111'); it gives me "2016-05-15T03:59:00Z" in result . I had this '111' just for notation . But I have removed this in my new patch , because MILLIS_TO_STR(1463284740000) also gives me same results.

Comment on lines +48 to +57
("Date", "DATETIME(DATE_FORMAT_STR(STR_TO_UTC('2019-01-02'), 'iso8601'))"),
(
"DateTime",
"DATETIME(DATE_FORMAT_STR(STR_TO_UTC('2019-01-02T03:04:05'), 'iso8601'))",
),
Copy link
Member

Choose a reason for hiding this comment

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

It would be nice to have a few more typical formats featured here, like VARCHAR, TEXT, INT, as I assume those will be commonly used.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I have added test case for other data types also.

@rusackas
Copy link
Member

rusackas commented Jul 9, 2024

Feel free to add the logo, too! They can appear on the website and readme.

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.

One small last comment, we can probably do improvements in follow-up PRs. Also, since CounchbaseDB doesn't seem to have any dedicated temporal types, have you been able to get it to work fully with temporal charts? If not, you may benefit from specifying column_type_mutators on your spec to handle the conversion after query results come in.

tests/unit_tests/db_engine_specs/test_couchbase.py Outdated Show resolved Hide resolved
@villebro villebro merged commit ec5bbaa into apache:master Jul 10, 2024
39 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
data:connect:couchdb data:connect Namespace | Anything related to db connections / integrations doc Namespace | Anything related to documentation enhancement:db Suggest new DB connections size/L
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

7 participants