codeant-ai-for-open-source[bot] commented on code in PR #44392:
URL: https://github.com/apache/superset/pull/44392#discussion_r4095531809
##########
superset/databases/schemas.py:
##########
@@ -944,9 +944,24 @@ class DatabaseRelatedDashboards(Schema):
)
+class DatabaseRelatedDataset(Schema):
+ id = fields.Integer()
+ table_name = fields.String()
+ schema = fields.String()
Review Comment:
**Suggestion:** Dataset schemas may be NULL, but this response schema
declares `schema` as non-nullable, so generated API clients reject valid
responses.
**Assessment:** ๐ `Major` ยท ๐ `Occurrence: Often` ยท ๐ท๏ธ `Api mismatch`
[](https://docs.codeant.ai/cli/resolve-pr-comments-skill)
[](https://app.codeant.ai/fix-in-ide?tool=cursor&prompt_id=e97c8993d72d44dcaa95db6d4f0659bb&service=github&base_url=https%3A%2F%2Fgithub.com&org=apache&repo=apache%2Fsuperset)
[](https://app.codeant.ai/fix-in-ide?tool=vscode-claude&prompt_id=e97c8993d72d44dcaa95db6d4f0659bb&service=github&base_url=https%3A%2F%2Fgithub.com&org=apache&repo=apache%2Fsuperset)
<details>
<summary><b>Prompt for AI Agent ๐ค </b></summary>
```mdx
This is a comment left during a code review.
**Path:** superset/databases/schemas.py
**Line:** 950:950
**Comment:**
*Api Mismatch: Dataset schemas may be NULL, but this response schema
declares `schema` as non-nullable, so generated API clients reject valid
responses.
Validate the correctness of the flagged issue. If correct, How can I resolve
this? If you propose a fix, implement it and please make it concise.
Once fix is implemented, also check other comments on the same PR, and ask
user if the user wants to fix the rest of the comments as well. if said yes,
then fetch all the comments validate the correctness and implement a minimal fix
```
</details>
<a
href='https://app.codeant.ai/feedback?pr_url=https%3A%2F%2Fgithub.com%2Fapache%2Fsuperset%2Fpull%2F44392&comment_hash=e3ace162abaef39dd097b0f7e73715cb6b8cea3dfe7815ec51bd53a44093e1aa&reaction=like'>๐</a>
| <a
href='https://app.codeant.ai/feedback?pr_url=https%3A%2F%2Fgithub.com%2Fapache%2Fsuperset%2Fpull%2F44392&comment_hash=e3ace162abaef39dd097b0f7e73715cb6b8cea3dfe7815ec51bd53a44093e1aa&reaction=dislike'>๐</a>
##########
superset/daos/database.py:
##########
@@ -49,10 +51,34 @@
logger = logging.getLogger(__name__)
+RELATED_DATASET_BATCH_SIZE = 100
+
class DatabaseDAO(BaseDAO[Database]):
base_filter = DatabaseFilter
+ @staticmethod
+ def _related_datasets_query(database_id: int) -> Query[SqlaTable]:
+ return (
+ db.session.query(SqlaTable)
+ .filter(SqlaTable.database_id == database_id)
+ .execution_options(**{SKIP_VISIBILITY_FILTER_CLASSES: {SqlaTable}})
+ )
+
+ @classmethod
+ def _iter_related_datasets(cls, database_id: int) -> Iterator[SqlaTable]:
+ """Yield dataset dependents in bounded batches, including archived
rows."""
+ last_id: int | None = None
+ while True:
+ query = cls._related_datasets_query(database_id)
+ if last_id is not None:
+ query = query.filter(SqlaTable.id > last_id)
+ batch =
query.order_by(SqlaTable.id).limit(RELATED_DATASET_BATCH_SIZE).all()
+ if not batch:
+ return
+ yield from batch
Review Comment:
**Suggestion:** When fewer than ten datasets are accessible, this iterator
scans every related row in batches, making modal requests scale with all hidden
datasets.
**Assessment:** ๐ `Major` ยท ๐ `Occurrence: Sometimes` ยท ๐ท๏ธ `Performance`
[](https://docs.codeant.ai/cli/resolve-pr-comments-skill)
[](https://app.codeant.ai/fix-in-ide?tool=cursor&prompt_id=595201bbb40242a79c992d5f5a55aef5&service=github&base_url=https%3A%2F%2Fgithub.com&org=apache&repo=apache%2Fsuperset)
[](https://app.codeant.ai/fix-in-ide?tool=vscode-claude&prompt_id=595201bbb40242a79c992d5f5a55aef5&service=github&base_url=https%3A%2F%2Fgithub.com&org=apache&repo=apache%2Fsuperset)
<details>
<summary><b>Prompt for AI Agent ๐ค </b></summary>
```mdx
This is a comment left during a code review.
**Path:** superset/daos/database.py
**Line:** 73:79
**Comment:**
*Performance: When fewer than ten datasets are accessible, this
iterator scans every related row in batches, making modal requests scale with
all hidden datasets.
Validate the correctness of the flagged issue. If correct, How can I resolve
this? If you propose a fix, implement it and please make it concise.
Once fix is implemented, also check other comments on the same PR, and ask
user if the user wants to fix the rest of the comments as well. if said yes,
then fetch all the comments validate the correctness and implement a minimal fix
```
</details>
<a
href='https://app.codeant.ai/feedback?pr_url=https%3A%2F%2Fgithub.com%2Fapache%2Fsuperset%2Fpull%2F44392&comment_hash=12dc365358483fbd5db390a15a128086a46e1715253a85c7016225d71e2eb8a5&reaction=like'>๐</a>
| <a
href='https://app.codeant.ai/feedback?pr_url=https%3A%2F%2Fgithub.com%2Fapache%2Fsuperset%2Fpull%2F44392&comment_hash=12dc365358483fbd5db390a15a128086a46e1715253a85c7016225d71e2eb8a5&reaction=dislike'>๐</a>
--
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]