discivigour commented on code in PR #160: URL: https://github.com/apache/paimon-rust/pull/160#discussion_r3016403614
########## crates/paimon/src/catalog/rest/rest_catalog.rs: ########## @@ -0,0 +1,371 @@ +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + +//! REST catalog implementation for Apache Paimon. +//! +//! This module provides a REST-based catalog that communicates with +//! a Paimon REST catalog server for database and table CRUD operations. + +use std::collections::HashMap; + +use async_trait::async_trait; + +use crate::api::rest_api::RESTApi; +use crate::api::rest_error::RestError; +use crate::api::PagedList; +use crate::catalog::{Catalog, Database, Identifier, DB_LOCATION_PROP}; +use crate::common::{CatalogOptions, Options}; +use crate::error::Error; +use crate::io::FileIO; +use crate::spec::{Schema, SchemaChange, TableSchema}; +use crate::table::Table; +use crate::Result; + +use super::rest_token_file_io::RESTTokenFileIO; + +/// REST catalog implementation. +/// +/// This catalog communicates with a Paimon REST catalog server +/// for all metadata operations (database and table CRUD). +/// +/// Corresponds to Python `RESTCatalog` in `pypaimon/catalog/rest/rest_catalog.py`. +pub struct RESTCatalog { + /// The REST API client. + api: RESTApi, + /// Catalog configuration options. + options: Options, + /// Warehouse path. + warehouse: String, + /// Whether data token is enabled for FileIO construction. + data_token_enabled: bool, +} + +impl RESTCatalog { + /// Create a new REST catalog. + /// + /// # Arguments + /// * `options` - Configuration options containing URI, warehouse, etc. + /// * `config_required` - Whether to fetch config from server and merge with options. + /// + /// # Errors + /// Returns an error if required options are missing or if initialization fails. + pub async fn new(options: Options, config_required: bool) -> Result<Self> { + let warehouse = options + .get(CatalogOptions::WAREHOUSE) + .cloned() + .unwrap_or_default(); Review Comment: Good point. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
