Sha256: 1afa15fcd2c4c36debebd128720ea88fb63f01f226c722ee7eb636795ecef4ea

Contents?: true

Size: 1.09 KB

Versions: 8

Compression:

Stored size: 1.09 KB

Contents

require 'helper'
require 'time'
require 'embulk/guess/schema_guess'

class SchemaGuessTest < ::Test::Unit::TestCase
  G = Embulk::Guess::SchemaGuess
  C = Embulk::Column

  def test_guess
    G.from_hash_records([{"int" => "1", "str" => "a"}])
  end

  def test_coalesce
    assert_equal(
      [C.new(0, "a", :timestamp, "%Y%m%d")],
      G.from_hash_records([
        {"a" => "20160101"},
        {"a" => "20160101"},
      ]))

    assert_equal(
      [C.new(0, "a", :long)],
      G.from_hash_records([
        {"a" => "20160101"},
        {"a" => "20160101"},
        {"a" => "12345678"},
      ]))
  end

  def test_boolean
    %w[
      true false t f
      yes no y n
      on off
    ].each do |str|
      # If at least one of three kinds of boolean strings (i.e., downcase, upcase, capitalize) is
      # mistakenly detected as "string," the guesser concludes the column type is "string."
      assert_equal(
        [C.new(0, "a", :boolean)],
        G.from_hash_records([
          {"a" => str.downcase},
          {"a" => str.upcase},
          {"a" => str.capitalize},
        ]))
    end
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
embulk-0.8.39 test/vanilla/guess/test_schema_guess.rb
embulk-0.8.39-java test/vanilla/guess/test_schema_guess.rb
embulk-0.8.38 test/vanilla/guess/test_schema_guess.rb
embulk-0.8.38-java test/vanilla/guess/test_schema_guess.rb
embulk-0.8.37 test/vanilla/guess/test_schema_guess.rb
embulk-0.8.37-java test/vanilla/guess/test_schema_guess.rb
embulk-0.8.36 test/guess/test_schema_guess.rb
embulk-0.8.36-java test/guess/test_schema_guess.rb