forked from OpenLineage/OpenLineage
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #13 from nubank/nufacet-resolved-input-map-enhance…
…ment Nufacet resolved input map enhancement
- Loading branch information
Showing
3 changed files
with
64 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,3 +4,5 @@ bin/ | |
*/spark-warehouse | ||
|
||
.sdkmanrc | ||
|
||
integration/spark/docker/notebooks/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
33 changes: 33 additions & 0 deletions
33
integration/spark/shared/src/main/java/io/openlineage/spark/agent/util/NuFacetsUtils.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
package io.openlineage.spark.agent.util; | ||
|
||
import com.fasterxml.jackson.core.JsonProcessingException; | ||
import com.fasterxml.jackson.core.type.TypeReference; | ||
import com.fasterxml.jackson.databind.ObjectMapper; | ||
import lombok.extern.slf4j.Slf4j; | ||
import org.apache.spark.sql.SparkSession; | ||
|
||
import java.util.HashMap; | ||
import java.util.Map; | ||
import java.util.NoSuchElementException; | ||
import java.util.Objects; | ||
|
||
@Slf4j | ||
public class NuFacetsUtils { | ||
public static Map<String, String> parseJsonToMap(String jsonString) throws JsonProcessingException { | ||
if (Objects.isNull(jsonString)) { | ||
return null; | ||
} | ||
ObjectMapper mapper = new ObjectMapper(); | ||
TypeReference<HashMap<String, String>> typeRef = new TypeReference<HashMap<String, String>>() {}; | ||
return mapper.readValue(jsonString, typeRef); | ||
} | ||
|
||
public static String getConfigValue(String key, SparkSession sparkSession) { | ||
try { | ||
return sparkSession.conf().get(key); | ||
} catch (NoSuchElementException e) { | ||
log.warn("Property {} not found in the context", key); | ||
return null; | ||
} | ||
} | ||
} |