Skip to content

Commit 158c12f

Browse files
feat: Fir 33643 replace i s databases with i s catalogs in drivers for python sdk (#392)
1 parent c804a99 commit 158c12f

File tree

4 files changed

+11
-47
lines changed

4 files changed

+11
-47
lines changed

src/firebolt/model/V2/database.py

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -33,17 +33,10 @@ class Database(FireboltBaseModel):
3333
_service: DatabaseService = field(repr=False, compare=False)
3434

3535
# required
36-
name: str = field(metadata={"db_name": "database_name"})
36+
name: str = field(metadata={"db_name": "catalog_name"})
3737
description: str = field()
38-
region: str = field()
39-
data_size_full: int = field(metadata={"db_name": "uncompressed_size"})
40-
data_size_compressed: int = field(metadata={"db_name": "compressed_size"})
41-
_attached_engine_names: str = field(
42-
repr=False, metadata={"db_name": "attached_engines"}, compare=False
43-
)
44-
create_time: datetime = field(metadata={"db_name": "created_on"})
45-
create_actor: str = field(metadata={"db_name": "created_by"})
46-
_errors: str = field(repr=False, metadata={"db_name": "errors"})
38+
create_time: datetime = field(metadata={"db_name": "created"})
39+
create_actor: str = field(metadata={"db_name": "catalog_owner"})
4740

4841
def get_attached_engines(self) -> List[Engine]:
4942
"""Get a list of engines that are attached to this database."""

src/firebolt/service/V2/database.py

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -11,18 +11,13 @@
1111

1212
class DatabaseService(BaseService):
1313
DB_FIELDS = (
14-
"database_name",
14+
"catalog_name",
1515
"description",
16-
"region",
17-
"uncompressed_size",
18-
"compressed_size",
19-
"attached_engines",
20-
"created_on",
21-
"created_by",
22-
"errors",
16+
"created",
17+
"catalog_owner",
2318
)
24-
GET_SQL = f"SELECT {', '.join(DB_FIELDS)} FROM information_schema.databases"
25-
GET_BY_NAME_SQL = GET_SQL + " WHERE database_name=?"
19+
GET_SQL = f"SELECT {', '.join(DB_FIELDS)} FROM information_schema.catalogs"
20+
GET_BY_NAME_SQL = GET_SQL + " WHERE catalog_name=?"
2621
GET_WHERE_SQL = " WHERE "
2722

2823
CREATE_PREFIX_SQL = 'CREATE DATABASE {}"{}"'
@@ -86,7 +81,7 @@ def get_many(
8681
)
8782

8883
if name_contains:
89-
sql += " WHERE database_name like ?"
84+
sql += " WHERE catalog_name like ?"
9085
parameters.append(f"%{name_contains}%")
9186

9287
with self._connection.cursor() as c:

tests/integration/resource_manager/V2/test_database.py

Lines changed: 2 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -31,19 +31,5 @@ def test_databases_get_many(
3131
with raises(ValueError):
3232
rm.databases.get_many(attached_engine_name_contains=engine_name)
3333

34-
region = [db for db in databases if db.name == database_name][0].region
35-
36-
# get all databases, with region_eq
37-
databases = rm.databases.get_many(region_eq=region)
38-
assert len(databases) > 0
39-
assert database_name in {db.name for db in databases}
40-
41-
# get all databases, with all filters
42-
kwargs = {
43-
"name_contains": database_name,
44-
"region_eq": region,
45-
}
46-
47-
databases = rm.databases.get_many(**kwargs)
48-
assert len(databases) > 0
49-
assert database_name in {db.name for db in databases}
34+
with raises(ValueError):
35+
rm.databases.get_many(region_eq="us-west-2")

tests/unit/service/conftest.py

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -65,13 +65,8 @@ def mock_database(db_name: str) -> Database:
6565
return Database(
6666
name=db_name,
6767
description="mock_db_description",
68-
region="",
69-
data_size_full=0,
70-
data_size_compressed=0,
7168
create_time=datetime.now().isoformat(),
7269
create_actor="",
73-
_attached_engine_names="-",
74-
_errors="",
7570
_service=None,
7671
)
7772

@@ -81,13 +76,8 @@ def mock_database_2() -> Database:
8176
return Database(
8277
name="database2",
8378
description="completely different db",
84-
region="",
85-
data_size_full=0,
86-
data_size_compressed=0,
8779
create_time=datetime.now().isoformat(),
8880
create_actor="",
89-
_attached_engine_names="-",
90-
_errors="",
9181
_service=None,
9282
)
9383

0 commit comments

Comments
 (0)