Avatica-Client
view release on metacpan or search on metacpan
lib/Avatica/Client.pm view on Meta::CPAN
AvaticaType component = 5; // Only present when name = ARRAY
}
// Generic wrapper to support any SQL type. Struct-like to work around no polymorphism construct.
message TypedValue {
Rep type = 1; // The actual type that was serialized in the general attribute below
bool bool_value = 2; // boolean
string string_value = 3; // char/varchar
sint64 number_value = 4; // var-len encoding lets us shove anything from byte to long
// includes numeric types and date/time types.
bytes bytes_value = 5; // binary/varbinary
double double_value = 6; // big numbers
bool null = 7; // a null object
repeated TypedValue array_value = 8; // The Array
Rep component_type = 9; // If an Array, the representation for the array values
bool implicitly_null = 10; // Differentiate between explicitly null (user-set) and implicitly null
// (un-set by the user)
}
enum Rep {
PRIMITIVE_BOOLEAN = 0;
PRIMITIVE_BYTE = 1;
PRIMITIVE_CHAR = 2;
PRIMITIVE_SHORT = 3;
PRIMITIVE_INT = 4;
PRIMITIVE_LONG = 5;
PRIMITIVE_FLOAT = 6;
PRIMITIVE_DOUBLE = 7;
BOOLEAN = 8;
BYTE = 9;
CHARACTER = 10;
SHORT = 11;
INTEGER = 12;
LONG = 13;
FLOAT = 14;
DOUBLE = 15;
BIG_INTEGER = 25;
BIG_DECIMAL = 26;
JAVA_SQL_TIME = 16;
JAVA_SQL_TIMESTAMP = 17;
JAVA_SQL_DATE = 18;
JAVA_UTIL_DATE = 19;
BYTE_STRING = 20;
STRING = 21;
NUMBER = 22;
OBJECT = 23;
NULL = 24;
ARRAY = 27;
STRUCT = 28;
MULTISET = 29;
}
// Generic metadata for the server to return with each response.
message RpcMetadata {
string server_address = 1; // The host:port of the server
}
// Message which encapsulates another message to support a single RPC endpoint
message WireMessage {
string name = 1;
bytes wrapped_message = 2;
}
__END__
=head1 SYNOPSIS
use Avatica::Client;
my $connection_id = 'number-or-uuid-or-any-string';
my $client = Avatica::Client->new(url => 'http://172.17.0.1:8765');
my ($res, $connection) = $client->open_connection($connection_id);
die "can't open connection: $connection->{message}" if !$res;
($res, my $prepare) = $client->prepare($connection_id, 'SELECT * FROM table WERE id = ? LIMIT 10');
die "can't prepare query: $prepare->{message}" if !$res;
my $statement = $prepare->get_statement;
my $statement_id = $statement->get_id;
my $signature = $statement->get_signature;
my $tv = Avatica::Client::Protocol::TypedValue->new;
$tv->set_number_value(1);
$tv->set_type(Avatica::Client::Protocol::Rep::LONG());
($res, my $execute) = $client->execute($connection_id, $statement_id, $signature, [$tv], 2);
die "can't execute: $execute->{message}" if !$res;
($res, my $fetch) = $client->fetch($connection_id, $statement_id, undef, 8);
die "can't fetch: $fetch->{message}" if !$res;
($res, my $close_state) = $client->close_statement($connection_id, $statement_id);
die "close statement error: $close_state->{message}" if !$res;
($res, $r) = $client->close_connection($connection_id);
die "close connection error: $r->{message}" if !$res;
=head1 DESCRIPTION
Client for Apache Calcite Avatica which based on HTTP and Google Protobuf.
=head2 new
Creates object of the Avatica::Client.
my $client = Avatica::Client->new(url => 'http://127.0.0.1:8765', max_retries => 10);
=head3 Parameters
=head4 url
URL to send request (required).
=head4 max_retries
Number of retires (default 3).
=head4 ua
HTTP::Tiny user agent.
=head2 open_connection
Open new connection.
( run in 0.587 second using v1.01-cache-2.11-cpan-e1769b4cff6 )