|
6 | 6 | from databricks.labs.blueprint.parallel import ManyError
|
7 | 7 | from databricks.labs.lsql.backends import MockBackend, SqlBackend
|
8 | 8 | from databricks.sdk import WorkspaceClient
|
9 |
| -from databricks.sdk.errors import NotFound |
| 9 | +from databricks.sdk.errors import NotFound, BadRequest |
10 | 10 | from databricks.sdk.errors.platform import ResourceConflict
|
11 | 11 | from databricks.sdk.service.catalog import TableInfo
|
12 | 12 |
|
@@ -254,15 +254,27 @@ def test_unskip_on_schema():
|
254 | 254 | )
|
255 | 255 |
|
256 | 256 |
|
257 |
| -def test_unskip_missing_table(caplog): |
| 257 | +def test_unskip_missing_table(): |
258 | 258 | ws = create_autospec(WorkspaceClient)
|
259 | 259 | sbe = create_autospec(SqlBackend)
|
260 |
| - installation = MockInstallation() |
261 | 260 | sbe.execute.side_effect = NotFound("[TABLE_OR_VIEW_NOT_FOUND]")
|
| 261 | + installation = MockInstallation() |
262 | 262 | mapping = TableMapping(installation, ws, sbe)
|
263 |
| - mapping.unskip_table_or_view(schema_name='foo', table_name="table", load_table=lambda schema, table: None) |
264 | 263 | ws.tables.get.assert_not_called()
|
265 |
| - assert [rec.message for rec in caplog.records if "table not found" in rec.message.lower()] |
| 264 | + with pytest.raises(NotFound, match="[TABLE_OR_VIEW_NOT_FOUND]"): |
| 265 | + mapping.unskip_table_or_view(schema_name='foo', table_name="table", load_table=lambda schema, table: None) |
| 266 | + |
| 267 | + |
| 268 | +def test_unskip_badrequest(caplog): |
| 269 | + ws = create_autospec(WorkspaceClient) |
| 270 | + sbe = create_autospec(SqlBackend) |
| 271 | + sbe.execute.side_effect = BadRequest("[Bad command]") |
| 272 | + installation = MockInstallation() |
| 273 | + mapping = TableMapping(installation, ws, sbe) |
| 274 | + table = Table(catalog="catalog", database="schema", name="table", object_type="table", table_format="csv") |
| 275 | + ws.tables.get.assert_not_called() |
| 276 | + mapping.unskip_table_or_view(schema_name="schema", table_name="table", load_table=lambda _schema, _table: table) |
| 277 | + assert [rec.message for rec in caplog.records if "bad command" in rec.message.lower()] |
266 | 278 |
|
267 | 279 |
|
268 | 280 | def test_skip_missing_schema(caplog):
|
|
0 commit comments