5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
|
# File 'lib/active_record/connection_adapters/pinot_adapter/table_structure.rb', line 5
def self.from_schema(schema)
fields = []
schema["dimensionFieldSpecs"].each do |f|
fields << {
"name" => f["name"],
"type" => f["dataType"],
"pinot_type" => "dimension"
}
end
schema["metricFieldSpecs"] ||= []
schema["metricFieldSpecs"].each do |f|
fields << {
"name" => f["name"],
"type" => f["dataType"],
"pinot_type" => "metric"
}
end
schema["dateTimeFieldSpecs"].each do |f|
fields << {
"name" => f.delete("name"),
"type" => f.delete("dataType"),
"pinot_type" => "dateTime",
"metadata" => f
}
end
fields.each do |f|
f["type"] = normalize_type(f["type"])
end
primary_key_columns = schema["primaryKeyColumns"] || []
primary_key_columns.each do |pk|
pk_fields = fields.select { |x| x["name"] == pk }
pk_fields.each { |field| field["pk"] = 1 }
end
fields
end
|