Skip to content

Commit

Permalink
chore: Enable new rust code format settings (#483)
Browse files Browse the repository at this point in the history
* chore: Enable new format settings

Signed-off-by: Xuanwo <github@xuanwo.io>

* Format

Signed-off-by: Xuanwo <github@xuanwo.io>

---------

Signed-off-by: Xuanwo <github@xuanwo.io>
  • Loading branch information
Xuanwo committed Jul 26, 2024
1 parent 36e128c commit 5b3d1d3
Show file tree
Hide file tree
Showing 67 changed files with 941 additions and 1,164 deletions.
5 changes: 3 additions & 2 deletions crates/catalog/glue/src/catalog.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@
// specific language governing permissions and limitations
// under the License.

use std::collections::HashMap;
use std::fmt::Debug;

use async_trait::async_trait;
use aws_sdk_glue::types::TableInput;
use iceberg::io::FileIO;
Expand All @@ -24,8 +27,6 @@ use iceberg::{
Catalog, Error, ErrorKind, Namespace, NamespaceIdent, Result, TableCommit, TableCreation,
TableIdent,
};
use std::{collections::HashMap, fmt::Debug};

use typed_builder::TypedBuilder;

use crate::error::{from_aws_build_error, from_aws_sdk_error};
Expand Down
6 changes: 2 additions & 4 deletions crates/catalog/glue/src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,16 +15,14 @@
// specific language governing permissions and limitations
// under the License.

use anyhow::anyhow;
use std::fmt::Debug;

use anyhow::anyhow;
use iceberg::{Error, ErrorKind};

/// Format AWS SDK error into iceberg error
pub(crate) fn from_aws_sdk_error<T>(error: aws_sdk_glue::error::SdkError<T>) -> Error
where
T: Debug,
{
where T: Debug {
Error::new(
ErrorKind::Unexpected,
"Operation failed for hitting aws skd error".to_string(),
Expand Down
13 changes: 4 additions & 9 deletions crates/catalog/glue/src/schema.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,9 @@ pub(crate) const ICEBERG_FIELD_CURRENT: &str = "iceberg.field.current";

use std::collections::HashMap;

use iceberg::{
spec::{visit_schema, PrimitiveType, SchemaVisitor, TableMetadata},
Error, ErrorKind, Result,
};

use aws_sdk_glue::types::Column;
use iceberg::spec::{visit_schema, PrimitiveType, SchemaVisitor, TableMetadata};
use iceberg::{Error, ErrorKind, Result};

use crate::error::from_aws_build_error;

Expand Down Expand Up @@ -188,10 +185,8 @@ impl SchemaVisitor for GlueSchemaBuilder {

#[cfg(test)]
mod tests {
use iceberg::{
spec::{Schema, TableMetadataBuilder},
TableCreation,
};
use iceberg::spec::{Schema, TableMetadataBuilder};
use iceberg::TableCreation;

use super::*;

Expand Down
21 changes: 9 additions & 12 deletions crates/catalog/glue/src/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,14 @@
use std::collections::HashMap;

use aws_config::{BehaviorVersion, Region, SdkConfig};
use aws_sdk_glue::{
config::Credentials,
types::{Database, DatabaseInput, StorageDescriptor, TableInput},
};
use aws_sdk_glue::config::Credentials;
use aws_sdk_glue::types::{Database, DatabaseInput, StorageDescriptor, TableInput};
use iceberg::spec::TableMetadata;
use iceberg::{Error, ErrorKind, Namespace, NamespaceIdent, Result};
use uuid::Uuid;

use crate::{error::from_aws_build_error, schema::GlueSchemaBuilder};
use crate::error::from_aws_build_error;
use crate::schema::GlueSchemaBuilder;

/// Property aws profile name
pub const AWS_PROFILE_NAME: &str = "profile_name";
Expand Down Expand Up @@ -286,15 +285,13 @@ macro_rules! with_catalog_id {

#[cfg(test)]
mod tests {
use aws_sdk_glue::{config::ProvideCredentials, types::Column};
use iceberg::{
spec::{NestedField, PrimitiveType, Schema, TableMetadataBuilder, Type},
Namespace, Result, TableCreation,
};

use crate::schema::{ICEBERG_FIELD_CURRENT, ICEBERG_FIELD_ID, ICEBERG_FIELD_OPTIONAL};
use aws_sdk_glue::config::ProvideCredentials;
use aws_sdk_glue::types::Column;
use iceberg::spec::{NestedField, PrimitiveType, Schema, TableMetadataBuilder, Type};
use iceberg::{Namespace, Result, TableCreation};

use super::*;
use crate::schema::{ICEBERG_FIELD_CURRENT, ICEBERG_FIELD_ID, ICEBERG_FIELD_OPTIONAL};

fn create_metadata(schema: Schema) -> Result<TableMetadata> {
let table_creation = TableCreation::builder()
Expand Down
23 changes: 11 additions & 12 deletions crates/catalog/hms/src/catalog.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,30 +15,29 @@
// specific language governing permissions and limitations
// under the License.

use crate::error::from_thrift_error;
use crate::error::{from_io_error, from_thrift_exception};
use std::collections::HashMap;
use std::fmt::{Debug, Formatter};
use std::net::ToSocketAddrs;

use super::utils::*;
use anyhow::anyhow;
use async_trait::async_trait;
use hive_metastore::ThriftHiveMetastoreClient;
use hive_metastore::ThriftHiveMetastoreClientBuilder;
use hive_metastore::ThriftHiveMetastoreGetDatabaseException;
use hive_metastore::ThriftHiveMetastoreGetTableException;
use hive_metastore::{
ThriftHiveMetastoreClient, ThriftHiveMetastoreClientBuilder,
ThriftHiveMetastoreGetDatabaseException, ThriftHiveMetastoreGetTableException,
};
use iceberg::io::FileIO;
use iceberg::spec::TableMetadata;
use iceberg::spec::TableMetadataBuilder;
use iceberg::spec::{TableMetadata, TableMetadataBuilder};
use iceberg::table::Table;
use iceberg::{
Catalog, Error, ErrorKind, Namespace, NamespaceIdent, Result, TableCommit, TableCreation,
TableIdent,
};
use std::collections::HashMap;
use std::fmt::{Debug, Formatter};
use std::net::ToSocketAddrs;
use typed_builder::TypedBuilder;
use volo_thrift::MaybeException;

use super::utils::*;
use crate::error::{from_io_error, from_thrift_error, from_thrift_exception};

/// Which variant of the thrift transport to communicate with HMS
/// See: <https://github.com/apache/thrift/blob/master/doc/specs/thrift-rpc.md#framed-vs-unframed-transport>
#[derive(Debug, Default)]
Expand Down
5 changes: 3 additions & 2 deletions crates/catalog/hms/src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,11 @@
// specific language governing permissions and limitations
// under the License.

use anyhow::anyhow;
use iceberg::{Error, ErrorKind};
use std::fmt::Debug;
use std::io;

use anyhow::anyhow;
use iceberg::{Error, ErrorKind};
use volo_thrift::MaybeException;

/// Format a thrift error into iceberg error.
Expand Down
3 changes: 2 additions & 1 deletion crates/catalog/hms/src/schema.rs
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,8 @@ impl SchemaVisitor for HiveSchemaBuilder {

#[cfg(test)]
mod tests {
use iceberg::{spec::Schema, Result};
use iceberg::spec::Schema;
use iceberg::Result;

use super::*;

Expand Down
12 changes: 6 additions & 6 deletions crates/catalog/hms/src/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,13 @@
// specific language governing permissions and limitations
// under the License.

use std::collections::HashMap;

use chrono::Utc;
use hive_metastore::{Database, PrincipalType, SerDeInfo, StorageDescriptor};
use iceberg::{spec::Schema, Error, ErrorKind, Namespace, NamespaceIdent, Result};
use iceberg::spec::Schema;
use iceberg::{Error, ErrorKind, Namespace, NamespaceIdent, Result};
use pilota::{AHashMap, FastStr};
use std::collections::HashMap;
use uuid::Uuid;

use crate::schema::HiveSchemaBuilder;
Expand Down Expand Up @@ -336,10 +338,8 @@ fn get_current_time() -> Result<i32> {

#[cfg(test)]
mod tests {
use iceberg::{
spec::{NestedField, PrimitiveType, Type},
Namespace, NamespaceIdent,
};
use iceberg::spec::{NestedField, PrimitiveType, Type};
use iceberg::{Namespace, NamespaceIdent};

use super::*;

Expand Down
8 changes: 4 additions & 4 deletions crates/catalog/hms/tests/hms_catalog_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -235,10 +235,10 @@ async fn test_list_tables() -> Result<()> {
catalog.create_table(ns.name(), creation).await?;
let result = catalog.list_tables(ns.name()).await?;

assert_eq!(
result,
vec![TableIdent::new(ns.name().clone(), "my_table".to_string())]
);
assert_eq!(result, vec![TableIdent::new(
ns.name().clone(),
"my_table".to_string()
)]);

Ok(())
}
Expand Down
23 changes: 13 additions & 10 deletions crates/catalog/rest/src/catalog.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,16 @@ use std::collections::HashMap;
use std::str::FromStr;

use async_trait::async_trait;
use iceberg::io::FileIO;
use iceberg::table::Table;
use iceberg::{
Catalog, Error, ErrorKind, Namespace, NamespaceIdent, Result, TableCommit, TableCreation,
TableIdent,
};
use itertools::Itertools;
use reqwest::header::{self, HeaderMap, HeaderName, HeaderValue};
use reqwest::header::{
HeaderMap, HeaderName, HeaderValue, {self},
};
use reqwest::{Method, StatusCode, Url};
use tokio::sync::OnceCell;
use typed_builder::TypedBuilder;
Expand All @@ -33,12 +41,6 @@ use crate::types::{
ListNamespaceResponse, ListTableResponse, LoadTableResponse, NamespaceSerde,
RenameTableRequest, NO_CONTENT, OK,
};
use iceberg::io::FileIO;
use iceberg::table::Table;
use iceberg::Result;
use iceberg::{
Catalog, Error, ErrorKind, Namespace, NamespaceIdent, TableCommit, TableCreation, TableIdent,
};

const ICEBERG_REST_SPEC_VERSION: &str = "0.14.1";
const CARGO_PKG_VERSION: &str = env!("CARGO_PKG_VERSION");
Expand Down Expand Up @@ -670,6 +672,10 @@ impl Catalog for RestCatalog {

#[cfg(test)]
mod tests {
use std::fs::File;
use std::io::BufReader;
use std::sync::Arc;

use chrono::{TimeZone, Utc};
use iceberg::spec::{
FormatVersion, NestedField, NullOrder, Operation, PrimitiveType, Schema, Snapshot,
Expand All @@ -679,9 +685,6 @@ mod tests {
use iceberg::transaction::Transaction;
use mockito::{Mock, Server, ServerGuard};
use serde_json::json;
use std::fs::File;
use std::io::BufReader;
use std::sync::Arc;
use uuid::uuid;

use super::*;
Expand Down
15 changes: 8 additions & 7 deletions crates/catalog/rest/src/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,17 +15,18 @@
// specific language governing permissions and limitations
// under the License.

use crate::types::{ErrorResponse, TokenResponse, OK};
use crate::RestCatalogConfig;
use iceberg::Result;
use iceberg::{Error, ErrorKind};
use reqwest::header::HeaderMap;
use reqwest::{Client, IntoUrl, Method, Request, RequestBuilder, Response};
use serde::de::DeserializeOwned;
use std::collections::HashMap;
use std::fmt::{Debug, Formatter};
use std::sync::Mutex;

use iceberg::{Error, ErrorKind, Result};
use reqwest::header::HeaderMap;
use reqwest::{Client, IntoUrl, Method, Request, RequestBuilder, Response};
use serde::de::DeserializeOwned;

use crate::types::{ErrorResponse, TokenResponse, OK};
use crate::RestCatalogConfig;

pub(crate) struct HttpClient {
client: Client,

Expand Down
3 changes: 1 addition & 2 deletions crates/catalog/rest/src/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,11 @@

use std::collections::HashMap;

use serde_derive::{Deserialize, Serialize};

use iceberg::spec::{Schema, SortOrder, TableMetadata, UnboundPartitionSpec};
use iceberg::{
Error, ErrorKind, Namespace, NamespaceIdent, TableIdent, TableRequirement, TableUpdate,
};
use serde_derive::{Deserialize, Serialize};

pub(super) const OK: u16 = 200u16;
pub(super) const NO_CONTENT: u16 = 204u16;
Expand Down
5 changes: 3 additions & 2 deletions crates/catalog/rest/tests/rest_catalog_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@

//! Integration tests for rest catalog.

use std::collections::HashMap;
use std::sync::RwLock;

use ctor::{ctor, dtor};
use iceberg::spec::{FormatVersion, NestedField, PrimitiveType, Schema, Type};
use iceberg::transaction::Transaction;
Expand All @@ -25,8 +28,6 @@ use iceberg_catalog_rest::{RestCatalog, RestCatalogConfig};
use iceberg_test_utils::docker::DockerCompose;
use iceberg_test_utils::{normalize_test_name, set_up};
use port_scanner::scan_port_addr;
use std::collections::HashMap;
use std::sync::RwLock;
use tokio::time::sleep;

const REST_CATALOG_PORT: u16 = 8181;
Expand Down
3 changes: 2 additions & 1 deletion crates/examples/src/rest_catalog_namespace.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,10 @@
// specific language governing permissions and limitations
// under the License.

use std::collections::HashMap;

use iceberg::{Catalog, NamespaceIdent};
use iceberg_catalog_rest::{RestCatalog, RestCatalogConfig};
use std::collections::HashMap;

#[tokio::main]
async fn main() {
Expand Down
3 changes: 2 additions & 1 deletion crates/examples/src/rest_catalog_table.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,11 @@
// specific language governing permissions and limitations
// under the License.

use std::collections::HashMap;

use iceberg::spec::{NestedField, PrimitiveType, Schema, Type};
use iceberg::{Catalog, TableCreation, TableIdent};
use iceberg_catalog_rest::{RestCatalog, RestCatalogConfig};
use std::collections::HashMap;

#[tokio::main]
async fn main() {
Expand Down
16 changes: 9 additions & 7 deletions crates/iceberg/src/arrow/reader.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,11 @@

//! Parquet file data reader

use crate::error::Result;
use std::collections::{HashMap, HashSet};
use std::ops::Range;
use std::str::FromStr;
use std::sync::Arc;

use arrow_arith::boolean::{and, is_not_null, is_null, not, or};
use arrow_array::{ArrayRef, BooleanArray, RecordBatch};
use arrow_ord::cmp::{eq, gt, gt_eq, lt, lt_eq, neq};
Expand All @@ -34,12 +38,9 @@ use parquet::arrow::async_reader::{AsyncFileReader, MetadataLoader};
use parquet::arrow::{ParquetRecordBatchStreamBuilder, ProjectionMask, PARQUET_FIELD_ID_META_KEY};
use parquet::file::metadata::ParquetMetaData;
use parquet::schema::types::{SchemaDescriptor, Type as ParquetType};
use std::collections::{HashMap, HashSet};
use std::ops::Range;
use std::str::FromStr;
use std::sync::Arc;

use crate::arrow::{arrow_schema_to_schema, get_arrow_datum};
use crate::error::Result;
use crate::expr::visitors::bound_predicate_visitor::{visit, BoundPredicateVisitor};
use crate::expr::{BoundPredicate, BoundReference};
use crate::io::{FileIO, FileMetadata, FileRead};
Expand Down Expand Up @@ -859,12 +860,13 @@ impl<R: FileRead> AsyncFileReader for ArrowFileReader<R> {

#[cfg(test)]
mod tests {
use std::collections::HashSet;
use std::sync::Arc;

use crate::arrow::reader::CollectFieldIdVisitor;
use crate::expr::visitors::bound_predicate_visitor::visit;
use crate::expr::{Bind, Reference};
use crate::spec::{NestedField, PrimitiveType, Schema, SchemaRef, Type};
use std::collections::HashSet;
use std::sync::Arc;

fn table_schema_simple() -> SchemaRef {
Arc::new(
Expand Down
Loading

0 comments on commit 5b3d1d3

Please sign in to comment.