Skip to content

Commit f9bed6e

Browse files
committed
fix postgres metadata col naming and channel init
1 parent ac90d22 commit f9bed6e

File tree

5 files changed

+14
-15
lines changed

5 files changed

+14
-15
lines changed

cosmotech/coal/postgresql/runner.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ def send_runner_metadata_to_postgresql(
5151
CREATE TABLE IF NOT EXISTS {schema_table} (
5252
id varchar(32) PRIMARY KEY,
5353
name varchar(256),
54-
last_run_id varchar(32),
54+
last_csm_run_id varchar(32),
5555
run_template_id varchar(32)
5656
);
5757
"""
@@ -60,11 +60,11 @@ def send_runner_metadata_to_postgresql(
6060
conn.commit()
6161
LOGGER.info(T("coal.services.postgresql.metadata"))
6262
sql_upsert = f"""
63-
INSERT INTO {schema_table} (id, name, last_run_id, run_template_id)
63+
INSERT INTO {schema_table} (id, name, last_csm_run_id, run_template_id)
6464
VALUES(%s, %s, %s, %s)
6565
ON CONFLICT (id)
6666
DO
67-
UPDATE SET name = EXCLUDED.name, last_run_id = EXCLUDED.last_run_id;
67+
UPDATE SET name = EXCLUDED.name, last_csm_run_id = EXCLUDED.last_csm_run_id;
6868
"""
6969
curs.execute(
7070
sql_upsert,
@@ -108,7 +108,7 @@ def remove_runner_metadata_from_postgresql(
108108
schema_table = f"{_psql.db_schema}.{_psql.table_prefix}RunnerMetadata"
109109
sql_delete_from_metatable = f"""
110110
DELETE FROM {schema_table}
111-
WHERE last_run_id={runner.get("lastRunId")};
111+
WHERE last_csm_run_id={runner.get("lastRunId")};
112112
"""
113113
curs.execute(sql_delete_from_metatable)
114114
conn.commit()

cosmotech/coal/postgresql/store.py

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,6 @@ def dump_store_to_postgresql_from_conf(
8686
fk_id: foreign key id to add to all table on all rows
8787
"""
8888
_psql = PostgresUtils(configuration)
89-
print(_psql.send_pyarrow_table_to_postgresql)
9089
_s = Store(store_location=store_folder)
9190

9291
tables = list(_s.list_tables())
@@ -103,9 +102,9 @@ def dump_store_to_postgresql_from_conf(
103102
if fk_id:
104103
_s.execute_query(
105104
f"""
106-
ALTER TABLE {_psql.table_prefix}{table_name}
107-
ADD run_id TEXT NOT NULL
108-
DEFAULT ({fk_id})
105+
ALTER TABLE {table_name}
106+
ADD csm_run_id TEXT NOT NULL
107+
DEFAULT ('{fk_id})
109108
"""
110109
)
111110
data = _s.get_table(table_name)
@@ -120,7 +119,7 @@ def dump_store_to_postgresql_from_conf(
120119
)
121120
if fk_id and _psql.is_metadata_exists():
122121
metadata_table = f"{_psql.table_prefix}RunnerMetadata"
123-
_psql.add_fk_constraint(table_name, "run_id", metadata_table, "last_run_id")
122+
_psql.add_fk_constraint(table_name, "csm_run_id", metadata_table, "last_csm_run_id")
124123

125124
total_rows += rows
126125
_up_time = perf_counter()

cosmotech/coal/store/output/aws_channel.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
from cosmotech.coal.aws import S3
99
from cosmotech.coal.store.output.channel_interface import ChannelInterface
1010
from cosmotech.coal.store.store import Store
11-
from cosmotech.coal.utils.configuration import Configuration
11+
from cosmotech.coal.utils.configuration import Configuration, Dotdict
1212
from cosmotech.coal.utils.logger import LOGGER
1313

1414

@@ -21,7 +21,7 @@ class AwsChannel(ChannelInterface):
2121
}
2222
requirement_string = required_keys
2323

24-
def __init__(self, dct: dict = None):
24+
def __init__(self, dct: Dotdict = None):
2525
self.configuration = Configuration(dct)
2626
self._s3 = S3(self.configuration)
2727

cosmotech/coal/store/output/az_storage_channel.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
from cosmotech.coal.azure.blob import dump_store_to_azure
44
from cosmotech.coal.store.output.channel_interface import ChannelInterface
5-
from cosmotech.coal.utils.configuration import Configuration
5+
from cosmotech.coal.utils.configuration import Configuration, Dotdict
66

77

88
class AzureStorageChannel(ChannelInterface):
@@ -22,7 +22,7 @@ class AzureStorageChannel(ChannelInterface):
2222
}
2323
requirement_string = required_keys
2424

25-
def __init__(self, dct: dict = None):
25+
def __init__(self, dct: Dotdict = None):
2626
self.configuration = Configuration(dct)
2727

2828
def send(self, tables_filter: Optional[list[str]] = None) -> bool:

cosmotech/coal/store/output/postgres_channel.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
)
77
from cosmotech.coal.postgresql.store import dump_store_to_postgresql_from_conf
88
from cosmotech.coal.store.output.channel_interface import ChannelInterface
9-
from cosmotech.coal.utils.configuration import Configuration
9+
from cosmotech.coal.utils.configuration import Configuration, Dotdict
1010

1111

1212
class PostgresChannel(ChannelInterface):
@@ -23,7 +23,7 @@ class PostgresChannel(ChannelInterface):
2323
}
2424
requirement_string = required_keys
2525

26-
def __init__(self, dct: dict = None):
26+
def __init__(self, dct: Dotdict = None):
2727
self.configuration = Configuration(dct)
2828

2929
def send(self, tables_filter: Optional[list[str]] = None) -> bool:

0 commit comments

Comments
 (0)