class Multiwoven::Integrations::Source::WatsonxData::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"
  response = execute_query(connection_config, query)
  records = JSON.parse(response.body)["response"]["result"]
  catalog = Catalog.new(streams: create_streams(records))
  catalog.to_multiwoven_message
rescue StandardError => e
  handle_exception(e, { context: "WATSONX DATA:DISCOVER:EXCEPTION", type: "error" })
end