Class: StructuredDataToSql::Json::SchemaInferrer

Inherits:
Object
  • Object
show all
Defined in:
lib/structured_data_to_sql/json/schema_inferrer.rb

Overview

Collects TableProfiles for every table produced by shredding a file.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(raw_dates: false) ⇒ SchemaInferrer

Returns a new instance of SchemaInferrer.



134
135
136
137
# File 'lib/structured_data_to_sql/json/schema_inferrer.rb', line 134

def initialize(raw_dates: false)
  @raw_dates = raw_dates
  @profiles = {}
end

Instance Attribute Details

#profilesObject (readonly)

Returns the value of attribute profiles.



132
133
134
# File 'lib/structured_data_to_sql/json/schema_inferrer.rb', line 132

def profiles
  @profiles
end

Instance Method Details

#observe(row) ⇒ Object



139
140
141
142
143
144
145
146
147
# File 'lib/structured_data_to_sql/json/schema_inferrer.rb', line 139

def observe(row)
  (
    @profiles[row.table_rel] ||= TableProfile.new(
      row.table_rel,
      raw_dates: @raw_dates
    )
  ).observe_row(row.columns)
  row.children.each { |child| observe(child) }
end