Sha256: eba1a1b8aff3264f901ac946c4aa802fba141952dad31f5821d97053da044069

Contents?: true

Size: 1.69 KB

Versions: 3

Compression:

Stored size: 1.69 KB

Contents

# encoding: utf-8

require 'spec_helper'

describe Optimizer::Algebra::Join::LeftMaterializedOperand, '#optimizable?' do
  subject { object.optimizable? }

  let(:relation) { left.join(right)              }
  let(:object)   { described_class.new(relation) }

  before do
    object.operation.should be_kind_of(Algebra::Join)
  end

  context 'when the left is materialized and right is not a restriction' do
    let(:left)  { Relation.new([ [ :id, Integer ], [ :name, String  ] ], [ [ 1, 'Dan Kubb' ] ])      }
    let(:right) { Relation.new([ [ :id, Integer ], [ :age,  Integer ] ], [ [ 1, 35         ] ].each) }

    it { should be(true) }
  end

  context 'when the left is materialized and right is a restriction not matching the left' do
    let(:left)  { Relation.new([ [ :id, Integer ], [ :name, String  ] ], [ [ 1, 'Dan Kubb' ] ])                                    }
    let(:right) { Relation.new([ [ :id, Integer ], [ :age,  Integer ] ], [ [ 1, 35         ] ].each).restrict { |r| r.age.eq(35) } }

    it { should be(true) }
  end

  context 'when the left is materialized and right is a restriction matching the left' do
    let(:left)  { Relation.new([ [ :id, Integer ], [ :name, String  ] ], [ [ 1, 'Dan Kubb' ] ])                                  }
    let(:right) { Relation.new([ [ :id, Integer ], [ :age,  Integer ] ], [ [ 1, 35         ] ].each).restrict { |r| r.id.eq(1) } }

    it { should be(false) }
  end

  context 'when the left is not materialized' do
    let(:left)  { Relation.new([ [ :id, Integer ], [ :name, String  ] ], [ [ 1, 'Dan Kubb' ] ].each) }
    let(:right) { Relation.new([ [ :id, Integer ], [ :age,  Integer ] ], [ [ 1, 35         ] ].each) }

    it { should be(false) }
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
veritas-optimizer-0.0.7 spec/unit/veritas/optimizer/algebra/join/left_materialized_operand/optimizable_spec.rb
veritas-optimizer-0.0.6 spec/unit/veritas/optimizer/algebra/join/left_materialized_operand/optimizable_spec.rb
veritas-optimizer-0.0.5 spec/unit/veritas/optimizer/algebra/join/left_materialized_operand/optimizable_spec.rb