MCPcopy
hub / github.com/dlt-hub/dlt / test_read_not_materialized_table

Function test_read_not_materialized_table

tests/load/test_read_interfaces.py:1470–1525  ·  view source on GitHub ↗
(destination_config: DestinationTestConfiguration)

Source from the content-addressed store, hash-verified

1468
1469@pytest.mark.essential
1470def test_read_not_materialized_table(destination_config: DestinationTestConfiguration):
1471 # TODO lancedb destination faills unreliably on the 2nd `pipeline.run()` because
1472 # of the dltSentinel table. The test parallelization PR should solve this issue
1473 # and upgrading LanceDB destination with `lance-namespace` should avoid it
1474 # entirely.
1475 # TODO reenable test after fix
1476 if destination_config.destination_type == "lancedb":
1477 pytest.skip("lancedb has race conditions for dltSentinel table")
1478
1479 @dlt.source
1480 def two_tables():
1481 @dlt.resource(
1482 columns=[{"name": "id", "data_type": "bigint", "nullable": True, "primary_key": True}],
1483 write_disposition="append",
1484 table_format=destination_config.table_format,
1485 )
1486 def table_1():
1487 yield {"id": 1}
1488
1489 @dlt.resource(
1490 columns=[{"name": "id", "data_type": "bigint", "nullable": True}],
1491 write_disposition="replace",
1492 table_format=destination_config.table_format,
1493 )
1494 def table_3(make_data=False):
1495 return
1496 yield
1497
1498 return table_1, table_3
1499
1500 pipeline = destination_config.setup_pipeline(
1501 "test_pipeline_upfront_tables_two_loads",
1502 dataset_name="test_pipeline_upfront_tables_two_loads",
1503 dev_mode=True,
1504 )
1505
1506 # create table without any data in it and try to access it. destination should not know this table
1507 # expected behavior is that table is not found
1508 schema = two_tables().discover_schema()
1509
1510 # now we use this schema but load just one resource
1511 source = two_tables()
1512 # push state, table 3 not created
1513 pipeline.run(source.table_3, schema=schema, **destination_config.run_kwargs)
1514
1515 with pytest.raises(DestinationUndefinedEntity):
1516 pipeline.dataset().table_3.fetchall()
1517
1518 # now set table_3 so it has seen data
1519 with pipeline.dataset() as dataset_:
1520 schema = dataset_.schema
1521 schema.tables["table_3"]["x-normalizer"] = {"seen-data": True}
1522
1523 # forces sql_client to map views. but data does not exist so must raise same exceptions
1524 with pytest.raises(DestinationUndefinedEntity):
1525 pipeline.dataset().table_3.fetchall()
1526
1527

Callers

nothing calls this directly

Calls 6

setup_pipelineMethod · 0.80
discover_schemaMethod · 0.80
datasetMethod · 0.80
two_tablesFunction · 0.70
runMethod · 0.45
fetchallMethod · 0.45

Tested by

no test coverage detected