Skip to content

Commit

Permalink
feat: Rename catalog schema to namespace (#20993)
Browse files Browse the repository at this point in the history
  • Loading branch information
nameexhaustion authored Jan 30, 2025
1 parent 0bc6cb8 commit d68eb1a
Show file tree
Hide file tree
Showing 5 changed files with 104 additions and 105 deletions.
36 changes: 18 additions & 18 deletions crates/polars-io/src/catalog/unity/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use polars_core::prelude::PlHashMap;
use polars_core::schema::Schema;
use polars_error::{polars_bail, to_compute_err, PolarsResult};

use super::models::{CatalogInfo, SchemaInfo, TableInfo};
use super::models::{CatalogInfo, NamespaceInfo, TableInfo};
use super::utils::{do_request, PageWalker};
use crate::catalog::schema::schema_to_column_info_list;
use crate::catalog::unity::models::{ColumnInfo, DataSourceFormat, TableType};
Expand All @@ -25,7 +25,7 @@ impl CatalogClient {
.await
}

pub async fn list_schemas(&self, catalog_name: &str) -> PolarsResult<Vec<SchemaInfo>> {
pub async fn list_namespaces(&self, catalog_name: &str) -> PolarsResult<Vec<NamespaceInfo>> {
ListSchemas(PageWalker::new(
self.http_client
.get(format!(
Expand All @@ -41,15 +41,15 @@ impl CatalogClient {
pub async fn list_tables(
&self,
catalog_name: &str,
schema_name: &str,
namespace: &str,
) -> PolarsResult<Vec<TableInfo>> {
ListTables(PageWalker::new(
self.http_client
.get(format!(
"{}{}",
&self.workspace_url, "/api/2.1/unity-catalog/tables"
))
.query(&[("catalog_name", catalog_name), ("schema_name", schema_name)]),
.query(&[("catalog_name", catalog_name), ("schema_name", namespace)]),
))
.read_all_pages()
.await
Expand All @@ -58,13 +58,13 @@ impl CatalogClient {
pub async fn get_table_info(
&self,
catalog_name: &str,
schema_name: &str,
namespace: &str,
table_name: &str,
) -> PolarsResult<TableInfo> {
let full_table_name = format!(
"{}.{}.{}",
catalog_name.replace('/', "%2F"),
schema_name.replace('/', "%2F"),
namespace.replace('/', "%2F"),
table_name.replace('/', "%2F")
);

Expand Down Expand Up @@ -129,21 +129,21 @@ impl CatalogClient {
Ok(())
}

pub async fn create_schema(
pub async fn create_namespace(
&self,
catalog_name: &str,
schema_name: &str,
namespace: &str,
comment: Option<&str>,
storage_root: Option<&str>,
) -> PolarsResult<SchemaInfo> {
) -> PolarsResult<NamespaceInfo> {
let resp = do_request(
self.http_client
.post(format!(
"{}{}",
&self.workspace_url, "/api/2.1/unity-catalog/schemas"
))
.json(&Body {
name: schema_name,
name: namespace,
catalog_name,
comment,
storage_root,
Expand All @@ -162,16 +162,16 @@ impl CatalogClient {
}
}

pub async fn delete_schema(
pub async fn delete_namespace(
&self,
catalog_name: &str,
schema_name: &str,
namespace: &str,
force: bool,
) -> PolarsResult<()> {
let full_name = format!(
"{}.{}",
catalog_name.replace('/', "%2F"),
schema_name.replace('/', "%2F"),
namespace.replace('/', "%2F"),
);

do_request(
Expand All @@ -192,7 +192,7 @@ impl CatalogClient {
pub async fn create_table(
&self,
catalog_name: &str,
schema_name: &str,
namespace: &str,
table_name: &str,
schema: Option<&Schema>,
table_type: &TableType,
Expand All @@ -213,7 +213,7 @@ impl CatalogClient {
.json(&Body {
name: table_name,
catalog_name,
schema_name,
schema_name: namespace,
table_type,
data_source_format,
comment,
Expand Down Expand Up @@ -244,13 +244,13 @@ impl CatalogClient {
pub async fn delete_table(
&self,
catalog_name: &str,
schema_name: &str,
namespace: &str,
table_name: &str,
) -> PolarsResult<()> {
let full_name = format!(
"{}.{}.{}",
catalog_name.replace('/', "%2F"),
schema_name.replace('/', "%2F"),
namespace.replace('/', "%2F"),
table_name.replace('/', "%2F"),
);

Expand Down Expand Up @@ -331,7 +331,7 @@ pub struct ListCatalogs(pub(crate) PageWalker);
impl_page_walk!(ListCatalogs, CatalogInfo, key_name = catalogs);

pub struct ListSchemas(pub(crate) PageWalker);
impl_page_walk!(ListSchemas, SchemaInfo, key_name = schemas);
impl_page_walk!(ListSchemas, NamespaceInfo, key_name = schemas);

pub struct ListTables(pub(crate) PageWalker);
impl_page_walk!(ListTables, TableInfo, key_name = tables);
2 changes: 1 addition & 1 deletion crates/polars-io/src/catalog/unity/models.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ pub struct CatalogInfo {
}

#[derive(Debug, serde::Deserialize)]
pub struct SchemaInfo {
pub struct NamespaceInfo {
pub name: String,
pub comment: Option<String>,

Expand Down
Loading

0 comments on commit d68eb1a

Please sign in to comment.