private static LocalQueryRunner createLocalQueryRunner() { Session defaultSession = testSessionBuilder() .setCatalog("tpch") .setSchema(TINY_SCHEMA_NAME) .build(); LocalQueryRunner localQueryRunner = new LocalQueryRunner(defaultSession); InMemoryNodeManager nodeManager = localQueryRunner.getNodeManager(); localQueryRunner.createCatalog("tpch", new TpchConnectorFactory(nodeManager, 1), ImmutableMap.<String, String>of()); HyperLogLogPlugin plugin = new HyperLogLogPlugin(); for (Type type : plugin.getTypes()) { localQueryRunner.getTypeManager().addType(type); } for (ParametricType parametricType : plugin.getParametricTypes()) { localQueryRunner.getTypeManager().addParametricType(parametricType); } localQueryRunner.getMetadata().addFunctions(extractFunctions(plugin.getFunctions())); return localQueryRunner; }
public SqlTpchQuery1(LocalQueryRunner localQueryRunner) { super(localQueryRunner, "sql_tpch_query_1", 1, 5, "" + "select\n" + " returnflag,\n" + " linestatus,\n" + " sum(quantity) as sum_qty,\n" + " sum(extendedprice) as sum_base_price,\n" + " sum(extendedprice * (1 - discount)) as sum_disc_price,\n" + " sum(extendedprice * (1 - discount) * (1 + tax)) as sum_charge,\n" + " avg(quantity) as avg_qty,\n" + " avg(extendedprice) as avg_price,\n" + " avg(discount) as avg_disc,\n" + " count(*) as count_order\n" + "from\n" + " lineitem\n" + "where\n" + " shipdate <= DATE '1998-09-02'\n" + "group by\n" + " returnflag,\n" + " linestatus\n" + "order by\n" + " returnflag,\n" + " linestatus"); }
public static LocalQueryRunner createLocalQueryRunner(boolean hashingEnabled) { SessionBuilder sessionBuilder = testSessionBuilder() .setCatalog("tpch") .setSchema(TINY_SCHEMA_NAME); if (hashingEnabled) { sessionBuilder.setSystemProperties(ImmutableMap.of("optimizer.optimize_hash_generation", "true")); } Session session = sessionBuilder.build(); LocalQueryRunner localQueryRunner = queryRunnerWithInitialTransaction(session); // add tpch InMemoryNodeManager nodeManager = localQueryRunner.getNodeManager(); localQueryRunner.createCatalog("tpch", new TpchConnectorFactory(nodeManager, 1), ImmutableMap.<String, String>of()); return localQueryRunner; }
public StructuredTypesBenchmark(LocalQueryRunner localQueryRunner) { super(localQueryRunner, "structured_types", 4, 5, "" + "select\n" + " returnflag,\n" + " linestatus,\n" + " sum(array[quantity][1]) as sum_qty,\n" + " sum(array[extendedprice][1]) as sum_base_price,\n" + " sum(array[extendedprice][1] * (1 - map(array['key'], array[discount])['key'])) as sum_disc_price,\n" + " sum(array[extendedprice][1] * (1 - map(array['key'], array[discount])['key']) * (1 + tax)) as sum_charge,\n" + " avg(map(array['key'], array[quantity])['key']) as avg_qty,\n" + " avg(map(array['key'], array[extendedprice])['key']) as avg_price,\n" + " avg(map(array['key'], array[discount])['key']) as avg_disc\n" + "from\n" + " lineitem\n" + "where\n" + " shipdate <= DATE '1998-09-02'\n" + "group by\n" + " returnflag,\n" + " linestatus\n" + "order by\n" + " returnflag,\n" + " linestatus"); }
public static LocalQueryRunner createLocalQueryRunner() { Session session = testSessionBuilder() .setCatalog("raptor") .setSchema("benchmark") .build(); LocalQueryRunner localQueryRunner = new LocalQueryRunner(session); // add tpch InMemoryNodeManager nodeManager = localQueryRunner.getNodeManager(); localQueryRunner.createCatalog("tpch", new TpchConnectorFactory(nodeManager, 1), ImmutableMap.<String, String>of()); // add raptor ConnectorFactory raptorConnectorFactory = createRaptorConnectorFactory(TPCH_CACHE_DIR, nodeManager); localQueryRunner.createCatalog("raptor", raptorConnectorFactory, ImmutableMap.of()); if (!localQueryRunner.tableExists(session, "orders")) { localQueryRunner.execute("CREATE TABLE orders AS SELECT * FROM tpch.sf1.orders"); } if (!localQueryRunner.tableExists(session, "lineitem")) { localQueryRunner.execute("CREATE TABLE lineitem AS SELECT * FROM tpch.sf1.lineitem"); } return localQueryRunner; }
private static LocalQueryRunner createLocalQueryRunner() { Session defaultSession = testSessionBuilder() .setCatalog("local") .setSchema(TINY_SCHEMA_NAME) .build(); LocalQueryRunner localQueryRunner = new LocalQueryRunner(defaultSession); // add the tpch catalog // local queries run directly against the generator localQueryRunner.createCatalog(defaultSession.getCatalog().get(), new IndexedTpchConnectorFactory(localQueryRunner.getNodeManager(), INDEX_SPEC, 1), ImmutableMap.<String, String>of()); return localQueryRunner; }
private static LocalQueryRunner createLocalQueryRunner() { Session defaultSession = testSessionBuilder() .setCatalog("local") .setSchema(TINY_SCHEMA_NAME) .build(); LocalQueryRunner localQueryRunner = new LocalQueryRunner(defaultSession); // add the tpch catalog // local queries run directly against the generator localQueryRunner.createCatalog( defaultSession.getCatalog().get(), new TpchConnectorFactory(localQueryRunner.getNodeManager(), 1), ImmutableMap.<String, String>of()); localQueryRunner.createCatalog(TPCH_SAMPLED_SCHEMA, new SampledTpchConnectorFactory(localQueryRunner.getNodeManager(), 1, 2), ImmutableMap.<String, String>of()); localQueryRunner.getMetadata().addFunctions(CUSTOM_FUNCTIONS); SessionPropertyManager sessionPropertyManager = localQueryRunner.getMetadata().getSessionPropertyManager(); sessionPropertyManager.addSystemSessionProperties(AbstractTestQueries.TEST_SYSTEM_PROPERTIES); sessionPropertyManager.addConnectorSessionProperties("connector", AbstractTestQueries.TEST_CATALOG_PROPERTIES); return localQueryRunner; }
public SqlHashJoinBenchmark(LocalQueryRunner localQueryRunner) { super(localQueryRunner, "sql_hash_join", 4, 5, "select lineitem.orderkey, lineitem.quantity, orders.totalprice, orders.orderkey from lineitem join orders using (orderkey)"); }
protected AbstractOperatorBenchmark( LocalQueryRunner localQueryRunner, String benchmarkName, int warmupIterations, int measuredIterations) { super(benchmarkName, warmupIterations, measuredIterations); this.localQueryRunner = requireNonNull(localQueryRunner, "localQueryRunner is null"); }
protected AbstractSimpleOperatorBenchmark( LocalQueryRunner localQueryRunner, String benchmarkName, int warmupIterations, int measuredIterations) { super(localQueryRunner, benchmarkName, warmupIterations, measuredIterations); }
public SqlSemiJoinInPredicateBenchmark(LocalQueryRunner localQueryRunner) { super(localQueryRunner, "sql_semijoin_in", 2, 4, "SELECT orderkey FROM lineitem WHERE orderkey IN (SELECT orderkey FROM orders WHERE orderkey % 2 = 0)"); }
public static void main(String... args) { LocalQueryRunner localQueryRunner = createLocalQueryRunner(); new LongVarianceBenchmark(localQueryRunner).runBenchmark(new AverageBenchmarkResults()); new LongVariancePopBenchmark(localQueryRunner).runBenchmark(new AverageBenchmarkResults()); new DoubleVarianceBenchmark(localQueryRunner).runBenchmark(new AverageBenchmarkResults()); new DoubleVariancePopBenchmark(localQueryRunner).runBenchmark(new AverageBenchmarkResults()); new LongStdDevBenchmark(localQueryRunner).runBenchmark(new AverageBenchmarkResults()); new LongStdDevPopBenchmark(localQueryRunner).runBenchmark(new AverageBenchmarkResults()); new DoubleStdDevBenchmark(localQueryRunner).runBenchmark(new AverageBenchmarkResults()); new DoubleStdDevPopBenchmark(localQueryRunner).runBenchmark(new AverageBenchmarkResults()); }
public SqlInBenchmark(LocalQueryRunner localQueryRunner) { super(localQueryRunner, "sql_in", 10, 50, "SELECT orderkey FROM lineitem WHERE orderkey IN (1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30)"); }
public SqlJoinWithPredicateBenchmark(LocalQueryRunner localQueryRunner) { super(localQueryRunner, "sql_join_with_predicate", 1, 5, "select count(*) from lineitem l join orders o on l.orderkey = o.orderkey and l.partkey % 2 = 0 and o.orderkey % 2 = 0\n"); }
public GroupBySumWithArithmeticSqlBenchmark(LocalQueryRunner localQueryRunner) { super(localQueryRunner, "sql_groupby_agg_with_arithmetic", 1, 4, "select linestatus, sum(orderkey - partkey) from lineitem group by linestatus"); }
public static void main(String... args) { LocalQueryRunner localQueryRunner = createLocalQueryRunner(); new ArrayEqualsBenchmark(localQueryRunner).runBenchmark(new SimpleLineBenchmarkResultWriter(System.out)); new ArrayLessThanBenchmark(localQueryRunner).runBenchmark(new SimpleLineBenchmarkResultWriter(System.out)); new ArrayGreaterThanBenchmark(localQueryRunner).runBenchmark(new SimpleLineBenchmarkResultWriter(System.out)); new ArrayNotEqualBenchmark(localQueryRunner).runBenchmark(new SimpleLineBenchmarkResultWriter(System.out)); new ArrayLessThanOrEqualBenchmark(localQueryRunner).runBenchmark(new SimpleLineBenchmarkResultWriter(System.out)); new ArrayGreaterThanOrEqualBenchmark(localQueryRunner).runBenchmark(new SimpleLineBenchmarkResultWriter(System.out)); }
protected AbstractSqlBenchmark( LocalQueryRunner localQueryRunner, String benchmarkName, int warmupIterations, int measuredIterations, @Language("SQL") String query) { super(localQueryRunner, benchmarkName, warmupIterations, measuredIterations); this.query = query; }
public SqlTpchQuery6(LocalQueryRunner localQueryRunner) { super(localQueryRunner, "sql_tpch_query_6", 4, 20, "" + "select sum(extendedprice * discount) as revenue \n" + "from lineitem \n" + "where shipdate >= DATE '1994-01-01' \n" + " and shipdate < DATE '1995-01-01' \n" + " and discount >= 0.05 \n" + " and discount <= 0.07 \n" + " and quantity < 24"); }
@Test public void smokeTest() throws Exception { try (LocalQueryRunner localQueryRunner = createLocalQueryRunner()) { for (AbstractBenchmark benchmark : createBenchmarks(localQueryRunner)) { try { benchmark.runOnce(); } catch (RuntimeException e) { throw new AssertionError("Error running " + benchmark.getBenchmarkName(), e); } } } }
public static void main(String[] args) throws IOException { String outputDirectory = requireNonNull(System.getProperty("outputDirectory"), "Must specify -DoutputDirectory=..."); try (LocalQueryRunner localQueryRunner = createLocalQueryRunner()) { new BenchmarkSuite(localQueryRunner, outputDirectory).runAllBenchmarks(); } }
public static void assertWindowQuery(@Language("SQL") String sql, MaterializedResult expected, LocalQueryRunner localQueryRunner) { @Language("SQL") String query = format("" + "SELECT orderkey, orderstatus,\n%s\n" + "FROM (%s) x", sql, VALUES); MaterializedResult actual = localQueryRunner.execute(query); assertEqualsIgnoreOrder(actual.getMaterializedRows(), expected.getMaterializedRows()); }
public static void assertWindowQueryWithNulls(@Language("SQL") String sql, MaterializedResult expected, LocalQueryRunner localQueryRunner) { @Language("SQL") String query = format("" + "SELECT orderkey, orderstatus,\n%s\n" + "FROM (%s) x", sql, VALUES_WITH_NULLS); MaterializedResult actual = localQueryRunner.execute(query); assertEqualsIgnoreOrder(actual.getMaterializedRows(), expected.getMaterializedRows()); }
@Test(expectedExceptions = RuntimeException.class, expectedExceptionsMessageRegExp = "/ by zero") public void testQuery() { // The other test does not exercise this function during execution (i.e. inside a page processor). // It only verifies constant folding works. new LocalQueryRunner(TEST_SESSION).execute("select if(x, 78, 0/0) from (values rand() >= 0, rand() < 0) t(x)"); }
public FunctionAssertions(Session session) { this.session = requireNonNull(session, "session is null"); runner = new LocalQueryRunner(session); metadata = runner.getMetadata(); compiler = new ExpressionCompiler(metadata); }
private static LocalQueryRunner createLocalQueryRunner() { Session defaultSession = testSessionBuilder() .setCatalog("local") .setSchema(TINY_SCHEMA_NAME) .build(); LocalQueryRunner localQueryRunner = new LocalQueryRunner(defaultSession); // add the tpch catalog // local queries run directly against the generator localQueryRunner.createCatalog( defaultSession.getCatalog().get(), new TpchConnectorFactory(localQueryRunner.getNodeManager(), 1), ImmutableMap.<String, String>of()); MLPlugin plugin = new MLPlugin(); plugin.setTypeManager(localQueryRunner.getTypeManager()); for (Type type : plugin.getServices(Type.class)) { localQueryRunner.getTypeManager().addType(type); } for (ParametricType parametricType : plugin.getServices(ParametricType.class)) { localQueryRunner.getTypeManager().addParametricType(parametricType); } localQueryRunner.getMetadata().getFunctionRegistry().addFunctions(Iterables.getOnlyElement(plugin.getServices(FunctionFactory.class)).listFunctions()); return localQueryRunner; }
public static void main(String[] args) throws IOException { String outputDirectory = requireNonNull(System.getProperty("outputDirectory"), "Must specify -DoutputDirectory=..."); File tempDir = Files.createTempDir(); try (LocalQueryRunner localQueryRunner = createLocalQueryRunner(tempDir)) { new BenchmarkSuite(localQueryRunner, outputDirectory).runAllBenchmarks(); } finally { FileUtils.deleteRecursively(tempDir); } }
public static LocalQueryRunner createLocalQueryRunner(File tempDir) { Session session = testSessionBuilder() .setCatalog("hive") .setSchema("tpch") .build(); LocalQueryRunner localQueryRunner = new LocalQueryRunner(session); // add tpch InMemoryNodeManager nodeManager = localQueryRunner.getNodeManager(); localQueryRunner.createCatalog("tpch", new TpchConnectorFactory(nodeManager, 1), ImmutableMap.<String, String>of()); // add hive File hiveDir = new File(tempDir, "hive_data"); InMemoryHiveMetastore metastore = new InMemoryHiveMetastore(hiveDir); File tpchDataDir = new File(hiveDir, "tpch"); metastore.createDatabase(new Database("tpch", null, tpchDataDir.toURI().toString(), null)); HiveConnectorFactory hiveConnectorFactory = new HiveConnectorFactory( "hive", ImmutableMap.of("node.environment", "test"), HiveBenchmarkQueryRunner.class.getClassLoader(), metastore, new TypeRegistry(), new GroupByHashPageIndexerFactory()); Map<String, String> hiveCatalogConfig = ImmutableMap.<String, String>builder() .put("hive.metastore.uri", "thrift://none.invalid:0") .put("hive.max-split-size", "10GB") .build(); localQueryRunner.createCatalog("hive", hiveConnectorFactory, hiveCatalogConfig); localQueryRunner.execute("CREATE TABLE orders AS SELECT * FROM tpch.sf1.orders"); localQueryRunner.execute("CREATE TABLE lineitem AS SELECT * FROM tpch.sf1.lineitem"); return localQueryRunner; }
private static LocalQueryRunnerSupplier createQueryRunner() { try { Session defaultSession = testSessionBuilder() .setCatalog("local") .setSchema(TINY_SCHEMA_NAME) .build(); LocalQueryRunner localQueryRunner = new LocalQueryRunner(defaultSession); // add the tpch catalog // local queries run directly against the generator localQueryRunner.createCatalog( defaultSession.getCatalog().get(), new TpchConnectorFactory(1), ImmutableMap.<String, String>of()); localQueryRunner.getTypeManager().addType(new BloomFilterType()); localQueryRunner.getTypeManager().addParametricType(new BloomFilterParametricType()); localQueryRunner.getMetadata().addFunctions(extractFunctions(new BloomFilterPlugin().getFunctions())); return new LocalQueryRunnerSupplier(localQueryRunner); } catch (Exception e) { throw new RuntimeException(e); } }
public HashBuildBenchmark(LocalQueryRunner localQueryRunner) { super(localQueryRunner, "hash_build", 4, 5); }
public SqlRegexpLikeBenchmark(LocalQueryRunner localQueryRunner) { super(localQueryRunner, "sql_regexp_like", 4, 5, "SELECT count(*) FROM orders WHERE regexp_like(comment, '\\b[a-z]{5}ly\\b')"); }
public DoubleSumAggregationBenchmark(LocalQueryRunner localQueryRunner) { super(localQueryRunner, "double_sum_agg", 10, 100); }
public static List<AbstractBenchmark> createBenchmarks(LocalQueryRunner localQueryRunner) { return ImmutableList.<AbstractBenchmark>of( // hand built benchmarks new CountAggregationBenchmark(localQueryRunner), new DoubleSumAggregationBenchmark(localQueryRunner), new HashAggregationBenchmark(localQueryRunner), new PredicateFilterBenchmark(localQueryRunner), new RawStreamingBenchmark(localQueryRunner), new Top100Benchmark(localQueryRunner), new OrderByBenchmark(localQueryRunner), new HashBuildBenchmark(localQueryRunner), new HashJoinBenchmark(localQueryRunner), new HashBuildAndJoinBenchmark(localQueryRunner.getDefaultSession(), localQueryRunner), new HashBuildAndJoinBenchmark(localQueryRunner.getDefaultSession().withSystemProperty(OPTIMIZE_HASH_GENERATION, "true"), localQueryRunner), new HandTpchQuery1(localQueryRunner), new HandTpchQuery6(localQueryRunner), // sql benchmarks new GroupBySumWithArithmeticSqlBenchmark(localQueryRunner), new CountAggregationSqlBenchmark(localQueryRunner), new SqlDoubleSumAggregationBenchmark(localQueryRunner), new CountWithFilterSqlBenchmark(localQueryRunner), new GroupByAggregationSqlBenchmark(localQueryRunner), new PredicateFilterSqlBenchmark(localQueryRunner), new RawStreamingSqlBenchmark(localQueryRunner), new Top100SqlBenchmark(localQueryRunner), new SqlHashJoinBenchmark(localQueryRunner), new SqlJoinWithPredicateBenchmark(localQueryRunner), new LongMaxAggregationSqlBenchmark(localQueryRunner), new VarBinaryMaxAggregationSqlBenchmark(localQueryRunner), new SqlDistinctMultipleFields(localQueryRunner), new SqlDistinctSingleField(localQueryRunner), new SqlTpchQuery1(localQueryRunner), new SqlTpchQuery6(localQueryRunner), new SqlLikeBenchmark(localQueryRunner), new SqlInBenchmark(localQueryRunner), new SqlSemiJoinInPredicateBenchmark(localQueryRunner), new SqlRegexpLikeBenchmark(localQueryRunner), new SqlApproximatePercentileBenchmark(localQueryRunner), new SqlBetweenBenchmark(localQueryRunner), // statistics benchmarks new StatisticsBenchmark.LongVarianceBenchmark(localQueryRunner), new StatisticsBenchmark.LongVariancePopBenchmark(localQueryRunner), new StatisticsBenchmark.DoubleVarianceBenchmark(localQueryRunner), new StatisticsBenchmark.DoubleVariancePopBenchmark(localQueryRunner), new StatisticsBenchmark.LongStdDevBenchmark(localQueryRunner), new StatisticsBenchmark.LongStdDevPopBenchmark(localQueryRunner), new StatisticsBenchmark.DoubleStdDevBenchmark(localQueryRunner), new StatisticsBenchmark.DoubleStdDevPopBenchmark(localQueryRunner), // array comparison benchmarks new ArrayComparisonBenchmark.ArrayEqualsBenchmark(localQueryRunner), new ArrayComparisonBenchmark.ArrayLessThanBenchmark(localQueryRunner), new ArrayComparisonBenchmark.ArrayGreaterThanBenchmark(localQueryRunner), new ArrayComparisonBenchmark.ArrayNotEqualBenchmark(localQueryRunner), new ArrayComparisonBenchmark.ArrayLessThanOrEqualBenchmark(localQueryRunner), new ArrayComparisonBenchmark.ArrayGreaterThanOrEqualBenchmark(localQueryRunner), new SqlApproximateCountDistinctLongBenchmark(localQueryRunner), new SqlApproximateCountDistinctDoubleBenchmark(localQueryRunner), new SqlApproximateCountDistinctVarBinaryBenchmark(localQueryRunner) ); }
public BenchmarkSuite(LocalQueryRunner localQueryRunner, String outputDirectory) { this.localQueryRunner = localQueryRunner; this.outputDirectory = requireNonNull(outputDirectory, "outputDirectory is null"); }
public PredicateFilterBenchmark(LocalQueryRunner localQueryRunner) { super(localQueryRunner, "predicate_filter", 5, 50); }
public HandTpchQuery6(LocalQueryRunner localQueryRunner) { super(localQueryRunner, "hand_tpch_query_6", 10, 100); }
public PredicateFilterSqlBenchmark(LocalQueryRunner localQueryRunner) { super(localQueryRunner, "sql_predicate_filter", 5, 50, "select totalprice from orders where totalprice > 50000"); }
public OrderByBenchmark(LocalQueryRunner localQueryRunner) { super(localQueryRunner, "in_memory_orderby_1.5M", 5, 10); }
public LongMaxAggregationSqlBenchmark(LocalQueryRunner localQueryRunner) { super(localQueryRunner, "sql_long_max", 40, 200, "select max(partkey) from lineitem"); }
public HashBuildAndJoinBenchmark(Session session, LocalQueryRunner localQueryRunner) { super(localQueryRunner, "hash_build_and_join_hash_enabled_" + isHashEnabled(session), 4, 5); this.hashEnabled = isHashEnabled(session); }
public GroupByAggregationSqlBenchmark(LocalQueryRunner localQueryRunner) { super(localQueryRunner, "sql_groupby_agg", 15, 100, "select orderstatus, sum(totalprice) from orders group by orderstatus"); }