Skip to content

Commit 8206167

Browse files
committed
fix: parse pg array correctly
1 parent 41ad77b commit 8206167

1 file changed

Lines changed: 7 additions & 1 deletion

File tree

main.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,12 @@ def read_table_from_postgres(settings: PostgresSettings) -> pd.DataFrame:
6565
return pd.read_sql(query, engine)
6666

6767

68+
def parse_pg_array(val):
69+
if isinstance(val, str):
70+
return val.strip("{}").split(",")
71+
return val
72+
73+
6874
@entrypoint(LDATopicModeling)
6975
def lda_topic_modeling(settings):
7076
logger.info("Starting LDA topic modeling pipeline…")
@@ -75,7 +81,7 @@ def lda_topic_modeling(settings):
7581
preprocessed_docs = [
7682
PreprocessedDocument(
7783
doc_id=row["doc_id"],
78-
tokens=row["tokens"]
84+
tokens=parse_pg_array(row["tokens"])
7985
)
8086
for _, row in normalized_docs.iterrows()
8187
]

0 commit comments

Comments
 (0)