You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@superset.apache.org by GitBox <gi...@apache.org> on 2022/10/21 01:04:39 UTC

[GitHub] [superset] passren opened a new pull request, #21900: feat: Add a new database driver for Amazon DynamoDB

passren opened a new pull request, #21900:
URL: https://github.com/apache/superset/pull/21900

   <!---
   Please write the PR title following the conventions at https://www.conventionalcommits.org/en/v1.0.0/
   Example:
   fix(dashboard): load charts correctly
   -->
   
   ### SUMMARY
   <!--- Describe the change below, including rationale and design decisions -->
   There is no database driver for Amazon DynamoDB so far. I developed a Python DB API 2.0 (PEP 249) client for Amazon DynamoDB and did some work to be compatible with Superset. My Project is [here](https://github.com/passren/PyDynamoDB). The latest version is 0.4.2 which have already supported Superset connector.
   
   
   ### BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF
   <!--- Skip this if not applicable -->
   
   ![image](https://user-images.githubusercontent.com/7568620/197087136-5cf27f24-3e82-423a-af15-93caa50d9c1f.png)
   
   
   ### TESTING INSTRUCTIONS
   <!--- Required! What steps can be taken to manually verify the changes? -->
   This is just a DB engine spec. No unit test required. For the setup in the Superset, please refer to the doc in my project.
   https://github.com/passren/PyDynamoDB/wiki/5.-Superset
   
   I tested in my Superset environment (v2.0) and it works.
   
   ### ADDITIONAL INFORMATION
   <!--- Check any relevant boxes with "x" -->
   <!--- HINT: Include "Fixes #nnn" if you are fixing an existing issue -->
   - [ ] Has associated issue:
   - [ ] Required feature flags:
   - [ ] Changes UI
   - [ ] Includes DB Migration (follow approval process in [SIP-59](https://github.com/apache/superset/issues/13351))
     - [ ] Migration is atomic, supports rollback & is backwards-compatible
     - [ ] Confirm DB migration upgrade and downgrade tested
     - [ ] Runtime estimates and downtime expectations provided
   - [X] Introduces new feature or API
   - [ ] Removes existing feature or API
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org


[GitHub] [superset] srinify commented on pull request #21900: feat: Add a new database driver for Amazon DynamoDB

Posted by GitBox <gi...@apache.org>.
srinify commented on PR #21900:
URL: https://github.com/apache/superset/pull/21900#issuecomment-1288122954

   This is an awesome start @passren ! 
   
   It may be worthwhile to add the database -> driver mapping here as well: https://github.com/apache/superset/blob/master/setup.py#L126
   
   cc @villebro too


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org


[GitHub] [superset] codecov[bot] commented on pull request #21900: feat: Add a new database driver for Amazon DynamoDB

Posted by GitBox <gi...@apache.org>.
codecov[bot] commented on PR #21900:
URL: https://github.com/apache/superset/pull/21900#issuecomment-1288123749

   # [Codecov](https://codecov.io/gh/apache/superset/pull/21900?src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) Report
   > Merging [#21900](https://codecov.io/gh/apache/superset/pull/21900?src=pr&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) (c4ba606) into [master](https://codecov.io/gh/apache/superset/commit/e4186941508476780323f67fa6a20332dec057eb?el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) (e418694) will **decrease** coverage by `10.77%`.
   > The diff coverage is `87.50%`.
   
   ```diff
   @@             Coverage Diff             @@
   ##           master   #21900       +/-   ##
   ===========================================
   - Coverage   66.16%   55.38%   -10.78%     
   ===========================================
     Files        1806     1807        +1     
     Lines       69140    69148        +8     
     Branches     7393     7393               
   ===========================================
   - Hits        45746    38298     -7448     
   - Misses      21485    28941     +7456     
     Partials     1909     1909               
   ```
   
   | Flag | Coverage Δ | |
   |---|---|---|
   | hive | `?` | |
   | presto | `52.83% <87.50%> (+<0.01%)` | :arrow_up: |
   | python | `57.59% <87.50%> (-22.33%)` | :arrow_down: |
   | sqlite | `?` | |
   | unit | `51.08% <87.50%> (+<0.01%)` | :arrow_up: |
   
   Flags with carried forward coverage won't be shown. [Click here](https://docs.codecov.io/docs/carryforward-flags?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#carryforward-flags-in-the-pull-request-comment) to find out more.
   
   | [Impacted Files](https://codecov.io/gh/apache/superset/pull/21900?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) | Coverage Δ | |
   |---|---|---|
   | [superset/db\_engine\_specs/dynamodb.py](https://codecov.io/gh/apache/superset/pull/21900/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-c3VwZXJzZXQvZGJfZW5naW5lX3NwZWNzL2R5bmFtb2RiLnB5) | `87.50% <87.50%> (ø)` | |
   | [superset/utils/dashboard\_import\_export.py](https://codecov.io/gh/apache/superset/pull/21900/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-c3VwZXJzZXQvdXRpbHMvZGFzaGJvYXJkX2ltcG9ydF9leHBvcnQucHk=) | `0.00% <0.00%> (-100.00%)` | :arrow_down: |
   | [superset/tags/core.py](https://codecov.io/gh/apache/superset/pull/21900/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-c3VwZXJzZXQvdGFncy9jb3JlLnB5) | `4.54% <0.00%> (-95.46%)` | :arrow_down: |
   | [superset/key\_value/commands/update.py](https://codecov.io/gh/apache/superset/pull/21900/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-c3VwZXJzZXQva2V5X3ZhbHVlL2NvbW1hbmRzL3VwZGF0ZS5weQ==) | `0.00% <0.00%> (-90.91%)` | :arrow_down: |
   | [superset/key\_value/commands/delete.py](https://codecov.io/gh/apache/superset/pull/21900/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-c3VwZXJzZXQva2V5X3ZhbHVlL2NvbW1hbmRzL2RlbGV0ZS5weQ==) | `0.00% <0.00%> (-87.88%)` | :arrow_down: |
   | [superset/db\_engines/hive.py](https://codecov.io/gh/apache/superset/pull/21900/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-c3VwZXJzZXQvZGJfZW5naW5lcy9oaXZlLnB5) | `0.00% <0.00%> (-85.19%)` | :arrow_down: |
   | [superset/key\_value/commands/delete\_expired.py](https://codecov.io/gh/apache/superset/pull/21900/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-c3VwZXJzZXQva2V5X3ZhbHVlL2NvbW1hbmRzL2RlbGV0ZV9leHBpcmVkLnB5) | `0.00% <0.00%> (-84.00%)` | :arrow_down: |
   | [superset/dashboards/commands/importers/v0.py](https://codecov.io/gh/apache/superset/pull/21900/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-c3VwZXJzZXQvZGFzaGJvYXJkcy9jb21tYW5kcy9pbXBvcnRlcnMvdjAucHk=) | `15.62% <0.00%> (-76.25%)` | :arrow_down: |
   | [superset/reports/commands/execute.py](https://codecov.io/gh/apache/superset/pull/21900/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-c3VwZXJzZXQvcmVwb3J0cy9jb21tYW5kcy9leGVjdXRlLnB5) | `24.04% <0.00%> (-67.95%)` | :arrow_down: |
   | [superset/views/datasource/utils.py](https://codecov.io/gh/apache/superset/pull/21900/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-c3VwZXJzZXQvdmlld3MvZGF0YXNvdXJjZS91dGlscy5weQ==) | `26.66% <0.00%> (-66.67%)` | :arrow_down: |
   | ... and [271 more](https://codecov.io/gh/apache/superset/pull/21900/diff?src=pr&el=tree-more&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) | |
   
   :mega: We’re building smart automated test selection to slash your CI/CD build times. [Learn more](https://about.codecov.io/iterative-testing/?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation)
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org


[GitHub] [superset] passren commented on a diff in pull request #21900: feat: Add a new database driver for Amazon DynamoDB

Posted by GitBox <gi...@apache.org>.
passren commented on code in PR #21900:
URL: https://github.com/apache/superset/pull/21900#discussion_r1006384720


##########
superset/db_engine_specs/dynamodb.py:
##########
@@ -0,0 +1,49 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+from superset.db_engine_specs.base import BaseEngineSpec
+
+
+class DynamoDBEngineSpec(BaseEngineSpec):
+    engine = "dynamodb"
+    engine_name = "Amazon DynamoDB"
+
+    _time_grain_expressions = {
+        None: "{col}",
+        "PT1S": "DATETIME(STRFTIME('%Y-%m-%dT%H:%M:%S', {col}))",
+        "PT1M": "DATETIME(STRFTIME('%Y-%m-%dT%H:%M:00', {col}))",
+        "PT1H": "DATETIME(STRFTIME('%Y-%m-%dT%H:00:00', {col}))",
+        "P1D": "DATETIME({col}, 'start of day')",
+        "P1W": "DATETIME({col}, 'start of day', -strftime('%w', {col}) || ' days')",
+        "P1M": "DATETIME({col}, 'start of month')",
+        "P3M": (
+            "DATETIME({col}, 'start of month', "
+            "printf('-%d month', (strftime('%m', {col}) - 1) % 3))"
+        ),
+        "P1Y": "DATETIME({col}, 'start of year')",
+        "P1W/1970-01-03T00:00:00Z": "DATETIME({col}, 'start of day', 'weekday 6')",
+        "P1W/1970-01-04T00:00:00Z": "DATETIME({col}, 'start of day', 'weekday 0')",
+        "1969-12-28T00:00:00Z/P1W": (
+            "DATETIME({col}, 'start of day', 'weekday 0', '-7 days')"
+        ),
+        "1969-12-29T00:00:00Z/P1W": (
+            "DATETIME({col}, 'start of day', 'weekday 1', '-7 days')"
+        ),
+    }
+
+    @classmethod
+    def epoch_to_dttm(cls) -> str:
+        return "datetime({col}, 'unixepoch')"

Review Comment:
   @villebro I added the convert_dttm and unit test case. Since leverage SQLite to get final dataset, I just copy the method and test cases from sqlite in db_engine_sepc.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org


[GitHub] [superset] villebro commented on a diff in pull request #21900: feat: Add a new database driver for Amazon DynamoDB

Posted by GitBox <gi...@apache.org>.
villebro commented on code in PR #21900:
URL: https://github.com/apache/superset/pull/21900#discussion_r1003005792


##########
superset/db_engine_specs/dynamodb.py:
##########
@@ -0,0 +1,49 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+from superset.db_engine_specs.base import BaseEngineSpec
+
+
+class DynamoDBEngineSpec(BaseEngineSpec):
+    engine = "dynamodb"
+    engine_name = "Amazon DynamoDB"
+
+    _time_grain_expressions = {
+        None: "{col}",
+        "PT1S": "DATETIME(STRFTIME('%Y-%m-%dT%H:%M:%S', {col}))",
+        "PT1M": "DATETIME(STRFTIME('%Y-%m-%dT%H:%M:00', {col}))",
+        "PT1H": "DATETIME(STRFTIME('%Y-%m-%dT%H:00:00', {col}))",
+        "P1D": "DATETIME({col}, 'start of day')",
+        "P1W": "DATETIME({col}, 'start of day', -strftime('%w', {col}) || ' days')",
+        "P1M": "DATETIME({col}, 'start of month')",
+        "P3M": (
+            "DATETIME({col}, 'start of month', "
+            "printf('-%d month', (strftime('%m', {col}) - 1) % 3))"
+        ),
+        "P1Y": "DATETIME({col}, 'start of year')",
+        "P1W/1970-01-03T00:00:00Z": "DATETIME({col}, 'start of day', 'weekday 6')",
+        "P1W/1970-01-04T00:00:00Z": "DATETIME({col}, 'start of day', 'weekday 0')",
+        "1969-12-28T00:00:00Z/P1W": (
+            "DATETIME({col}, 'start of day', 'weekday 0', '-7 days')"
+        ),
+        "1969-12-29T00:00:00Z/P1W": (
+            "DATETIME({col}, 'start of day', 'weekday 1', '-7 days')"
+        ),
+    }
+
+    @classmethod
+    def epoch_to_dttm(cls) -> str:
+        return "datetime({col}, 'unixepoch')"

Review Comment:
   I would also recommend implementing `convert_dttm` which is also often needed



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org


[GitHub] [superset] passren commented on pull request #21900: feat: Add a new database driver for Amazon DynamoDB

Posted by GitBox <gi...@apache.org>.
passren commented on PR #21900:
URL: https://github.com/apache/superset/pull/21900#issuecomment-1288253885

   > This is an awesome start @passren !
   > 
   > It may be worthwhile to add the database -> driver mapping here as well: https://github.com/apache/superset/blob/master/setup.py#L126
   > 
   > cc @villebro too
   
   Thanks for your reminder. It has been added here.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org


[GitHub] [superset] passren commented on a diff in pull request #21900: feat: Add a new database driver for Amazon DynamoDB

Posted by GitBox <gi...@apache.org>.
passren commented on code in PR #21900:
URL: https://github.com/apache/superset/pull/21900#discussion_r1004495861


##########
superset/db_engine_specs/dynamodb.py:
##########
@@ -0,0 +1,49 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+from superset.db_engine_specs.base import BaseEngineSpec
+
+
+class DynamoDBEngineSpec(BaseEngineSpec):
+    engine = "dynamodb"
+    engine_name = "Amazon DynamoDB"
+
+    _time_grain_expressions = {
+        None: "{col}",
+        "PT1S": "DATETIME(STRFTIME('%Y-%m-%dT%H:%M:%S', {col}))",
+        "PT1M": "DATETIME(STRFTIME('%Y-%m-%dT%H:%M:00', {col}))",
+        "PT1H": "DATETIME(STRFTIME('%Y-%m-%dT%H:00:00', {col}))",
+        "P1D": "DATETIME({col}, 'start of day')",
+        "P1W": "DATETIME({col}, 'start of day', -strftime('%w', {col}) || ' days')",
+        "P1M": "DATETIME({col}, 'start of month')",
+        "P3M": (
+            "DATETIME({col}, 'start of month', "
+            "printf('-%d month', (strftime('%m', {col}) - 1) % 3))"
+        ),
+        "P1Y": "DATETIME({col}, 'start of year')",
+        "P1W/1970-01-03T00:00:00Z": "DATETIME({col}, 'start of day', 'weekday 6')",
+        "P1W/1970-01-04T00:00:00Z": "DATETIME({col}, 'start of day', 'weekday 0')",
+        "1969-12-28T00:00:00Z/P1W": (
+            "DATETIME({col}, 'start of day', 'weekday 0', '-7 days')"
+        ),
+        "1969-12-29T00:00:00Z/P1W": (
+            "DATETIME({col}, 'start of day', 'weekday 1', '-7 days')"
+        ),
+    }
+
+    @classmethod
+    def epoch_to_dttm(cls) -> str:
+        return "datetime({col}, 'unixepoch')"

Review Comment:
   > I would also recommend implementing `convert_dttm` which is also often needed
   
   ### @villebro  Thanks for your comments. Will do that.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org


[GitHub] [superset] passren closed pull request #21900: feat: Add a new database driver for Amazon DynamoDB

Posted by GitBox <gi...@apache.org>.
passren closed pull request #21900: feat: Add a new database driver for Amazon DynamoDB
URL: https://github.com/apache/superset/pull/21900


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org


[GitHub] [superset] passren commented on pull request #21900: feat: Add a new database driver for Amazon DynamoDB

Posted by GitBox <gi...@apache.org>.
passren commented on PR #21900:
URL: https://github.com/apache/superset/pull/21900#issuecomment-1308322401

   **@srinify** **@villebro** Hi, is there anything I can do to move forward this PR?


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org