Search in sources :

Example 6 with ProfilerConfiguration

use of com.thinkbiganalytics.spark.dataprofiler.ProfilerConfiguration in project kylo by Teradata.

the class TimestampColumnCase2Test method accomodate.

/**
 * Verify accommodating column values.
 */
@Test
public void accomodate() {
    final ProfilerConfiguration profilerConfiguration = new ProfilerConfiguration();
    // Test with a null value
    TimestampColumnStatistics stats = new TimestampColumnStatistics(DataTypes.createStructField("ts", DataTypes.TimestampType, true), profilerConfiguration);
    stats.accomodate(null, 1L);
    Assert.assertNull(stats.getMaxTimestamp());
    Assert.assertNull(stats.getMinTimestamp());
    // Test with uninitialized max & min
    stats.accomodate("2016-06-27 14:04:30", 1L);
    Timestamp ts1 = new Timestamp(new DateTime(2016, 6, 27, 14, 4, 30).getMillis());
    Assert.assertEquals(ts1, stats.getMaxTimestamp());
    Assert.assertEquals(ts1, stats.getMinTimestamp());
    // Test with a later timestamp
    stats.accomodate("2016-06-27 14:04:31", 1L);
    Timestamp ts2 = new Timestamp(new DateTime(2016, 6, 27, 14, 4, 31).getMillis());
    Assert.assertEquals(ts2, stats.getMaxTimestamp());
    Assert.assertEquals(ts1, stats.getMinTimestamp());
    // Test with an earlier timestamp
    stats.accomodate("2016-06-27 14:04:29", 1L);
    Timestamp ts3 = new Timestamp(new DateTime(2016, 6, 27, 14, 4, 29).getMillis());
    Assert.assertEquals(ts2, stats.getMaxTimestamp());
    Assert.assertEquals(ts3, stats.getMinTimestamp());
}
Also used : ProfilerConfiguration(com.thinkbiganalytics.spark.dataprofiler.ProfilerConfiguration) Timestamp(java.sql.Timestamp) DateTime(org.joda.time.DateTime) TimestampColumnStatistics(com.thinkbiganalytics.spark.dataprofiler.columns.TimestampColumnStatistics) Test(org.junit.Test) ProfilerTest(com.thinkbiganalytics.spark.dataprofiler.core.ProfilerTest)

Aggregations

ProfilerConfiguration (com.thinkbiganalytics.spark.dataprofiler.ProfilerConfiguration)6 TimestampColumnStatistics (com.thinkbiganalytics.spark.dataprofiler.columns.TimestampColumnStatistics)4 ProfilerTest (com.thinkbiganalytics.spark.dataprofiler.core.ProfilerTest)4 Test (org.junit.Test)4 StatisticsModel (com.thinkbiganalytics.spark.dataprofiler.StatisticsModel)2 OutputRow (com.thinkbiganalytics.spark.dataprofiler.output.OutputRow)2 Timestamp (java.sql.Timestamp)2 DateTime (org.joda.time.DateTime)2 DataSet (com.thinkbiganalytics.spark.DataSet)1 ColumnStatistics (com.thinkbiganalytics.spark.dataprofiler.ColumnStatistics)1 BigDecimal (java.math.BigDecimal)1 ArrayList (java.util.ArrayList)1 Map (java.util.Map)1 Nonnull (javax.annotation.Nonnull)1 JavaSparkContext (org.apache.spark.api.java.JavaSparkContext)1 Row (org.apache.spark.sql.Row)1 StructField (org.apache.spark.sql.types.StructField)1 StructType (org.apache.spark.sql.types.StructType)1 Before (org.junit.Before)1