Search in sources :

Example 11 with SparkCatalog

use of org.apache.iceberg.spark.SparkCatalog in project OpenLineage by OpenLineage.

the class IcebergHandlerTest method testGetDatasetIdentifierForHadoop.

@ParameterizedTest
@CsvSource({ "hdfs://namenode:8020/warehouse,hdfs://namenode:8020,/warehouse/database.schema.table", "/tmp/warehouse,file,/tmp/warehouse/database.schema.table" })
public void testGetDatasetIdentifierForHadoop(String warehouseConf, String namespace, String name) {
    when(sparkSession.conf()).thenReturn(runtimeConfig);
    when(runtimeConfig.getAll()).thenReturn(new Map.Map2<>("spark.sql.catalog.test.type", "hadoop", "spark.sql.catalog.test.warehouse", warehouseConf));
    SparkCatalog sparkCatalog = mock(SparkCatalog.class);
    when(sparkCatalog.name()).thenReturn("test");
    DatasetIdentifier datasetIdentifier = icebergHandler.getDatasetIdentifier(sparkSession, sparkCatalog, Identifier.of(new String[] { "database", "schema" }, "table"), new HashMap<>());
    assertEquals(name, datasetIdentifier.getName());
    assertEquals(namespace, datasetIdentifier.getNamespace());
}
Also used : SparkCatalog(org.apache.iceberg.spark.SparkCatalog) DatasetIdentifier(io.openlineage.spark.agent.util.DatasetIdentifier) HashMap(java.util.HashMap) Map(scala.collection.immutable.Map) CsvSource(org.junit.jupiter.params.provider.CsvSource) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Aggregations

SparkCatalog (org.apache.iceberg.spark.SparkCatalog)11 SparkTable (org.apache.iceberg.spark.source.SparkTable)6 Identifier (org.apache.spark.sql.connector.catalog.Identifier)5 Test (org.junit.Test)5 DatasetIdentifier (io.openlineage.spark.agent.util.DatasetIdentifier)4 Map (java.util.Map)4 File (java.io.File)3 StreamSupport (java.util.stream.StreamSupport)3 DeleteOrphanFiles (org.apache.iceberg.actions.DeleteOrphanFiles)3 Maps (org.apache.iceberg.relocated.com.google.common.collect.Maps)3 SparkSchemaUtil (org.apache.iceberg.spark.SparkSchemaUtil)3 SparkSessionCatalog (org.apache.iceberg.spark.SparkSessionCatalog)3 Transform (org.apache.spark.sql.connector.expressions.Transform)3 After (org.junit.After)3 Assert (org.junit.Assert)3 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)3 HashMap (java.util.HashMap)2 SneakyThrows (lombok.SneakyThrows)2 NoSuchTableException (org.apache.spark.sql.catalyst.analysis.NoSuchTableException)2 Test (org.junit.jupiter.api.Test)2