Giter Site home page Giter Site logo

heavyai / heavyai-rs Goto Github PK

View Code? Open in Web Editor NEW
3.0 3.0 4.0 449 KB

Rust client for OmniSci https://github.com/omnisci/omniscidb https://www.omnisci.com/

License: MIT License

Shell 0.25% Rust 97.40% Makefile 0.14% Dockerfile 0.03% Thrift 2.19%

heavyai-rs's Introduction

OmniSci


Latest Version

A Rust client for connecting to OmniSciDB via its RPC protocol of Thrift. This package takes care of creating a client with the Thrift binary protocol and buffered transport, and exposes all of the OmniSci Thrift types and methods for use with it.

Requirements

This client has been tested on these versions, and is expected to work with more recent versions unless otherwise noted:

  • Rust 1.41+
  • OmniSciDB 5.1+

It is also likely to work on earlier versions of OmniSciDB, but this is not officially supported.

How to use

Add omnisci to your Cargo.toml:

[dependencies]
omnisci = "0.1.0"

Then create a client and connect (to the 'Backend TCP' port on the OmniSciDB instance):

use omnisci;

let mut client = omnisci::client::create("127.0.0.1:6274")?;

let user = "admin".to_string();
let passwd = "HyperInteractive".to_string();
let database = "omnisci".to_string();

let session = client.connect(user, passwd, database)?;

let query = "SELECT * FROM flights_donotmodify LIMIT 5".to_string();
let columnar = false;
let nonce = "1".to_string();
let first_n = 10000;
let at_most_n = -1;

let results = client.sql_execute(session, query, columnar, nonce, first_n, at_most_n);

See the examples folder for a more complete example.

Contributing

Building

This project is built with Cargo, using cargo build. Each file in src/ except for lib.rs is automatically generated using Thrift, based on the the Thrift definitions stored at omniscidb (mapd.thrift, plus the .thrift files it references via include). To regenerate them, install Thrift 0.13.0 with your system's package manager, clone omniscidb locally, and then run:

./generate_thrift_bindings.sh ../omniscidb

All source is also formatted with rustfmt, via cargo fmt.

Testing

The integration tests expect a local running instance of OmniSciDB on the default Backend TCP port: http://localhost:6274

If running natively (such as with the ./startomnisci script), that port is accessible by default. If running with Docker, expose the Backend TCP port in addition to the default Frontend Web port using -p 6274:6274.

When ready, run cargo test.

License

This project is licensed under the MIT license.

heavyai-rs's People

Contributors

alexbaden avatar jonvuri avatar mikehinchey avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

heavyai-rs's Issues

examples/query_print only prints integers

Hey JraJav,

When trying to run query_print main.rs I only get integers, 0's and "NULL"

When I cargo run main.rs with only changing line 58 in main.rs to
let query = "SELECT * FROM flights_2008_10k LIMIT 1".to_string();
and line 8 in Cargo.toml to omnisci = "0.1.0"

[dependencies]
omnisci = "0.1.0"

I get

connecting to server on 127.0.0.1:6274...
connection successful
2008, 1, 6, 7, 1014, 1015, 1107, 1115, 0, 3837, 0, 53, 60, 44, -8, -1, 0, 0, 248, 3, 6, 0, NULL, 0, NULL, NULL, NULL, NULL, NULL, 1199614440, 1199617620, 0, 0, 0, 1109548800, 0, 0, 0, 0, 1986, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0

If I run in Omnisql

omnisql> SELECT * FROM flights_2008_10k LIMIT 1;
flight_year|flight_month|flight_dayofmonth|flight_dayofweek|deptime|crsdeptime|arrtime|crsarrtime|uniquecarrier|flightnum|tailnum|actualelapsedtime|crselapsedtime|airtime|arrdelay|depdelay|origin|dest|distance|taxiin|taxiout|cancelled|cancellationcode|diverted|carrierdelay|weatherdelay|nasdelay|securitydelay|lateaircraftdelay|dep_timestamp|arr_timestamp|carrier_name|plane_type|plane_manufacturer|plane_issue_date|plane_model|plane_status|plane_aircraft_type|plane_engine_type|plane_year|origin_name|origin_city|origin_state|origin_country|origin_lat|origin_lon|dest_name|dest_city|dest_state|dest_country|dest_lat|dest_lon|origin_merc_x|origin_merc_y|dest_merc_x|dest_merc_y
2008|1|6|7|2024|2010|2122|2105|WN|900|N686SW|118|115|106|17|14|DEN|LAS|629|5|7|0|NULL|0|11|0|3|0|3|2008-01-06 20:24:00|2008-01-06 21:22:00|Southwest Airlines|Corporation|BOEING|1993-10-21|737-317|Valid|Fixed Wing Multi-Engine|Turbo-Jet|1985|Denver Intl|Denver|CO|USA|39.85841|-104.667|McCarran International|Las Vegas|NV|USA|36.08036|-115.1523|-1.165148e+07|4845388|-1.28187e+07|4311684

Thank you,

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.