Exemplo n.º 1
0
// Select Applies a Select transform.
func (t *Transformer) Select(filter func(optimus.Row) (bool, error)) *Transformer {
	return t.Apply(transforms.Select(filter))
}
Exemplo n.º 2
0
			out <- optimus.Row{}
			out <- optimus.Row{}
			out <- optimus.Row{}
			return nil
		},
	},
	{
		Name:   "Select",
		Source: defaultSource,
		Actual: func(source optimus.Table, arg interface{}) optimus.Table {
			filter := arg.(func(optimus.Row) (bool, error))
			return New(source).Select(filter).Table()
		},
		Expected: func(source optimus.Table, arg interface{}) optimus.Table {
			filter := arg.(func(optimus.Row) (bool, error))
			return optimus.Transform(source, transforms.Select(filter))
		},
		Arg: func(row optimus.Row) (bool, error) {
			return row["header1"] == "value1", nil
		},
	},
	{
		Name:   "Valuemap",
		Source: defaultSource,
		Actual: func(source optimus.Table, arg interface{}) optimus.Table {
			mapping := arg.(map[string]map[interface{}]interface{})
			return New(source).Valuemap(mapping).Table()
		},
		Expected: func(source optimus.Table, arg interface{}) optimus.Table {
			mapping := arg.(map[string]map[interface{}]interface{})
			return optimus.Transform(source, transforms.Valuemap(mapping))