bito-code-review[bot] commented on PR #43808:
URL: https://github.com/apache/superset/pull/43808#issuecomment-5546247880

   <!-- Bito Reply -->
   The current implementation correctly optimizes the import process by 
wrapping the `has_table` check in an `if data_uri:` block, ensuring the 
database round trip only occurs when data actually needs to be loaded. The test 
`test_import_dataset_skips_has_table_check_without_data_uri` correctly asserts 
that `has_table` is not called when `data_uri` is absent. 
   
   To address the case where `has_table()` returns `False` (meaning the table 
is missing), you can add a test case that mocks `has_table` to return `False` 
and asserts that `load_data` is called. This ensures that when data is provided 
but the table is missing, the import proceeds as expected.
   
   **tests/unit_tests/datasets/commands/importers/v1/import_test.py**
   ```
   def test_import_dataset_calls_load_data_when_table_missing(mocker: 
MockerFixture, session: Session) -> None:
       mocker.patch.object(security_manager, "can_access", return_value=True)
       has_table = mocker.patch.object(Database, "has_table", 
return_value=False)
       load_data = 
mocker.patch("superset.commands.dataset.importers.v1.utils.load_data")
   
       config = { ... } # Use a config with a data_uri
       import_dataset(config)
   
       has_table.assert_called_once()
       load_data.assert_called_once()
   ```


-- 
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