@Override public DDF sql2ddf(String command, Schema schema, DataFormat dataFormat) throws DDFException { return this.sql2ddf(command, schema, null, dataFormat); }
@Override public DDF sql2ddf(String command, DataFormat dataFormat) throws DDFException { return this.sql2ddf(command, null, null, dataFormat); }
@Override public DDF sql2ddf(String command, Schema schema, DataSourceDescriptor dataSource) throws DDFException { return this.sql2ddf(command, schema, dataSource, null); }
@Override public DDF sql2ddf(String command, Schema schema) throws DDFException { return this.sql2ddf(command, schema, null, null); }
@Override public DDF sql2ddf(String command) throws DDFException { return this.sql2ddf(command, null, null, null); }
public DDF sql2ddf(String command, Boolean queyOnDDF) throws DDFException { return this.sql2ddf(command, new SQLDataSourceDescriptor(null, queyOnDDF, null, null, null)); }
public DDF sql2ddf(String sqlCommand) throws DDFException { try { // sqlCommand = sqlCommand.replace("@this", this.getTableName()); sqlCommand = sqlCommand.replace("@this", "{1}"); sqlCommand = String.format(sqlCommand, "{1}"); SQLDataSourceDescriptor sqlDS = new SQLDataSourceDescriptor(sqlCommand, null, null,null, this.getUUID().toString()); return this.getManager().sql2ddf(sqlCommand, null, sqlDS); // return this.getManager().sql2ddf(sqlCommand); } catch (Exception e) { throw new DDFException(String.format("Error executing queries for ddf %s", this.getTableName()), e); } }
@Before public void setUp() throws Exception { createTableAirline(); ddf = manager .sql2ddf("select year, month, dayofweek, deptime, arrtime," + "origin, distance, arrdelay, depdelay, carrierdelay," + " weatherdelay, nasdelay, securitydelay, " + "lateaircraftdelay from airline", false); ddf1 = manager.sql2ddf("select year, month, dayofweek, deptime, arrdelay from airline", false); }
private DDF sql2ddf(String sqlCommand, String errorMessage) throws DDFException { try { return this.getManager().sql2ddf(String.format(sqlCommand, "{1}"), new SQLDataSourceDescriptor(sqlCommand, null, null, null, this .getDDF().getUUID().toString())); } catch (Exception e) { throw new DDFException(String.format(errorMessage, this.getDDF().getTableName()), e); } }
@Test public void testVectorMean() throws DDFException { DDF ddf2 = manager.sql2ddf("select * from airline", false); Double a = ddf2.getVectorMean("year"); assert (a != null); System.out.println(">>>>> testVectorMean = " + a); }
@Before public void setUp() throws Exception { createTableAirlineWithNA(); ddf = manager.sql2ddf("select * from airline", false); }
@Before public void setUp() throws Exception { createTableAirlineWithNA(); ddf = manager.sql2ddf("select * from airline", false); }
@Before public void setUp() throws Exception { createTableAirline(); ddf = manager.sql2ddf("select year, month, dayofweek, deptime, arrtime, " + "distance, arrdelay, depdelay from airline", false); }
@Test public void testVectorVariance() throws DDFException { DDF ddf2 = manager.sql2ddf("select * from airline", false); Double[] a = ddf2.getVectorVariance("year"); assert (a != null); assert (a.length == 2); }
@Before public void setUp() throws Exception { createTableAirline(); ddf = manager .sql2ddf("select year, month, dayofweek, deptime, arrtime,origin, " + "distance, arrdelay, depdelay, carrierdelay, weatherdelay, " + "nasdelay, securitydelay, lateaircraftdelay from airline", false); }
@Test public void testSampling() throws DDFException { DDF ddf2 = manager.sql2ddf("select * from airline", false); Assert.assertEquals(25, ddf2.VIEWS.getRandomSample(25).size()); SparkDDF sampleDDF = (SparkDDF) ddf2.VIEWS.getRandomSample(0.5, false, 1); Assert.assertEquals(25, ddf2.VIEWS.getRandomSample(25).size()); Assert.assertTrue(sampleDDF.getRDD(Object[].class).count() > 10); }
@Test public void TestKMeans() throws DDFException { createTableAirline(); DDF ddf = manager.sql2ddf("select deptime, arrtime, distance, depdelay, arrdelay from airline", false); KMeansModel kmeansModel = (KMeansModel) ddf.ML.KMeans(5, 5, 2, "random").getRawModel(); Assert.assertEquals(5, kmeansModel.clusterCenters().length); // Assert.assertTrue(kmeansModel.computeCost((RDD<double[]>)ddf.getRepresentationHandler().get( // RDD_ARR_DOUBLE().getTypeSpecsString())) > 0); // Assert.assertTrue(kmeansModel.predict(Vectors.dense(new double[] { 1232, 1341, 389, 7, 1 })) > -1); // Assert.assertTrue(kmeansModel.predict(new double[] { 1232, 1341, 389, 7, 1 }) < 5); }
@Test public void testSummary() throws DDFException { Assert.assertEquals(14, ddf.getSummary().length); Assert.assertEquals(31, ddf.getNumRows()); createTableSmiths2(); DDF ddf3 = manager.sql2ddf("select * from smiths2", false); Summary[] summary = ddf3.getSummary(); Assert.assertEquals(summary[2].NACount(), 4); }
@Test public void testSummaryBigInt() throws DDFException { DDF ddf4 = manager.sql2ddf("select floor(deptime/100) as dephour, cast(arrdelay as " + "bigint) as arrdelay1 from airline", false); Summary[] summary = ddf4.getSummary(); Assert.assertTrue(summary[0].min() != Double.NaN); Assert.assertTrue(summary[0].count() > 0); Assert.assertTrue(summary[1].min() != Double.NaN); Assert.assertTrue(summary[1].count() > 0); }