Module: ActiveRecord::ConnectionAdapters::Trino::SchemaStatements

Included in:
ActiveRecord::ConnectionAdapters::TrinoAdapter
Defined in:
lib/active_record/connection_adapters/trino/schema_statements.rb

Instance Method Summary collapse

Instance Method Details

#columns(table_name) ⇒ Object



7
8
9
10
11
12
13
14
15
16
17
# File 'lib/active_record/connection_adapters/trino/schema_statements.rb', line 7

def columns(table_name)
  rows = run_trino_query(columns_query(table_name.to_s)).rows
  rows.map do |name, data_type, is_nullable|
    Trino::Column.new(
      name: name,
      sql_type: data_type,
      type: type_map.lookup(data_type),
      null: nullable?(is_nullable)
    )
  end
end

#data_sourcesObject Also known as: tables



19
20
21
# File 'lib/active_record/connection_adapters/trino/schema_statements.rb', line 19

def data_sources
  run_trino_query("SHOW TABLES").rows.map(&:first)
end

#foreign_keys(_table_name) ⇒ Object



37
38
39
# File 'lib/active_record/connection_adapters/trino/schema_statements.rb', line 37

def foreign_keys(_table_name)
  []
end

#indexes(_table_name) ⇒ Object



33
34
35
# File 'lib/active_record/connection_adapters/trino/schema_statements.rb', line 33

def indexes(_table_name)
  []
end

#primary_key(_table_name) ⇒ Object



29
30
31
# File 'lib/active_record/connection_adapters/trino/schema_statements.rb', line 29

def primary_key(_table_name)
  nil
end

#schema_cacheObject



49
50
51
# File 'lib/active_record/connection_adapters/trino/schema_statements.rb', line 49

def schema_cache
  @schema_cache ||= ActiveRecord::ConnectionAdapters::SchemaCache.new(self)
end

#table_exists?(table_name) ⇒ Boolean Also known as: data_source_exists?

Returns:

  • (Boolean)


24
25
26
# File 'lib/active_record/connection_adapters/trino/schema_statements.rb', line 24

def table_exists?(table_name)
  data_sources.include?(table_name.to_s)
end

#view_exists?(_view_name) ⇒ Boolean

Returns:

  • (Boolean)


45
46
47
# File 'lib/active_record/connection_adapters/trino/schema_statements.rb', line 45

def view_exists?(_view_name)
  false
end

#viewsObject



41
42
43
# File 'lib/active_record/connection_adapters/trino/schema_statements.rb', line 41

def views
  []
end