Skip to content

Commit

Permalink
working
Browse files Browse the repository at this point in the history
  • Loading branch information
claytongentry committed May 7, 2024
1 parent 6af5a26 commit 5f70388
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions lib/manifolds/services/big_query_service.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ def generate_dimensions_schema(project_name)
return unless validate_config_exists(config_path, project_name)

config = YAML.load_file(config_path)
dimensions = extract_fields(config["dimensions"])
dimensions = extract_dimensions(config["dimensions"])
create_dimensions_file(project_name, dimensions)
end

Expand All @@ -30,11 +30,17 @@ def validate_config_exists(config_path, project_name)
true
end

def extract_dimensions(dimensions_hash)
dimensions_hash.map do |dimension|
extract_fields(dimension)
end
end

def extract_fields(fields_hash, mode = "NULLABLE")
fields_hash.map do |name, type|
if type.is_a?(Hash)
{ "type" => "RECORD", "name" => name, "fields" => extract_fields(type) }
else
elsif type
{ "type" => type.upcase, "name" => name, "mode" => mode }
end
end
Expand Down

0 comments on commit 5f70388

Please sign in to comment.