This commit is contained in:
AsafMah 2022-07-28 16:58:40 +03:00
Родитель aee73398ff
Коммит c0a2b4df61
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: AD0D1680EEE7A4FF
8 изменённых файлов: 115 добавлений и 73 удалений

Просмотреть файл

@ -22,7 +22,7 @@ async fn main() -> Result<(), Box<dyn Error + Send + Sync>> {
let authority_id =
std::env::var("AZURE_TENANT_ID").expect("Set env variable AZURE_TENANT_ID first!");
let kcsb = ConnectionString::from_application_auth(
let kcsb = ConnectionString::with_application_auth(
service_url,
client_id,
client_secret,

Просмотреть файл

@ -35,7 +35,7 @@ struct Args {
async fn main() -> Result<(), Box<dyn Error>> {
let args = Args::parse();
let kcsb = ConnectionString::from_application_auth(
let kcsb = ConnectionString::with_application_auth(
args.endpoint,
args.application_id,
args.tenant_id,

Просмотреть файл

@ -90,13 +90,13 @@ pub fn convert_column(data: Vec<serde_json::Value>, column: &Column) -> Result<(
match column.column_type {
ColumnType::String => convert_array_string(data)
.map(|data| (Field::new(column_name, DataType::Utf8, true), data)),
ColumnType::Bool | ColumnType::Boolean => convert_array_bool(data)
ColumnType::Bool => convert_array_bool(data)
.map(|data| (Field::new(column_name, DataType::Boolean, true), data)),
ColumnType::Int => convert_array_i32(data)
.map(|data| (Field::new(column_name, DataType::Int32, true), data)),
ColumnType::Long => convert_array_i64(data)
.map(|data| (Field::new(column_name, DataType::Int64, true), data)),
ColumnType::Real | ColumnType::Double => convert_array_float(data)
ColumnType::Real => convert_array_float(data)
.map(|data| (Field::new(column_name, DataType::Float64, true), data)),
ColumnType::Datetime => convert_array_datetime(data).map(|data| {
(

Просмотреть файл

@ -83,7 +83,7 @@ impl KustoClient {
/// use azure_kusto_data::prelude::*;
///
/// let client = KustoClient::new(
/// ConnectionString::from_default_auth("https://mycluster.region.kusto.windows.net/".to_string()),
/// ConnectionString::with_default_auth("https://mycluster.region.kusto.windows.net/".to_string()),
/// KustoClientOptions::default());
///
/// assert!(client.is_ok());
@ -123,7 +123,7 @@ impl KustoClient {
/// # #[tokio::main] async fn main() -> Result<(), Error> {
///
/// let client = KustoClient::new(
/// ConnectionString::from_default_auth("https://mycluster.region.kusto.windows.net/".to_string()),
/// ConnectionString::with_default_auth("https://mycluster.region.kusto.windows.net/".to_string()),
/// KustoClientOptions::default())?;
///
/// // Once the [IntoFuture] trait is stabilized, we can drop the call the `into_future()` here
@ -132,7 +132,8 @@ impl KustoClient {
/// assert!(matches!(result, KustoResponse::V1(..)));
/// # Ok(())}
/// ```
#[must_use] pub fn execute_with_options(
#[must_use]
pub fn execute_with_options(
&self,
database: String,
query: String,
@ -161,7 +162,7 @@ impl KustoClient {
/// use azure_kusto_data::request_options::RequestOptionsBuilder;
///
/// let client = KustoClient::new(
/// ConnectionString::from_default_auth("https://mycluster.region.kusto.windows.net/".to_string()),
/// ConnectionString::with_default_auth("https://mycluster.region.kusto.windows.net/".to_string()),
/// KustoClientOptions::default())?;
/// // Once the [IntoFuture] trait is stabilized, we can drop the call the `into_future()` here
/// let result = client.execute_query_with_options(
@ -176,7 +177,8 @@ impl KustoClient {
/// # Ok(())}
/// ```
///
#[must_use] pub fn execute_query_with_options(
#[must_use]
pub fn execute_query_with_options(
&self,
database: String,
query: String,
@ -194,7 +196,7 @@ impl KustoClient {
///
/// # #[tokio::main] async fn main() -> Result<(), Error> {
/// let client = KustoClient::new(
/// ConnectionString::from_default_auth("https://mycluster.region.kusto.windows.net/".to_string()),
/// ConnectionString::with_default_auth("https://mycluster.region.kusto.windows.net/".to_string()),
/// KustoClientOptions::default())?;
///
/// // Once the [IntoFuture] trait is stabilized, we can drop the call the `into_future()` here
@ -205,7 +207,8 @@ impl KustoClient {
/// }
/// # Ok(())}
/// ```
#[must_use] pub fn execute_query(&self, database: String, query: String) -> V2QueryRunner {
#[must_use]
pub fn execute_query(&self, database: String, query: String) -> V2QueryRunner {
V2QueryRunner(self.execute_with_options(database, query, QueryKind::Query, None))
}
@ -217,7 +220,7 @@ impl KustoClient {
/// use azure_kusto_data::prelude::*;
/// # #[tokio::main] async fn main() -> Result<(), Error> {
/// let client = KustoClient::new(
/// ConnectionString::from_default_auth("https://mycluster.region.kusto.windows.net/".to_string()),
/// ConnectionString::with_default_auth("https://mycluster.region.kusto.windows.net/".to_string()),
/// KustoClientOptions::default())?;
///
/// // Once the [IntoFuture] trait is stabilized, we can drop the call the `into_future()` here
@ -230,7 +233,8 @@ impl KustoClient {
/// }
/// # Ok(())}
/// ```
#[must_use] pub fn execute_command_with_options(
#[must_use]
pub fn execute_command_with_options(
&self,
database: String,
query: String,
@ -249,7 +253,7 @@ impl KustoClient {
/// # #[tokio::main] async fn main() -> Result<(), Error> {
///
/// let client = KustoClient::new(
/// ConnectionString::from_default_auth("https://mycluster.region.kusto.windows.net/".to_string()),
/// ConnectionString::with_default_auth("https://mycluster.region.kusto.windows.net/".to_string()),
/// KustoClientOptions::default())?;
///
/// // Once the [IntoFuture] trait is stabilized, we can drop the call the `into_future()` here
@ -260,7 +264,8 @@ impl KustoClient {
/// }
/// # Ok(())}
/// ```
#[must_use] pub fn execute_command(&self, database: String, query: String) -> V1QueryRunner {
#[must_use]
pub fn execute_command(&self, database: String, query: String) -> V1QueryRunner {
V1QueryRunner(self.execute_with_options(database, query, QueryKind::Management, None))
}
}

Просмотреть файл

@ -37,7 +37,7 @@ const CONNECTION_STRING_TRUE: &str = "True";
const CONNECTION_STRING_FALSE: &str = "False";
impl ConnectionStringKey {
const fn to_str(&self) -> &'static str {
const fn to_str(self) -> &'static str {
match self {
ConnectionStringKey::DataSource => "Data Source",
ConnectionStringKey::FederatedSecurity => "AAD Federated Security",
@ -253,7 +253,8 @@ impl ConnectionStringAuth {
///
/// assert_eq!(token_callback.build(true), None);
/// ```
#[must_use] pub fn build(&self, safe: bool) -> Option<String> {
#[must_use]
pub fn build(&self, safe: bool) -> Option<String> {
match self {
ConnectionStringAuth::Default => Some("".to_string()),
ConnectionStringAuth::UserAndPassword { user_id, password } => Some(format!(
@ -377,8 +378,8 @@ impl PartialEq for ConnectionStringAuth {
ConnectionStringAuth::ManagedIdentity { user_id: u1 },
ConnectionStringAuth::ManagedIdentity { user_id: u2 },
) => u1 == u2,
(ConnectionStringAuth::AzureCli, ConnectionStringAuth::AzureCli) => true,
(ConnectionStringAuth::InteractiveLogin, ConnectionStringAuth::InteractiveLogin) => {
(ConnectionStringAuth::AzureCli, ConnectionStringAuth::AzureCli)
| (ConnectionStringAuth::InteractiveLogin, ConnectionStringAuth::InteractiveLogin) => {
true
}
_ => false,
@ -489,11 +490,12 @@ impl ConnectionString {
}
}
let data_source = (*result_map
.get(&ConnectionStringKey::DataSource)
.ok_or(ConnectionStringError::MissingValue {
let data_source = (*result_map.get(&ConnectionStringKey::DataSource).ok_or(
ConnectionStringError::MissingValue {
key: "data_source".to_string(),
})?).to_string();
},
)?)
.to_string();
let federated_security = result_map
.get(&ConnectionStringKey::FederatedSecurity)
@ -580,7 +582,8 @@ impl ConnectionString {
} else if result_map
.get(&ConnectionStringKey::MsiAuth)
.map(|s| parse_boolean(s, "msi_auth"))
.transpose()? == Some(true)
.transpose()?
== Some(true)
{
let msi_user_id = result_map
.get(&ConnectionStringKey::MsiParams)
@ -595,7 +598,8 @@ impl ConnectionString {
} else if result_map
.get(&ConnectionStringKey::AzCli)
.map(|s| parse_boolean(s, "az_cli"))
.transpose()? == Some(true)
.transpose()?
== Some(true)
{
Ok(Self {
data_source,
@ -605,7 +609,8 @@ impl ConnectionString {
} else if result_map
.get(&ConnectionStringKey::InteractiveLogin)
.map(|s| parse_boolean(s, "interactive_login"))
.transpose()? == Some(true)
.transpose()?
== Some(true)
{
Ok(Self {
data_source,
@ -627,14 +632,15 @@ impl ConnectionString {
/// ```rust
/// use azure_kusto_data::prelude::{ConnectionString, ConnectionStringAuth};
///
/// let conn = ConnectionString::from_default_auth("https://mycluster.kusto.windows.net".into());
/// let conn = ConnectionString::with_default_auth("https://mycluster.kusto.windows.net".into());
///
/// assert_eq!(conn.data_source, "https://mycluster.kusto.windows.net".to_string());
/// assert_eq!(conn.auth, ConnectionStringAuth::Default);
///
/// assert_eq!(conn.build(), Some("Data Source=https://mycluster.kusto.windows.net;AAD Federated Security=True;".to_string()))
/// ```
#[must_use] pub fn from_default_auth(data_source: String) -> Self {
#[must_use]
pub const fn with_default_auth(data_source: String) -> Self {
Self {
data_source,
federated_security: true,
@ -647,14 +653,19 @@ impl ConnectionString {
/// ```rust
/// use azure_kusto_data::prelude::{ConnectionString, ConnectionStringAuth};
///
/// let conn = ConnectionString::from_user_auth("https://mycluster.kusto.windows.net".into(), "user".into(), "password".into());
/// let conn = ConnectionString::with_user_password_auth("https://mycluster.kusto.windows.net".into(), "user".into(), "password".into());
///
/// assert_eq!(conn.data_source, "https://mycluster.kusto.windows.net".to_string());
/// assert!(matches!(conn.auth, ConnectionStringAuth::UserAndPassword { .. }));
///
/// assert_eq!(conn.build(), Some("Data Source=https://mycluster.kusto.windows.net;AAD Federated Security=True;AAD User ID=user;Password=******".to_string()))
/// ```
#[must_use] pub fn from_user_auth(data_source: String, user_id: String, password: String) -> Self {
#[must_use]
pub const fn with_user_password_auth(
data_source: String,
user_id: String,
password: String,
) -> Self {
Self {
data_source,
federated_security: true,
@ -667,14 +678,15 @@ impl ConnectionString {
/// ```rust
/// use azure_kusto_data::prelude::{ConnectionString, ConnectionStringAuth};
///
/// let conn = ConnectionString::from_token_auth("https://mycluster.kusto.windows.net".into(), "token".into());
/// let conn = ConnectionString::with_token_auth("https://mycluster.kusto.windows.net".into(), "token".into());
///
/// assert_eq!(conn.data_source, "https://mycluster.kusto.windows.net".to_string());
/// assert!(matches!(conn.auth, ConnectionStringAuth::Token { .. }));
///
/// assert_eq!(conn.build(), Some("Data Source=https://mycluster.kusto.windows.net;AAD Federated Security=True;ApplicationToken=******".to_string()))
/// ```
#[must_use] pub fn from_token_auth(data_source: String, token: String) -> Self {
#[must_use]
pub const fn with_token_auth(data_source: String, token: String) -> Self {
Self {
data_source,
federated_security: true,
@ -688,7 +700,7 @@ impl ConnectionString {
/// use std::sync::Arc;
/// use azure_kusto_data::prelude::{ConnectionString, ConnectionStringAuth};
///
/// let conn = ConnectionString::from_token_callback_auth("https://mycluster.kusto.windows.net".into(), Arc::new(|resource_uri| resource_uri.to_string()));
/// let conn = ConnectionString::with_token_callback_auth("https://mycluster.kusto.windows.net".into(), Arc::new(|resource_uri| resource_uri.to_string()));
///
/// assert_eq!(conn.data_source, "https://mycluster.kusto.windows.net".to_string());
/// assert!(matches!(conn.auth, ConnectionStringAuth::TokenCallback { .. }));
@ -696,7 +708,8 @@ impl ConnectionString {
/// // Can't be represented as a string.
/// assert_eq!(conn.build(), None)
/// ```
#[must_use] pub fn from_token_callback_auth(
#[must_use]
pub fn with_token_callback_auth(
data_source: String,
token_callback: Arc<dyn Fn(&str) -> String>,
) -> Self {
@ -712,7 +725,7 @@ impl ConnectionString {
/// ```rust
/// use azure_kusto_data::prelude::{ConnectionString, ConnectionStringAuth};
///
/// let conn = ConnectionString::from_application_auth("https://mycluster.kusto.windows.net".into(),
/// let conn = ConnectionString::with_application_auth("https://mycluster.kusto.windows.net".into(),
/// "029067d2-220e-4467-99be-b74f4751270b".into(),
/// "client_secret".into(),
/// "e7f86dff-7a05-4b87-8c48-ed1ea5b5b814".into());
@ -721,7 +734,8 @@ impl ConnectionString {
/// assert!(matches!(conn.auth, ConnectionStringAuth::Application { .. }));
/// assert_eq!(conn.build(), Some("Data Source=https://mycluster.kusto.windows.net;AAD Federated Security=True;Application Client Id=029067d2-220e-4467-99be-b74f4751270b;Application Key=******;Authority Id=e7f86dff-7a05-4b87-8c48-ed1ea5b5b814".to_string()))
/// ```
#[must_use] pub fn from_application_auth(
#[must_use]
pub const fn with_application_auth(
data_source: String,
client_id: String,
client_secret: String,
@ -742,7 +756,7 @@ impl ConnectionString {
/// ```rust
/// use azure_kusto_data::prelude::{ConnectionString, ConnectionStringAuth};
///
/// let conn = ConnectionString::from_application_certificate_auth("https://mycluster.kusto.windows.net".into(),
/// let conn = ConnectionString::with_application_certificate_auth("https://mycluster.kusto.windows.net".into(),
/// "029067d2-220e-4467-99be-b74f4751270b".into(),
/// "e7f86dff-7a05-4b87-8c48-ed1ea5b5b814".into(),
/// "certificate.pem".into(),
@ -752,7 +766,8 @@ impl ConnectionString {
/// assert!(matches!(conn.auth, ConnectionStringAuth::ApplicationCertificate { .. }));
/// assert_eq!(conn.build(), Some("Data Source=https://mycluster.kusto.windows.net;AAD Federated Security=True;Application Client Id=029067d2-220e-4467-99be-b74f4751270b;ApplicationCertificate=certificate.pem;Application Certificate Thumbprint=******;Authority Id=e7f86dff-7a05-4b87-8c48-ed1ea5b5b814".to_string()))
/// ```
#[must_use] pub fn from_application_certificate_auth(
#[must_use]
pub const fn with_application_certificate_auth(
data_source: String,
client_id: String,
client_authority: String,
@ -777,14 +792,15 @@ impl ConnectionString {
/// ```rust
/// use azure_kusto_data::prelude::{ConnectionString, ConnectionStringAuth};
///
/// let conn = ConnectionString::from_managed_identity_auth("https://mycluster.kusto.windows.net".into(), None);
/// let conn = ConnectionString::with_managed_identity_auth("https://mycluster.kusto.windows.net".into(), None);
///
/// assert_eq!(conn.data_source, "https://mycluster.kusto.windows.net".to_string());
/// assert_eq!(conn.auth, ConnectionStringAuth::ManagedIdentity { user_id: None });
///
/// assert_eq!(conn.build(), Some("Data Source=https://mycluster.kusto.windows.net;AAD Federated Security=True;MSI Authentication=True".to_string()))
/// ```
#[must_use] pub fn from_managed_identity_auth(data_source: String, user_id: Option<String>) -> Self {
#[must_use]
pub const fn with_managed_identity_auth(data_source: String, user_id: Option<String>) -> Self {
Self {
data_source,
federated_security: true,
@ -798,14 +814,15 @@ impl ConnectionString {
/// ```rust
/// use azure_kusto_data::prelude::{ConnectionString, ConnectionStringAuth};
///
/// let conn = ConnectionString::from_azure_cli_auth("https://mycluster.kusto.windows.net".into());
/// let conn = ConnectionString::with_azure_cli_auth("https://mycluster.kusto.windows.net".into());
///
/// assert_eq!(conn.data_source, "https://mycluster.kusto.windows.net".to_string());
/// assert_eq!(conn.auth, ConnectionStringAuth::AzureCli);
///
/// assert_eq!(conn.build(), Some("Data Source=https://mycluster.kusto.windows.net;AAD Federated Security=True;AZ CLI=True".to_string()))
/// ```
#[must_use] pub fn from_azure_cli_auth(data_source: String) -> Self {
#[must_use]
pub const fn with_azure_cli_auth(data_source: String) -> Self {
Self {
data_source,
federated_security: true,
@ -820,7 +837,7 @@ impl ConnectionString {
/// use std::sync::Arc;
/// use azure_kusto_data::prelude::{ConnectionString, ConnectionStringAuth};
///
/// let conn = ConnectionString::from_device_code_auth("https://mycluster.kusto.windows.net".into(), Some(Arc::new(|code| code.to_string())));
/// let conn = ConnectionString::with_device_code_auth("https://mycluster.kusto.windows.net".into(), Some(Arc::new(|code| code.to_string())));
///
/// assert_eq!(conn.data_source, "https://mycluster.kusto.windows.net".to_string());
/// assert!(matches!(conn.auth, ConnectionStringAuth::DeviceCode { .. }));
@ -828,7 +845,8 @@ impl ConnectionString {
/// // Can't be represented as a string.
/// assert_eq!(conn.build(), None)
/// ```
#[must_use] pub fn from_device_code_auth(
#[must_use]
pub fn with_device_code_auth(
data_source: String,
callback: Option<Arc<dyn Fn(&str) -> String>>,
) -> Self {
@ -844,14 +862,15 @@ impl ConnectionString {
/// ```rust
/// use azure_kusto_data::prelude::{ConnectionString, ConnectionStringAuth};
///
/// let conn = ConnectionString::from_interactive_login_auth("https://mycluster.kusto.windows.net".into());
/// let conn = ConnectionString::with_interactive_login_auth("https://mycluster.kusto.windows.net".into());
///
/// assert_eq!(conn.data_source, "https://mycluster.kusto.windows.net".to_string());
/// assert_eq!(conn.auth, ConnectionStringAuth::InteractiveLogin);
///
/// assert_eq!(conn.build(), Some("Data Source=https://mycluster.kusto.windows.net;AAD Federated Security=True;Interactive Login=True".to_string()))
/// ```
#[must_use] pub fn from_interactive_login_auth(data_source: String) -> Self {
#[must_use]
pub const fn with_interactive_login_auth(data_source: String) -> Self {
Self {
data_source,
federated_security: true,
@ -867,7 +886,7 @@ impl ConnectionString {
/// use azure_identity::DefaultAzureCredential;
/// use azure_kusto_data::prelude::{ConnectionString, ConnectionStringAuth};
///
/// let conn = ConnectionString::from_token_credential("https://mycluster.kusto.windows.net".into(), Arc::new(DefaultAzureCredential::default()));
/// let conn = ConnectionString::with_token_credential("https://mycluster.kusto.windows.net".into(), Arc::new(DefaultAzureCredential::default()));
///
/// assert_eq!(conn.data_source, "https://mycluster.kusto.windows.net".to_string());
/// assert!(matches!(conn.auth, ConnectionStringAuth::TokenCredential { .. }));
@ -875,7 +894,8 @@ impl ConnectionString {
/// // Can't be represented as a string.
/// assert_eq!(conn.build(), None)
/// ```
#[must_use] pub fn from_token_credential(
#[must_use]
pub fn with_token_credential(
data_source: String,
token_credential: Arc<dyn TokenCredential>,
) -> Self {
@ -895,10 +915,11 @@ impl ConnectionString {
/// ```rust
/// use azure_kusto_data::prelude::{ConnectionString, ConnectionStringAuth};
///
/// let conn = ConnectionString::from_user_auth("https://mycluster.kusto.windows.net".into(), "user".into(), "password".into());
/// let conn = ConnectionString::with_user_password_auth("https://mycluster.kusto.windows.net".into(), "user".into(), "password".into());
///
/// assert_eq!(conn.build(), Some("Data Source=https://mycluster.kusto.windows.net;AAD Federated Security=True;AAD User ID=user;Password=******".to_string()));
#[must_use] pub fn build(&self) -> Option<String> {
#[must_use]
pub fn build(&self) -> Option<String> {
self.build_with_options(true, false)
}
@ -908,11 +929,12 @@ impl ConnectionString {
/// ```rust
/// use azure_kusto_data::prelude::{ConnectionString, ConnectionStringAuth};
///
/// let conn = ConnectionString::from_user_auth("https://mycluster.kusto.windows.net".into(), "user".into(), "password".into());
/// let conn = ConnectionString::with_user_password_auth("https://mycluster.kusto.windows.net".into(), "user".into(), "password".into());
///
/// assert_eq!(conn.build_with_options(false, false), Some("Data Source=https://mycluster.kusto.windows.net;AAD Federated Security=True;AAD User ID=user;Password=password".to_string()));
/// assert_eq!(conn.build_with_options(false, true), Some("Data Source=https://mycluster.kusto.windows.net;AAD Federated Security=True".to_string()));
#[must_use] pub fn build_with_options(&self, safe: bool, ignore_auth: bool) -> Option<String> {
#[must_use]
pub fn build_with_options(&self, safe: bool, ignore_auth: bool) -> Option<String> {
let mut s = format!(
"{}={};{}={}",
ConnectionStringKey::DataSource.to_str(),

Просмотреть файл

@ -27,34 +27,48 @@ pub(crate) struct RequestProperties {
/// Represents the scalar data types of ADX. see [the docs for more information] https://docs.microsoft.com/en-us/azure/data-explorer/kusto/query/scalar-data-types/
#[derive(Debug, PartialEq, Eq, Serialize, Deserialize, Clone)]
#[serde(rename_all = "snake_case")]
pub enum ColumnType {
#[serde(alias = "Boolean", alias = "bool", alias = "boolean")]
/// Boolean type, true or false. Internally is a u8.
Bool,
/// Alias for `Bool`.
Boolean,
/// Datetime, represents a specific point in time.
#[serde(alias = "DateTime", alias = "datetime", alias = "Date", alias = "date")]
Datetime,
/// Alias for `Datetime`.
Date,
/// A complex type, that is either an array or a dictionary of other values.
#[serde(alias = "dynamic", alias = "Object", alias = "object")]
Dynamic,
/// GUID type, represents a globally unique identifier.
#[serde(
alias = "GUID",
alias = "guid",
alias = "UUID",
alias = "uuid",
alias = "Uuid"
)]
Guid,
#[serde(alias = "Int32", alias = "int32", alias = "int")]
/// 32 bit integer type.
Int,
/// 64 bit integer type.
#[serde(alias = "Int64", alias = "int64", alias = "long")]
Long,
/// 64 bit floating point type.
#[serde(
alias = "Real",
alias = "real",
alias = "float",
alias = "Float",
alias = "Double",
alias = "double"
)]
Real,
/// Alias for `Real`.
Double,
#[serde(alias = "string")]
/// String type, represents a string of characters.
String,
/// Timespan type, represents a duration of time.
#[serde(alias = "TimeSpan", alias = "timespan", alias = "Time", alias = "time")]
Timespan,
/// Alias for `Timespan`.
Time,
#[serde(alias = "decimal")]
/// Decimal, represents a fixed-point number with a defined precision and scale.
Decimal,
}

Просмотреть файл

@ -381,7 +381,7 @@ impl KustoResponseDataSetV2 {
///],
///};
/// let mut results = vec![];
/// for table in data_set.parsed_data_tables() {
/// for table in data_set.primary_results() {
/// results.push(format!("{} - {}", table.table_id, table.table_name));
/// }
///
@ -411,24 +411,24 @@ impl KustoResponseDataSetV2 {
/// table_id: 0,
/// table_name: "table_1".to_string(),
/// table_kind: TableKind::PrimaryResult,
/// columns: vec![Column{column_name: "col1".to_string(), column_type: ColumnType::Int64}],
/// rows: vec![vec![Value::from(3)]],
/// columns: vec![Column{column_name: "col1".to_string(), column_type: ColumnType::Long}],
/// rows: vec![vec![Value::from(3u64)]],
/// }),
/// V2QueryResult::TableHeader(TableHeader {
/// table_id: 1,
/// table_name: "table_2".to_string(),
/// table_kind: TableKind::PrimaryResult,
/// columns: vec![Column{column_name: "col1".to_string(), column_type: ColumnType::Int64}],
/// columns: vec![Column{column_name: "col1".to_string(), column_type: ColumnType::String}],
/// }),
/// V2QueryResult::TableFragment(TableFragment {
/// table_id: 1,
/// rows: vec![vec![Value::from("first")], vec![Value::from("second")]],
/// field_count: Some(2),
/// table_fragment_type: TableFragmentType::Data,
/// field_count: Some(1),
/// table_fragment_type: TableFragmentType::DataAppend,
/// }),
/// V2QueryResult::TableCompletion(TableCompletion {
/// table_id: 1,
/// row_count: 0,
/// row_count: 2,
/// }),
///],
///};
@ -554,15 +554,16 @@ mod tests {
"TableName": "Table_0",
"Columns": [{
"ColumnName": "Text",
"DataType": "String",
"ColumnType": "string"
"DataType": "String"
}],
"Rows": [["Hello, World!"]]
}]
}"#;
let parsed = serde_json::from_str::<KustoResponseDataSetV1>(data);
assert!(parsed.is_ok());
let parsed = serde_json::from_str::<KustoResponseDataSetV1>(data).expect("Failed to parse");
assert_eq!(parsed.tables[0].columns[0].column_name, "Text");
assert_eq!(parsed.tables[0].rows[0][0], "Hello, World!");
}
#[test]

Просмотреть файл

@ -69,7 +69,7 @@ pub fn create_kusto_client(transaction_name: &str) -> (KustoClient, String) {
(
KustoClient::new(
ConnectionString::from_token_credential(service_url, credential),
ConnectionString::with_token_credential(service_url, credential),
options,
)
.expect("Failed to create KustoClient"),