Class: YbDDLParser::AST::Statement

Inherits:
Data
  • Object
show all
Defined in:
lib/yb_ddl_parser/ast.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#access_methodObject (readonly)

Returns the value of attribute access_method

Returns:

  • (Object)

    the current value of access_method



29
30
31
# File 'lib/yb_ddl_parser/ast.rb', line 29

def access_method
  @access_method
end

#columnsObject (readonly)

Returns the value of attribute columns

Returns:

  • (Object)

    the current value of columns



29
30
31
# File 'lib/yb_ddl_parser/ast.rb', line 29

def columns
  @columns
end

#commandsObject (readonly)

Returns the value of attribute commands

Returns:

  • (Object)

    the current value of commands



29
30
31
# File 'lib/yb_ddl_parser/ast.rb', line 29

def commands
  @commands
end

#concurrentlyObject (readonly)

Returns the value of attribute concurrently

Returns:

  • (Object)

    the current value of concurrently



29
30
31
# File 'lib/yb_ddl_parser/ast.rb', line 29

def concurrently
  @concurrently
end

#constraintsObject (readonly)

Returns the value of attribute constraints

Returns:

  • (Object)

    the current value of constraints



29
30
31
# File 'lib/yb_ddl_parser/ast.rb', line 29

def constraints
  @constraints
end

#if_existsObject (readonly)

Returns the value of attribute if_exists

Returns:

  • (Object)

    the current value of if_exists



29
30
31
# File 'lib/yb_ddl_parser/ast.rb', line 29

def if_exists
  @if_exists
end

#if_not_existsObject (readonly)

Returns the value of attribute if_not_exists

Returns:

  • (Object)

    the current value of if_not_exists



29
30
31
# File 'lib/yb_ddl_parser/ast.rb', line 29

def if_not_exists
  @if_not_exists
end

#include_columnsObject (readonly)

Returns the value of attribute include_columns

Returns:

  • (Object)

    the current value of include_columns



29
30
31
# File 'lib/yb_ddl_parser/ast.rb', line 29

def include_columns
  @include_columns
end

#index_nameObject (readonly)

Returns the value of attribute index_name

Returns:

  • (Object)

    the current value of index_name



29
30
31
# File 'lib/yb_ddl_parser/ast.rb', line 29

def index_name
  @index_name
end

#keysObject (readonly)

Returns the value of attribute keys

Returns:

  • (Object)

    the current value of keys



29
30
31
# File 'lib/yb_ddl_parser/ast.rb', line 29

def keys
  @keys
end

#kindObject (readonly)

Returns the value of attribute kind

Returns:

  • (Object)

    the current value of kind



29
30
31
# File 'lib/yb_ddl_parser/ast.rb', line 29

def kind
  @kind
end

#locationObject (readonly)

Returns the value of attribute location

Returns:

  • (Object)

    the current value of location



29
30
31
# File 'lib/yb_ddl_parser/ast.rb', line 29

def location
  @location
end

#nameObject (readonly)

Returns the value of attribute name

Returns:

  • (Object)

    the current value of name



29
30
31
# File 'lib/yb_ddl_parser/ast.rb', line 29

def name
  @name
end

#new_nameObject (readonly)

Returns the value of attribute new_name

Returns:

  • (Object)

    the current value of new_name



29
30
31
# File 'lib/yb_ddl_parser/ast.rb', line 29

def new_name
  @new_name
end

#object_typeObject (readonly)

Returns the value of attribute object_type

Returns:

  • (Object)

    the current value of object_type



29
30
31
# File 'lib/yb_ddl_parser/ast.rb', line 29

def object_type
  @object_type
end

#objectsObject (readonly)

Returns the value of attribute objects

Returns:

  • (Object)

    the current value of objects



29
30
31
# File 'lib/yb_ddl_parser/ast.rb', line 29

def objects
  @objects
end

#ownerObject (readonly)

Returns the value of attribute owner

Returns:

  • (Object)

    the current value of owner



29
30
31
# File 'lib/yb_ddl_parser/ast.rb', line 29

def owner
  @owner
end

#partition_bound_sqlObject (readonly)

Returns the value of attribute partition_bound_sql

Returns:

  • (Object)

    the current value of partition_bound_sql



29
30
31
# File 'lib/yb_ddl_parser/ast.rb', line 29

def partition_bound_sql
  @partition_bound_sql
end

#partition_ofObject (readonly)

Returns the value of attribute partition_of

Returns:

  • (Object)

    the current value of partition_of



29
30
31
# File 'lib/yb_ddl_parser/ast.rb', line 29

def partition_of
  @partition_of
end

#partition_specObject (readonly)

Returns the value of attribute partition_spec

Returns:

  • (Object)

    the current value of partition_spec



29
30
31
# File 'lib/yb_ddl_parser/ast.rb', line 29

def partition_spec
  @partition_spec
end

#primary_keyObject (readonly)

Returns the value of attribute primary_key

Returns:

  • (Object)

    the current value of primary_key



29
30
31
# File 'lib/yb_ddl_parser/ast.rb', line 29

def primary_key
  @primary_key
end

#raw_node_typeObject (readonly)

Returns the value of attribute raw_node_type

Returns:

  • (Object)

    the current value of raw_node_type



29
30
31
# File 'lib/yb_ddl_parser/ast.rb', line 29

def raw_node_type
  @raw_node_type
end

#relationObject (readonly)

Returns the value of attribute relation

Returns:

  • (Object)

    the current value of relation



29
30
31
# File 'lib/yb_ddl_parser/ast.rb', line 29

def relation
  @relation
end

#replica_placement_jsonObject (readonly)

Returns the value of attribute replica_placement_json

Returns:

  • (Object)

    the current value of replica_placement_json



29
30
31
# File 'lib/yb_ddl_parser/ast.rb', line 29

def replica_placement_json
  @replica_placement_json
end

#sqlObject (readonly)

Returns the value of attribute sql

Returns:

  • (Object)

    the current value of sql



29
30
31
# File 'lib/yb_ddl_parser/ast.rb', line 29

def sql
  @sql
end

#tablespaceObject (readonly)

Returns the value of attribute tablespace

Returns:

  • (Object)

    the current value of tablespace



29
30
31
# File 'lib/yb_ddl_parser/ast.rb', line 29

def tablespace
  @tablespace
end

#tablespace_locationObject (readonly)

Returns the value of attribute tablespace_location

Returns:

  • (Object)

    the current value of tablespace_location



29
30
31
# File 'lib/yb_ddl_parser/ast.rb', line 29

def tablespace_location
  @tablespace_location
end

#tablet_splitObject (readonly)

Returns the value of attribute tablet_split

Returns:

  • (Object)

    the current value of tablet_split



29
30
31
# File 'lib/yb_ddl_parser/ast.rb', line 29

def tablet_split
  @tablet_split
end

#uniqueObject (readonly)

Returns the value of attribute unique

Returns:

  • (Object)

    the current value of unique



29
30
31
# File 'lib/yb_ddl_parser/ast.rb', line 29

def unique
  @unique
end

#where_sqlObject (readonly)

Returns the value of attribute where_sql

Returns:

  • (Object)

    the current value of where_sql



29
30
31
# File 'lib/yb_ddl_parser/ast.rb', line 29

def where_sql
  @where_sql
end

Instance Method Details

#alter_index?Boolean

Returns:

  • (Boolean)


77
78
79
# File 'lib/yb_ddl_parser/ast.rb', line 77

def alter_index?
  kind == :alter_index
end

#create_index?Boolean

Returns:

  • (Boolean)


65
66
67
# File 'lib/yb_ddl_parser/ast.rb', line 65

def create_index?
  kind == :create_index
end

#create_table?Boolean

Returns:

  • (Boolean)


61
62
63
# File 'lib/yb_ddl_parser/ast.rb', line 61

def create_table?
  kind == :create_table
end

#drop_index?Boolean

Returns:

  • (Boolean)


73
74
75
# File 'lib/yb_ddl_parser/ast.rb', line 73

def drop_index?
  kind == :drop && object_type == :index
end

#drop_table?Boolean

Returns:

  • (Boolean)


69
70
71
# File 'lib/yb_ddl_parser/ast.rb', line 69

def drop_table?
  kind == :drop && object_type == :table
end

#explicit_concurrently?Boolean

Returns:

  • (Boolean)


89
90
91
# File 'lib/yb_ddl_parser/ast.rb', line 89

def explicit_concurrently?
  concurrently == :explicit
end

#hash_key_groupsObject



108
109
110
111
112
113
114
115
116
117
# File 'lib/yb_ddl_parser/ast.rb', line 108

def hash_key_groups
  groups = keys.each_with_object({}) do |key, grouped|
    next if key.hash_group.nil?

    grouped[key.hash_group] ||= []
    grouped[key.hash_group] << (key.name || key.expression)
  end

  groups.keys.sort.map { |group| groups.fetch(group) }
end

#partitionObject



123
124
125
# File 'lib/yb_ddl_parser/ast.rb', line 123

def partition
  partition_spec
end

#partition_child?Boolean

Returns:

  • (Boolean)


85
86
87
# File 'lib/yb_ddl_parser/ast.rb', line 85

def partition_child?
  !partition_of.nil?
end

#partition_parent?Boolean

Returns:

  • (Boolean)


81
82
83
# File 'lib/yb_ddl_parser/ast.rb', line 81

def partition_parent?
  create_table? && !partition_spec.nil? && !partition_child?
end

#splitObject



119
120
121
# File 'lib/yb_ddl_parser/ast.rb', line 119

def split
  tablet_split
end

#target_nameObject



104
105
106
# File 'lib/yb_ddl_parser/ast.rb', line 104

def target_name
  index_name || target_relation&.qualified_name || name
end

#target_relationObject



100
101
102
# File 'lib/yb_ddl_parser/ast.rb', line 100

def target_relation
  target_relations.first
end

#target_relationsObject



93
94
95
96
97
98
# File 'lib/yb_ddl_parser/ast.rb', line 93

def target_relations
  return objects unless objects.empty?
  return [relation] if relation

  []
end