use of io.openlineage.spark3.agent.lifecycle.plan.catalog.CatalogUtils3 in project OpenLineage by OpenLineage.
the class PlanUtils3Test method testGetDatasetIdentifier.
@Test
public void testGetDatasetIdentifier() {
DatasetIdentifier di = mock(DatasetIdentifier.class);
try (MockedStatic<CatalogUtils3> mocked = mockStatic(CatalogUtils3.class)) {
when(CatalogUtils3.getDatasetIdentifier(sparkSession, tableCatalog, identifier, tableProperties)).thenReturn(di);
assertEquals(di, PlanUtils3.getDatasetIdentifier(openLineageContext, tableCatalog, identifier, tableProperties).get());
}
}
use of io.openlineage.spark3.agent.lifecycle.plan.catalog.CatalogUtils3 in project OpenLineage by OpenLineage.
the class PlanUtils3Test method testIncludeProviderFacet.
@Test
public void testIncludeProviderFacet() {
try (MockedStatic<CatalogUtils3> mocked = mockStatic(CatalogUtils3.class)) {
Map<String, OpenLineage.DatasetFacet> facets = new HashMap<>();
TableProviderFacet tableProviderFacet = new TableProviderFacet("iceberg", "parquet");
when(CatalogUtils3.getTableProviderFacet(tableCatalog, tableProperties)).thenReturn(Optional.of(tableProviderFacet));
PlanUtils3.includeProviderFacet(tableCatalog, tableProperties, facets);
assertEquals(tableProviderFacet, facets.get("tableProvider"));
}
}
use of io.openlineage.spark3.agent.lifecycle.plan.catalog.CatalogUtils3 in project OpenLineage by OpenLineage.
the class PlanUtils3Test method testGetDatasetIdentifierWhenCatalogUnsupported.
@Test
public void testGetDatasetIdentifierWhenCatalogUnsupported() {
try (MockedStatic<CatalogUtils3> mocked = mockStatic(CatalogUtils3.class)) {
when(CatalogUtils3.getDatasetIdentifier(sparkSession, tableCatalog, identifier, tableProperties)).thenThrow(new UnsupportedCatalogException("exception"));
assertEquals(Optional.empty(), PlanUtils3.getDatasetIdentifier(openLineageContext, tableCatalog, identifier, tableProperties));
}
}
use of io.openlineage.spark3.agent.lifecycle.plan.catalog.CatalogUtils3 in project OpenLineage by OpenLineage.
the class PlanUtils3Test method testFromDataSourceV2RelationWhenDatasetIdentifierEmpty.
@Test
public void testFromDataSourceV2RelationWhenDatasetIdentifierEmpty() {
try (MockedStatic<CatalogUtils3> mocked = mockStatic(CatalogUtils3.class)) {
DatasetIdentifier di = mock(DatasetIdentifier.class);
OpenLineage.Dataset dataset = mock(OpenLineage.Dataset.class);
when(CatalogUtils3.getDatasetIdentifier(sparkSession, tableCatalog, identifier, tableProperties)).thenThrow(new UnsupportedCatalogException("exception"));
when(datasetFactory.getDataset(di, schema)).thenReturn(dataset);
assertEquals(Collections.emptyList(), PlanUtils3.fromDataSourceV2Relation(datasetFactory, openLineageContext, dataSourceV2Relation));
}
}
use of io.openlineage.spark3.agent.lifecycle.plan.catalog.CatalogUtils3 in project OpenLineage by OpenLineage.
the class PlanUtils3Test method testFromDataSourceV2Relation.
@Test
public void testFromDataSourceV2Relation() {
try (MockedStatic<CatalogUtils3> mocked = mockStatic(CatalogUtils3.class)) {
try (MockedStatic<PlanUtils> mockedPlanUtils = mockStatic(PlanUtils.class)) {
DatasetIdentifier di = mock(DatasetIdentifier.class);
when(di.getNamespace()).thenReturn("file://tmp");
when(di.getName()).thenReturn("name");
OpenLineage.DatasetFacets datasetFacets = mock(OpenLineage.DatasetFacets.class);
OpenLineage.Dataset dataset = mock(OpenLineage.Dataset.class);
OpenLineage.SchemaDatasetFacet schemaDatasetFacet = mock(OpenLineage.SchemaDatasetFacet.class);
OpenLineage.DatasourceDatasetFacet datasourceDatasetFacet = mock(OpenLineage.DatasourceDatasetFacet.class);
when(PlanUtils.schemaFacet(openLineage, schema)).thenReturn(schemaDatasetFacet);
when(PlanUtils.datasourceFacet(openLineage, di.getNamespace())).thenReturn(datasourceDatasetFacet);
when(datasetFacetsBuilder.schema(schemaDatasetFacet)).thenReturn(datasetFacetsBuilder);
when(datasetFacetsBuilder.dataSource(datasourceDatasetFacet)).thenReturn(datasetFacetsBuilder);
when(datasetFacetsBuilder.build()).thenReturn(datasetFacets);
when(CatalogUtils3.getDatasetIdentifier(sparkSession, tableCatalog, identifier, tableProperties)).thenReturn(di);
when(datasetFactory.getDataset(di.getName(), di.getNamespace(), datasetFacets)).thenReturn(dataset);
assertEquals(Collections.singletonList(dataset), PlanUtils3.fromDataSourceV2Relation(datasetFactory, openLineageContext, dataSourceV2Relation));
}
}
}
Aggregations