EnxDev commented on code in PR #45205:
URL: https://github.com/apache/superset/pull/45205#discussion_r4402451380


##########
tests/unit_tests/db_engine_specs/test_dynamodb.py:
##########
@@ -124,3 +124,47 @@ def test_convert_dttm_preserves_timezone_offset() -> None:
         )
         == "'2019-01-02T04:00:00+00:00'"
     )
+
+
+def test_dynamodb_properties() -> None:
+    from superset.db_engine_specs.dynamodb import DynamoDBEngineSpec
+
+    assert DynamoDBEngineSpec.engine == "dynamodb"
+    assert DynamoDBEngineSpec.engine_name == "Amazon DynamoDB"
+
+
+def test_dynamodb_metadata() -> None:
+    from superset.db_engine_specs.dynamodb import DynamoDBEngineSpec
+
+    metadata = DynamoDBEngineSpec.metadata
+    assert "Amazon DynamoDB is a serverless NoSQL database" in 
metadata["description"]
+    assert metadata["logo"] == "aws.png"
+    assert "pydynamodb" in metadata["pypi_packages"]
+
+
+def test_epoch_to_dttm() -> None:
+    from superset.db_engine_specs.dynamodb import DynamoDBEngineSpec
+
+    assert (
+        DynamoDBEngineSpec.epoch_to_dttm().format(col="ts")
+        == "datetime(ts, 'unixepoch')"
+    )
+
+
[email protected](
+    "time_grain,expected",
+    [
+        (None, "ts"),
+        ("PT1S", "DATETIME(STRFTIME('%Y-%m-%dT%H:%M:%S', ts))"),
+        ("PT1M", "DATETIME(STRFTIME('%Y-%m-%dT%H:%M:00', ts))"),
+        ("PT1H", "DATETIME(STRFTIME('%Y-%m-%dT%H:00:00', ts))"),
+        ("P1D", "DATETIME(ts, 'start of day')"),
+        ("P1M", "DATETIME(ts, 'start of month')"),
+        ("P1Y", "DATETIME(ts, 'start of year')"),

Review Comment:
   The grains left out here (WEEK, QUARTER, the week-starting/ending ones) are 
the only ones with real logic, and two of them are off. With 
`connector=superset` the SQL runs in SQLite, where `'weekday 0', '-7 days'` on 
a date that's already Sunday goes back a full week: `2024-01-07` buckets into 
`2023-12-31`. Same for Monday-start on a Monday.
   
   Not this PR's bug, and `mongodb.py:121` has the identical expressions. But a 
test that runs these through `sqlite3` with a Sunday/Monday input would catch 
it, which a string-equality row can't. Worth adding, or I'm happy to open an 
issue for the fix.



-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to