Package com.facebook.presto.util

Examples of com.facebook.presto.util.LocalQueryRunner


        //
        // If the projection does not need bound values, execute query using full engine
        if (!needsBoundValue(projectionExpression)) {
            try {
                LocalQueryRunner runner = createDualLocalQueryRunner(session, EXECUTOR);
                MaterializedResult result = runner.execute("SELECT " + projection + " FROM dual");
                assertEquals(result.getTupleInfos().size(), 1);
                assertEquals(result.getMaterializedTuples().size(), 1);
                Object queryResult = Iterables.getOnlyElement(result.getMaterializedTuples()).getField(0);
                results.add(queryResult);
            }
View Full Code Here


        //
        // If the filter does not need bound values, execute query using full engine
        if (!needsBoundValue(filterExpression)) {
            try {
                LocalQueryRunner runner = createDualLocalQueryRunner(session, EXECUTOR);
                MaterializedResult result = runner.execute("SELECT TRUE FROM dual WHERE " + filter);
                assertEquals(result.getTupleInfos().size(), 1);

                Boolean queryResult;
                if (result.getMaterializedTuples().isEmpty()) {
                    queryResult = false;
View Full Code Here

    }

    public FunctionAssertions(ConnectorSession session)
    {
        this.session = checkNotNull(session, "session is null");
        runner = new LocalQueryRunner(session, EXECUTOR);
        metadataManager = runner.getMetadata();
        compiler = new ExpressionCompiler(metadataManager);
    }
View Full Code Here

{
    private static final Logger LOGGER = Logger.get(BenchmarkSuite.class);

    public static List<AbstractBenchmark> createBenchmarks(ExecutorService executor)
    {
        LocalQueryRunner localQueryRunner = createLocalQueryRunner(executor);
        LocalQueryRunner localSampledQueryRunner = createLocalSampledQueryRunner(executor);

        return ImmutableList.<AbstractBenchmark>of(
                // hand built benchmarks
                new CountAggregationBenchmark(localQueryRunner),
                new DoubleSumAggregationBenchmark(localQueryRunner),
View Full Code Here

    private WindowAssertions() {}

    public static MaterializedResult computeActual(@Language("SQL") String sql, ExecutorService executor)
    {
        ConnectorSession session = new ConnectorSession("user", "test", "tpch", TpchMetadata.TINY_SCHEMA_NAME, UTC_KEY, Locale.ENGLISH, null, null);
        LocalQueryRunner localQueryRunner = new LocalQueryRunner(session, executor);
        localQueryRunner.createCatalog("tpch", new TpchConnectorFactory(localQueryRunner.getNodeManager(), 1), ImmutableMap.<String, String>of());

        return localQueryRunner.execute(sql);
    }
View Full Code Here

    @Override
    protected ConnectorSession setUpQueryFramework()
    {
        ConnectorSession session = new ConnectorSession("user", "test", "local", TpchMetadata.TINY_SCHEMA_NAME, UTC_KEY, Locale.ENGLISH, null, null);
        localQueryRunner = new LocalQueryRunner(session, getExecutor());
        localSampledQueryRunner = new LocalQueryRunner(session, getExecutor());

        // add the tpch catalog
        // local queries run directly against the generator
        localQueryRunner.createCatalog(session.getCatalog(), new TpchConnectorFactory(localQueryRunner.getNodeManager(), 1), ImmutableMap.<String, String>of());
        localSampledQueryRunner.createCatalog(session.getCatalog(), new SampledTpchConnectorFactory(localSampledQueryRunner.getNodeManager(), 1, 2), ImmutableMap.<String, String>of());
View Full Code Here

    @Override
    protected ConnectorSession setUpQueryFramework()
    {
        ConnectorSession session = new ConnectorSession("user", "test", "local", TpchMetadata.TINY_SCHEMA_NAME, UTC_KEY, Locale.ENGLISH, null, null);
        localSampledQueryRunner = new LocalQueryRunner(session, getExecutor());

        // add the tpch catalog
        // local queries run directly against the generator
        localSampledQueryRunner.createCatalog(session.getCatalog(), new SampledTpchConnectorFactory(localSampledQueryRunner.getNodeManager(), 1, 1), ImmutableMap.<String, String>of());
        localSampledQueryRunner.getMetadata().addFunctions(CUSTOM_FUNCTIONS);
View Full Code Here

    @Override
    protected ConnectorSession setUpQueryFramework()
    {
        ConnectorSession session = new ConnectorSession("user", "test", "local", TpchMetadata.TINY_SCHEMA_NAME, UTC_KEY, Locale.ENGLISH, null, null);
        localIndexedQueryRunner = new LocalQueryRunner(session, getExecutor());

        // add the tpch catalog
        // local queries run directly against the generator
        localIndexedQueryRunner.createCatalog(session.getCatalog(), new IndexedTpchConnectorFactory(localIndexedQueryRunner.getNodeManager(), getTpchIndexSpec(), 1), ImmutableMap.<String, String>of());
View Full Code Here

    }

    public static LocalQueryRunner createLocalSampledQueryRunner(ExecutorService executor)
    {
        ConnectorSession session = new ConnectorSession("user", "test", "default", "default", UTC_KEY, Locale.ENGLISH, null, null);
        LocalQueryRunner localQueryRunner = new LocalQueryRunner(session, executor);

        // add sampled tpch
        InMemoryNodeManager nodeManager = localQueryRunner.getNodeManager();
        localQueryRunner.createCatalog("tpch_sampled", new SampledTpchConnectorFactory(nodeManager, 1, 2), ImmutableMap.<String, String>of());

        // add native
        NativeConnectorFactory nativeConnectorFactory = createNativeConnectorFactory(
                nodeManager,
                localQueryRunner.getTypeManager(),
                System.getProperty("tpchSampledCacheDir", "/tmp/presto_tpch/sampled_data_cache"));
        localQueryRunner.createCatalog("default", nativeConnectorFactory, ImmutableMap.<String, String>of());

        MetadataManager metadata = localQueryRunner.getMetadata();
        if (!metadata.getTableHandle(session, new QualifiedTableName("default", "default", "orders")).isPresent()) {
            localQueryRunner.execute("CREATE TABLE orders AS SELECT * FROM tpch_sampled.sf1.orders");
        }
        if (!metadata.getTableHandle(session, new QualifiedTableName("default", "default", "lineitem")).isPresent()) {
            localQueryRunner.execute("CREATE TABLE lineitem AS SELECT * FROM tpch_sampled.sf1.lineitem");
        }
        return localQueryRunner;
    }
View Full Code Here

    }

    public static LocalQueryRunner createLocalQueryRunner(ExecutorService executor)
    {
        ConnectorSession session = new ConnectorSession("user", "test", "default", "default", UTC_KEY, Locale.ENGLISH, null, null);
        LocalQueryRunner localQueryRunner = new LocalQueryRunner(session, executor);

        // add tpch
        InMemoryNodeManager nodeManager = localQueryRunner.getNodeManager();
        localQueryRunner.createCatalog("tpch", new TpchConnectorFactory(nodeManager, 1), ImmutableMap.<String, String>of());

        // add native
        NativeConnectorFactory nativeConnectorFactory = createNativeConnectorFactory(
                nodeManager,
                localQueryRunner.getTypeManager(),
                System.getProperty("tpchCacheDir", "/tmp/presto_tpch/data_cache"));
        localQueryRunner.createCatalog("default", nativeConnectorFactory, ImmutableMap.<String, String>of());

        MetadataManager metadata = localQueryRunner.getMetadata();
        if (!metadata.getTableHandle(session, new QualifiedTableName("default", "default", "orders")).isPresent()) {
            localQueryRunner.execute("CREATE TABLE orders AS SELECT * FROM tpch.sf1.orders");
        }
        if (!metadata.getTableHandle(session, new QualifiedTableName("default", "default", "lineitem")).isPresent()) {
            localQueryRunner.execute("CREATE TABLE lineitem AS SELECT * FROM tpch.sf1.lineitem");
        }
        return localQueryRunner;
    }
View Full Code Here

TOP

Related Classes of com.facebook.presto.util.LocalQueryRunner

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.