Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,16 @@
import org.apache.commons.io.FilenameUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.yaml.snakeyaml.DumperOptions;
import org.yaml.snakeyaml.LoaderOptions;
import org.yaml.snakeyaml.Yaml;
import org.yaml.snakeyaml.representer.Representer;
import org.yaml.snakeyaml.constructor.Constructor;
import queryhelper.pojo.GenericResponse;
import queryhelper.service.DbtAIService;

import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Path;
Expand Down Expand Up @@ -324,8 +330,14 @@ public List<DbtModel> readDbtModels(Path directory) throws IOException {

public List<DbtModel> readDbtModels(List<String> filePaths) throws IOException {
List<DbtModel> result = new ArrayList<>();

LoaderOptions loaderOptions = new LoaderOptions();
loaderOptions.setMaxAliasesForCollections(Integer.MAX_VALUE);

Yaml yaml = new Yaml(loaderOptions);
for (String filePath : filePaths) {
result.add(yamlMapper.readValue(new File(filePath), DbtModel.class));
Object temp = yaml.load(new FileInputStream(filePath));
result.add(yamlMapper.convertValue(temp, DbtModel.class));
}
return result;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
package com.adaptivescale.rosetta.common.models.dbt;

import com.fasterxml.jackson.annotation.JsonAnyGetter;
import com.fasterxml.jackson.annotation.JsonAnySetter;
import com.fasterxml.jackson.annotation.JsonInclude;

import java.util.HashMap;
import java.util.Map;

@JsonInclude(JsonInclude.Include.NON_EMPTY)
public class AbstractDbtModel {
private Map<Object, Object> additionalProperties = new HashMap<>();

@JsonAnyGetter
public Map<Object, Object> getAdditionalProperties() {
return additionalProperties;
}

@JsonAnySetter
public void setAdditionalProperties(Map<Object, Object> additionalProperties) {
this.additionalProperties = additionalProperties;
}

public void addProperty(Object name, Object value) {
this.additionalProperties.put(name, value);
}

public Object getProperty(Object name) {
if (additionalProperties.containsKey(name))
return this.additionalProperties.get(name);
return null;
}

public String getPropertyAsString(Object name) {
return (String) getProperty(name);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

@JsonInclude(JsonInclude.Include.NON_NULL)
@JsonIgnoreProperties(ignoreUnknown = true)
public class DbtColumn {
public class DbtColumn extends AbstractDbtModel{
private String name;
private String description;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

@JsonInclude(JsonInclude.Include.NON_NULL)
@JsonIgnoreProperties(ignoreUnknown = true)
public class DbtModel {
public class DbtModel extends AbstractDbtModel{
private Integer version;
private Collection<DbtSource> sources; //sources -> tables
private Collection<DbtTable> models; //models (direct list)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

@JsonInclude(JsonInclude.Include.NON_NULL)
@JsonIgnoreProperties(ignoreUnknown = true)
public class DbtSource {
public class DbtSource extends AbstractDbtModel{
private String name;
private String description;
private Collection<DbtTable> tables;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

@JsonInclude(JsonInclude.Include.NON_NULL)
@JsonIgnoreProperties(ignoreUnknown = true)
public class DbtTable {
public class DbtTable extends AbstractDbtModel{
private String name;
private String description;
private Collection<DbtColumn> columns;
Expand Down
Loading