FrancescoCastaldi commented on code in PR #45205:
URL: https://github.com/apache/superset/pull/45205#discussion_r4422156565
##########
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:
Great catch on the SQLite weekday bucketing edge case! You're completely
right: `'weekday 0', '-7 days'` when evaluated on a Sunday (or Monday for
Monday-start) steps back an extra full week under SQLite semantics.
Since this PR's scope is strictly backfilling baseline unit test coverage
for existing engine spec definitions without altering their generated SQL
expressions (and as you noted, `mongodb.py:121` shares this identical logic),
keeping the dialect-level bug fix in a dedicated issue/PR is definitely the
cleanest approach. Please feel free to open an issue/PR for that fix and we'll
be glad to help review and test it across both specs!
--
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]