Skip to content

Commit

Permalink
just syncing
Browse files Browse the repository at this point in the history
  • Loading branch information
AsafMah committed Jan 1, 2024
1 parent 02ce97f commit ed981bc
Show file tree
Hide file tree
Showing 24 changed files with 591 additions and 474 deletions.
15 changes: 8 additions & 7 deletions azure-kusto-data/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,28 +5,28 @@ description = "Rust wrappers around Microsoft Azure REST APIs - Azure Data Explo
readme = "README.md"
license = "MIT"
edition = "2021"
rust-version = "1.65"
rust-version = "1.75"
repository = "https://github.com/azure/azure-sdk-for-rust"
homepage = "https://github.com/azure/azure-sdk-for-rust"
documentation = "https://docs.rs/azure_kusto_data"
keywords = ["sdk", "azure", "kusto", "azure-data-explorer"]
categories = ["api-bindings"]

[dependencies]
arrow-array = { version = "42", optional = true }
arrow-schema = { version = "42", optional = true }
azure_core = { version = "0.13", features = [
arrow-array = { version = "49.0.0", optional = true }
arrow-schema = { version = "49.0.0", optional = true }
azure_core = { version = "0.18.0", features = [
"enable_reqwest",
"enable_reqwest_gzip",
] }
azure_identity = "0.13.0"
azure_identity = "0.18.1"
async-trait = "0.1.64"
async-convert = "1.0.0"
bytes = "1.4"
futures = "0.3"
serde = { version = "1", features = ["derive"] }
serde_json = "1"
serde_with = { version = "3", features = ["json"] }
serde_with = { version = "3.4.0"}
thiserror = "1.0.38"
hashbrown = { version = "0.14", features = ["serde"] }
regex = "1.7.1"
Expand All @@ -38,10 +38,11 @@ time = { version = "0.3", features = [
"serde-well-known",
] }
derive_builder = "0.12"
derive_more = { version = "1.0.0-beta.6" , features = ["from", "into", "display"] }
once_cell = "1"

[dev-dependencies]
arrow = { version = "42", features = ["prettyprint"] }
arrow = { version = "49.0.0", features = ["prettyprint"] }
dotenv = "0.15.0"
env_logger = "0.10.0"
tokio = { version = "1.25.0", features = ["macros"] }
Expand Down
4 changes: 2 additions & 2 deletions azure-kusto-data/examples/query.rs
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
use azure_kusto_data::models::V2QueryResult;
use azure_kusto_data::prelude::*;
use azure_kusto_data::types::{KustoDateTime, KustoDuration};
use clap::Parser;
use futures::{pin_mut, TryStreamExt};
use serde::{Deserialize, Serialize};
use serde_json::Value;
use std::error::Error;
use azure_kusto_data::types::timespan::{KustoDateTime, KustoTimespan};

/// Simple program to greet a person
#[derive(Parser, Debug, Clone)]
Expand Down Expand Up @@ -140,7 +140,7 @@ struct Item {
vnum: i32,
vdec: String, // optionally, you can use a decimal type here
vdate: KustoDateTime,
vspan: KustoDuration,
vspan: KustoTimespan,
vobj: Value,
vb: bool,
vreal: f64,
Expand Down
10 changes: 5 additions & 5 deletions azure-kusto-data/src/arrow.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ use serde_json::Value;

use crate::error::Result;
use crate::models::ColumnType;
use crate::models::{Column, DataTable};
use crate::types::{KustoDateTime, KustoDuration};
use crate::models::v2::{Column, DataTable};
use crate::types::{KustoDateTime, KustoTimespan};

Check failure on line 17 in azure-kusto-data/src/arrow.rs

View workflow job for this annotation

GitHub Actions / clippy

unresolved imports `crate::types::KustoDateTime`, `crate::types::KustoTimespan`

error[E0432]: unresolved imports `crate::types::KustoDateTime`, `crate::types::KustoTimespan` --> azure-kusto-data/src/arrow.rs:17:20 | 17 | use crate::types::{KustoDateTime, KustoTimespan}; | ^^^^^^^^^^^^^ ^^^^^^^^^^^^^ no `KustoTimespan` in `types` | | | no `KustoDateTime` in `types`

fn convert_array_string(values: Vec<Value>) -> Result<ArrayRef> {
let strings: Vec<Option<String>> = serde_json::from_value(Value::Array(values))?;
Expand Down Expand Up @@ -59,7 +59,7 @@ fn convert_array_timespan(values: Vec<Value>) -> Result<ArrayRef> {
let durations: Vec<Option<i64>> = strings
.iter()
.map(|s| {
KustoDuration::from_str(s)
KustoTimespan::from_str(s)
.ok()
.and_then(|d| i64::try_from(d.whole_nanoseconds()).ok())
})
Expand Down Expand Up @@ -150,7 +150,7 @@ pub fn convert_table(table: DataTable) -> Result<RecordBatch> {
#[cfg(test)]
mod tests {
use super::*;
use crate::models::{TableKind, V2QueryResult};
use crate::models::v2::{TableKind, Frame};
use crate::operations::query::KustoResponseDataSetV2;
use std::path::PathBuf;

Expand Down Expand Up @@ -205,7 +205,7 @@ mod tests {
path.push("tests/inputs/dataframe.json");

let data = std::fs::read_to_string(path).expect("Failed to read file");
let tables: Vec<V2QueryResult> =
let tables: Vec<Frame> =
serde_json::from_str(&data).expect("Failed to deserialize result table");
let response = KustoResponseDataSetV2 { results: tables };
let record_batches = response
Expand Down
34 changes: 27 additions & 7 deletions azure-kusto-data/src/credentials.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
//! Custom credentials for Azure Data Explorer.

use std::fmt::{Debug, Formatter};
use crate::connection_string::TokenCallbackFunction;
use azure_core::auth::{AccessToken, TokenCredential, TokenResponse};
use azure_core::auth::{AccessToken, TokenCredential};
use std::time::Duration;
use time::OffsetDateTime;

Expand All @@ -14,30 +15,49 @@ pub struct ConstTokenCredential {
}
#[async_trait::async_trait]
impl TokenCredential for ConstTokenCredential {
async fn get_token(&self, _resource: &str) -> azure_core::Result<TokenResponse> {
Ok(TokenResponse {
token: AccessToken::new(self.token.clone()),
async fn get_token(&self, _resource: &str) -> azure_core::Result<AccessToken> {

Check failure on line 18 in azure-kusto-data/src/credentials.rs

View workflow job for this annotation

GitHub Actions / clippy

lifetime parameters or bounds on method `get_token` do not match the trait declaration

error[E0195]: lifetime parameters or bounds on method `get_token` do not match the trait declaration --> azure-kusto-data/src/credentials.rs:18:14 | 18 | async fn get_token(&self, _resource: &str) -> azure_core::Result<AccessToken> { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ lifetimes do not match method in trait
Ok(AccessToken {
token: self.token.clone().into(),
expires_on: OffsetDateTime::now_utc() + Duration::from_secs(SECONDS_IN_50_YEARS),
})
}

async fn clear_cache(&self) -> azure_core::Result<()> {
Ok(())
}
}


/// Uses a user provided callback that accepts the resource and returns a token in order to authenticate.
pub struct CallbackTokenCredential {
pub(crate) token_callback: TokenCallbackFunction,
pub(crate) time_to_live: Option<Duration>,
}


impl Debug for CallbackTokenCredential {
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
f.debug_struct("CallbackTokenCredential")
.field("token_callback", &"<REDACTED>")
.field("time_to_live", &self.time_to_live)
.finish()
}
}

#[async_trait::async_trait]

Check failure on line 47 in azure-kusto-data/src/credentials.rs

View workflow job for this annotation

GitHub Actions / clippy

lifetime parameters or bounds on method `get_token` do not match the trait declaration

error[E0195]: lifetime parameters or bounds on method `get_token` do not match the trait declaration --> azure-kusto-data/src/credentials.rs:47:14 | 47 | async fn get_token(&self, resource: &str) -> azure_core::Result<AccessToken> { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ lifetimes do not match method in trait
impl TokenCredential for CallbackTokenCredential {
async fn get_token(&self, resource: &str) -> azure_core::Result<TokenResponse> {
async fn get_token(&self, resource: &str) -> azure_core::Result<AccessToken> {
let callback = &self.token_callback;
Ok(TokenResponse {
token: AccessToken::new(callback(resource)),
Ok(AccessToken {
token: callback(resource).into(),
expires_on: OffsetDateTime::now_utc()
+ self
.time_to_live
.unwrap_or(Duration::from_secs(SECONDS_IN_50_YEARS)),
})
}

async fn clear_cache(&self) -> azure_core::Result<()> {
todo!()
}
}
1 change: 1 addition & 0 deletions azure-kusto-data/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,4 @@ mod operations;
pub mod prelude;
pub mod request_options;
pub mod types;
mod query;
Loading

0 comments on commit ed981bc

Please sign in to comment.