Sha256: b5e4bd576f015d4fd8b6d5ef42e4f559c5f12a80da3ee15037f249b3b2d39d32

Contents?: true

Size: 1.62 KB

Versions: 12

Compression:

Stored size: 1.62 KB

Contents

grammar SQLKeyValuePair
  include SQLPrimitives
  include SQLRowSupport

  rule key_value_pair
    one_column_name optional_spaces joiner_or_null  {
      def eval
        results = joiner_or_null.eval
        klass = Expressions.find_class_for(results[:joiner])
        if value = results[:value]
          klass.new(one_column_name.eval.to_sym, results[:value])
        else
          klass.new(one_column_name.eval.to_sym)
        end
      end
    }
  end

  rule joiner_or_null
    a_null / joiner_with_value
  end

  rule a_null
    is_not_null / is_null
  end

  rule is_not_null
    "IS" SPACE "NOT" SPACE "NULL" {
      def eval
        { :joiner => :"IS NOT NULL" }
      end
    }
  end

  rule is_null
    "IS" SPACE "NULL" {
      def eval
        { :joiner => :"IS NULL" }
      end
     }
  end

  rule joiner_with_value
    condition_joiner optional_spaces primitive {
      def eval
        { 
          :joiner => condition_joiner.eval,
          :value => primitive.eval
        }
      end
    }
  end

  rule condition_joiner
    greater_than_or_equal / 
    less_than_or_equal / 
    equals / 
    not_equals / 
    less_than / 
    greater_than /
    like
  end

  rule less_than_or_equal
    "<="  {   def eval;   :<=;   end }
  end

  rule greater_than_or_equal
    ">="  {   def eval;   :>=    end }
  end

  rule less_than
    "<"   {   def eval;   :<     end }
  end

  rule greater_than
    ">"   {   def eval;   :>     end }
  end

  rule not_equals
    "!="  {  def eval;   :"!="   end }
  end

  rule equals
    "="   {   def eval;  :"="    end }
  end
  
  rule like
    "LIKE"   {   def eval;  :"LIKE"    end }
  end
end

Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
hipster_sql_to_hbase-0.3.1 lib/sql_parser/sql_key_value_pair.treetop
hipster_sql_to_hbase-0.3.0 lib/sql_parser/sql_key_value_pair.treetop
hipster_sql_to_hbase-0.2.2 lib/sql_parser/sql_key_value_pair.treetop
hipster_sql_to_hbase-0.2.0 lib/sql_parser/sql_key_value_pair.treetop
hipster_sql_to_hbase-0.1.85 lib/sql_parser/sql_key_value_pair.treetop
hipster_sql_to_hbase-0.1.8 lib/sql_parser/sql_key_value_pair.treetop
hipster_sql_to_hbase-0.1.7 lib/sql_parser/sql_key_value_pair.treetop
hipster_sql_to_hbase-0.1.6 lib/sql_parser/sql_key_value_pair.treetop
hipster_sql_to_hbase-0.1.5 lib/sql_parser/sql_key_value_pair.treetop
hipster_sql_to_hbase-0.1.4 lib/sql_parser/sql_key_value_pair.treetop
hipster_sql_to_hbase-0.1.3 lib/sql_parser/sql_key_value_pair.treetop
hipster_sql_to_hbase-0.1.2 lib/sql_parser/sql_key_value_pair.treetop