Sha256: 20d546e56a2090d1da9201d38edd43e1f88218800a33ea10958392ee64c3d92c

Contents?: true

Size: 1.41 KB

Versions: 2

Compression:

Stored size: 1.41 KB

Contents

# encoding: utf-8

require 'spec_helper'

describe Optimizer::Algebra::Rename::ProjectionOperand, '#optimizable?' do
  subject { object.optimizable? }

  let(:header) { Relation::Header.coerce([[:one, Integer], [:two, Integer], [:three, Integer]]) }
  let(:base)   { Relation.new(header, LazyEnumerable.new([[1, 2]]))                             }
  let(:object) { described_class.new(relation)                                                  }

  before do
    expect(object.operation).to be_kind_of(Algebra::Rename)
  end

  context 'when the operand is a projection and the aliases do not conflict with a removed column' do
    let(:operand)  { base.project([:one, :two])             }
    let(:relation) { operand.rename(one: :other, two: :one) }

    it { should be(true) }
  end

  context 'when the operand is a projection and the alias does not conflict with a removed column' do
    let(:operand)  { base.project([:one])        }
    let(:relation) { operand.rename(one: :other) }

    it { should be(true) }
  end

  context 'when the operand is a projection and the alias conflicts with a removed column' do
    let(:operand)  { base.project([:one])      }
    let(:relation) { operand.rename(one: :two) }

    it { should be(false) }
  end

  context 'when the operand is not a projection' do
    let(:operand)  { base                        }
    let(:relation) { operand.rename(one: :other) }

    it { should be(false) }
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
axiom-optimizer-0.2.0 spec/unit/axiom/optimizer/algebra/rename/projection_operand/optimizable_predicate_spec.rb
axiom-optimizer-0.1.1 spec/unit/axiom/optimizer/algebra/rename/projection_operand/optimizable_predicate_spec.rb