Class: DWH::Adapters::Redshift

Inherits:
Postgres show all
Defined in:
lib/dwh/adapters/redshift.rb

Overview

Redshift adapter. Please ensure the pg gem is available before using this adapter. Generally, adapters should be created using DWH.create. Where a configuration is passed in as options hash or argument list.

Examples:

Basic connection with required only options

DWH.create(:redshift, {host: 'localhost', database: 'redshift',
  username: 'redshift'})

Connection with cert based SSL connection

DWH.create(:redshift, {host: 'localhost', database: 'redshift',
  username: 'redshift', ssl: true,
  extra_connection_params: { sslmode: 'require' })

valid sslmodes: disable, prefer, require, verify-ca, verify-full
For modes requiring Certs make sure you add the appropirate params
to extra_connection_params. (ie sslrootcert, sslcert etc.)

Connection sending custom application name

DWH.create(:redshift, {host: 'localhost', database: 'redshift',
  username: 'redshift', application_name: "Strata CLI" })

Constant Summary

Constants included from Settings

Settings::BASE_SETTINGS_FILE

Constants included from Functions::Dates

Functions::Dates::DATE_CLASSES, Functions::Dates::TIMESTAMPABLE_UNITS

Instance Attribute Summary

Attributes inherited from Adapter

#config, #settings

Attributes included from Settings

#adapter_settings

Instance Method Summary collapse

Methods inherited from Postgres

#connection, #execute, #execute_stream, #metadata, #schema?, #stats, #stream, #table?, #tables, #test_connection, #valid_config?

Methods inherited from Adapter

#adapter_name, #alter_settings, #close, config, configuration, #connect!, #connect?, #connection, #execute, #execute_stream, #extra_connection_params, #extra_query_params, #initialize, #metadata, #reset_settings, #stats, #stream, #table?, #tables, #test_connection, #token_expired?, #with_debug, #with_retry

Methods included from Settings

#adapter_name, #load_settings, #settings_file, #settings_file_path, #using_base_settings?

Methods included from Logger

#logger, logger

Methods included from Behaviors

#apply_advanced_filtering_on_array_projections?, #cross_universe_measure_filtering_strategy, #extend_ending_date_to_last_hour_of_day?, #final_measure_filter?, #final_pass_measure_join_type, #greedy_apply_date_filters, #intermediate_measure_filter?, #temp_table_prefix, #temp_table_type

Methods included from Functions

#cast, #cross_join, #gsk, #lower_case, #quote, #string_lit, #trim, #upper_case

Methods included from Functions::Arrays

#array_exclude_list, #array_in_list, #array_unnest_join

Methods included from Functions::Nulls

#if_null, #null_if, #null_if_zero

Methods included from Functions::ExtractDatePart

#extract_day_name, #extract_day_of_month, #extract_day_of_week, #extract_day_of_year, #extract_hour, #extract_minute, #extract_month, #extract_month_name, #extract_quarter, #extract_week_of_year, #extract_year, #extract_year_month

Methods included from Functions::Dates

#adjust_week_start_day, #adjust_week_start_day?, #current_date, #current_time, #current_timestamp, #date_data_type, #date_diff, #date_format, #date_format_sql, #date_int?, #date_lit, #date_literal, #date_time_format, #date_time_literal, #date_time_tz_format, #default_week_start_day, #timestamp_lit, #timestamp_literal, #truncate_date, #week_start_day, #week_starts_on_sunday?

Methods included from Capabilities

#supports_array_functions?, #supports_common_table_expressions?, #supports_cross_join?, #supports_full_join?, #supports_sub_queries?, #supports_table_join?, #supports_temp_tables?, #supports_window_functions?

Constructor Details

This class inherits a constructor from DWH::Adapters::Adapter

Instance Method Details

#date_add(unit, val, exp) ⇒ Object

Need to override default add method since redshift doesn't support quarter as an interval.

Parameters:

  • unit (String)

    Should be one of day, month, quarter etc

  • val (String, Integer)

    The number of days to add

  • exp (String)

    The sql expresssion to modify



40
41
42
43
44
45
# File 'lib/dwh/adapters/redshift.rb', line 40

def date_add(unit, val, exp)
  gsk(:date_add)
    .gsub(/@unit/i, unit)
    .gsub(/@val/i, val.to_s)
    .gsub(/@exp/i, exp)
end