Code Monkey home page Code Monkey logo

php-presto-client's Introduction

Ytake\PrestoClient

Build Status Coverage Status Scrutinizer Code Quality

License Latest Version Total Downloads StyleCI

SensioLabsInsight

prestodb http protocol client for php

prestodb

What is Presto

Presto is an open source distributed SQL query engine for running interactive analytic queries against data sources of all sizes ranging from gigabytes to petabytes.

Install

required >= PHP 7.0

$ composer require ytake/php-presto-client

Usage

Standard

<?php

$client = new \Ytake\PrestoClient\StatementClient(
    new \Ytake\PrestoClient\ClientSession('http://localhost:8080/', 'acme'),
    'SELECT * FROM acme.acme.acme'
);
// execute http request
$client->execute();
// next call uri
$client->advance();

/** @var \Ytake\PrestoClient\QueryResult $result */
// current result
$result = $client->current();

// request cancel
$client->cancelLeafStage();

bulk operations

<?php

$client = new \Ytake\PrestoClient\StatementClient(
    new \Ytake\PrestoClient\ClientSession('http://localhost:8080/', 'acme'),
    'SELECT * FROM acme.acme.acme'
);
$resultSession = new \Ytake\PrestoClient\ResultsSession($client);
// yield results instead of returning them. Recommended.
$result = $resultSession->execute()->yieldResults();

// array
$result = $resultSession->execute()->getResults();

Fetch Styles

FixData Object

<?php

$client = new \Ytake\PrestoClient\StatementClient(
    new \Ytake\PrestoClient\ClientSession('http://localhost:8080/', 'acme'),
    'SELECT * FROM acme.acme.acme'
);
$resultSession = new \Ytake\PrestoClient\ResultsSession($client);
$result = $resultSession->execute()->yieldResults();
/** @var \Ytake\PrestoClient\QueryResult $row */
foreach ($result as $row) {
    foreach ($row->yieldData() as $yieldRow) {
        if ($yieldRow instanceof \Ytake\PrestoClient\FixData) {
            var_dump($yieldRow->offsetGet('column_name'), $yieldRow['column_name']);
        }
    }
}

Array Keys

<?php

$client = new \Ytake\PrestoClient\StatementClient(
    new \Ytake\PrestoClient\ClientSession('http://localhost:8080/', 'acme'),
    'SELECT * FROM acme.acme.acme'
);
$resultSession = new \Ytake\PrestoClient\ResultsSession($client);
$result = $resultSession->execute()->yieldResults();
/** @var \Ytake\PrestoClient\QueryResult $row */
foreach ($result as $row) {
    /** @var array $item */
    foreach ($row->yieldDataArray() as $item) {
        if (!is_null($item)) {
            var_dump($item);
        }
    }
}

Mapping Class

<?php

class Testing
{
    private $_key;

    private $_value;
}

$client = new \Ytake\PrestoClient\StatementClient(
    new \Ytake\PrestoClient\ClientSession('http://localhost:8080/', 'acme'),
    'SELECT * FROM acme.acme.acme'
);
$resultSession = new \Ytake\PrestoClient\ResultsSession($client);
$result = $resultSession->execute()->yieldResults();
/** @var \Ytake\PrestoClient\QueryResult $row */
foreach ($result as $row) {
    foreach($row->yieldObject(Testing::class) as $object) {
        if ($object instanceof Testing) {
            var_dump($object);
        }
    }
}

php-presto-client's People

Contributors

sonnyyou avatar ytake avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

php-presto-client's Issues

BasicAuthentication in php-presto-client

How does "BasicAuthentication" works to access a presto,

For Example in python,
prestodb.dbapi.connect(
host="localhost",
port="8080",
user="username",
auth=prestodb.auth.BasicAuthentication("username", "password"),
catalog="catalog",
schema="schema",
http_scheme='https'
)

Does the authentication can be achieved using this presto-client

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.