Commit 72daff47 authored by Tibo's avatar Tibo

Distinct

parent 1ecc87c1
Pipeline #2143 passed with stage
in 18 seconds
......@@ -83,6 +83,15 @@ class Dataset
return new Dataset($copy);
}
/**
*
* @return \Cylab\Spark\Dataset
*/
public function distinct()
{
return new Dataset(array_unique($this->data));
}
/**
*
* @return \Cylab\Spark\Dataset
......
......@@ -55,4 +55,10 @@ class DatasetTest extends TestCase
$data = new Dataset([1, 2, 3, 4]);
$this->assertEquals(4, count($data->collect()));
}
public function testDistinct()
{
$data = new Dataset([1, 2, 1, 3, 4, 4]);
$this->assertEquals(4, count($data->distinct()->collect()));
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment