class Multiwoven::Integrations::Source::Snowflake::Client

def discover(connection_config)

def discover(connection_config)
  connection_config = connection_config.with_indifferent_access
  query = "SELECT table_name, column_name, data_type, is_nullable
          FROM information_schema.columns
          WHERE table_schema = \'#{connection_config[:schema]}\' AND table_catalog = \'#{connection_config[:database]}\'
          ORDER BY table_name, ordinal_position;"
  db = create_connection(connection_config)
  records = []
  db.fetch(query.gsub("\n", "")) do |row|
    records << row
  end
  catalog = Catalog.new(streams: create_streams(records))
  catalog.to_multiwoven_message
rescue StandardError => e
  handle_exception(e, {
                     context: "SNOWFLAKE:DISCOVER:EXCEPTION",
                     type: "error"
                   })
end