Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,17 +12,17 @@ repos:
- id: check-toml

- repo: https://github.com/psf/black-pre-commit-mirror
rev: 25.12.0
rev: 26.3.1
hooks:
- id: black

- repo: https://github.com/psf/black-pre-commit-mirror
rev: 25.12.0
rev: 26.3.1
hooks:
- id: black-jupyter

- repo: https://github.com/pycqa/isort
rev: 7.0.0
rev: 8.0.1
hooks:
- id: isort
args: ["--profile", "black"]
Expand Down
6 changes: 2 additions & 4 deletions relbench/base/task_autocomplete.py
Original file line number Diff line number Diff line change
Expand Up @@ -173,8 +173,7 @@ def make_table(self, db: Database, timestamps: "pd.Series[pd.Timestamp]") -> Tab
min_timestamp = timestamp_df["timestamp"].min()
max_timestamp = timestamp_df["timestamp"].max()

df = duckdb.sql(
f"""
df = duckdb.sql(f"""
SELECT
entity_table.{self.time_col},
entity_table.{entity_col},
Expand All @@ -188,8 +187,7 @@ def make_table(self, db: Database, timestamps: "pd.Series[pd.Timestamp]") -> Tab
WHERE
entity_table.{self.time_col} > '{min_timestamp}' AND
entity_table.{self.time_col} <= '{max_timestamp}'
"""
).df()
""").df()

if self.task_type == TaskType.MULTICLASS_CLASSIFICATION:
df[self.target_col] = self.transform_target(df[self.target_col])
Expand Down
42 changes: 14 additions & 28 deletions relbench/tasks/amazon.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,7 @@ def make_table(self, db: Database, timestamps: "pd.Series[pd.Timestamp]") -> Tab
review = db.table_dict["review"].df
timestamp_df = pd.DataFrame({"timestamp": timestamps})

df = duckdb.sql(
f"""
df = duckdb.sql(f"""
SELECT
timestamp,
customer_id,
Expand All @@ -61,8 +60,7 @@ def make_table(self, db: Database, timestamps: "pd.Series[pd.Timestamp]") -> Tab
review_time > timestamp - INTERVAL '{self.timedelta}' AND
review_time <= timestamp
)
"""
).df()
""").df()

return Table(
df=df,
Expand Down Expand Up @@ -90,8 +88,7 @@ def make_table(self, db: Database, timestamps: "pd.Series[pd.Timestamp]") -> Tab
review = db.table_dict["review"].df
timestamp_df = pd.DataFrame({"timestamp": timestamps})

df = duckdb.sql(
f"""
df = duckdb.sql(f"""
SELECT
timestamp,
customer_id,
Expand Down Expand Up @@ -120,8 +117,7 @@ def make_table(self, db: Database, timestamps: "pd.Series[pd.Timestamp]") -> Tab
review_time > timestamp - INTERVAL '{self.timedelta}' AND
review_time <= timestamp
)
"""
).df()
""").df()

return Table(
df=df,
Expand Down Expand Up @@ -149,8 +145,7 @@ def make_table(self, db: Database, timestamps: "pd.Series[pd.Timestamp]") -> Tab
review = db.table_dict["review"].df
timestamp_df = pd.DataFrame({"timestamp": timestamps})

df = duckdb.sql(
f"""
df = duckdb.sql(f"""
SELECT
timestamp,
product_id,
Expand All @@ -176,8 +171,7 @@ def make_table(self, db: Database, timestamps: "pd.Series[pd.Timestamp]") -> Tab
review_time > timestamp - INTERVAL '{self.timedelta}' AND
review_time <= timestamp
)
"""
).df()
""").df()

return Table(
df=df,
Expand Down Expand Up @@ -205,8 +199,7 @@ def make_table(self, db: Database, timestamps: "pd.Series[pd.Timestamp]") -> Tab
review = db.table_dict["review"].df
timestamp_df = pd.DataFrame({"timestamp": timestamps})

df = duckdb.sql(
f"""
df = duckdb.sql(f"""
SELECT
timestamp,
product.product_id,
Expand All @@ -222,8 +215,7 @@ def make_table(self, db: Database, timestamps: "pd.Series[pd.Timestamp]") -> Tab
GROUP BY
timestamp,
product.product_id
"""
).df()
""").df()

return Table(
df=df,
Expand Down Expand Up @@ -252,8 +244,7 @@ def make_table(self, db: Database, timestamps: "pd.Series[pd.Timestamp]") -> Tab
review = db.table_dict["review"].df
timestamp_df = pd.DataFrame({"timestamp": timestamps})

df = duckdb.sql(
f"""
df = duckdb.sql(f"""
SELECT
t.timestamp,
review.customer_id,
Expand All @@ -270,8 +261,7 @@ def make_table(self, db: Database, timestamps: "pd.Series[pd.Timestamp]") -> Tab
GROUP BY
t.timestamp,
review.customer_id
"""
).df()
""").df()

return Table(
df=df,
Expand Down Expand Up @@ -303,8 +293,7 @@ def make_table(self, db: Database, timestamps: "pd.Series[pd.Timestamp]") -> Tab
review = db.table_dict["review"].df
timestamp_df = pd.DataFrame({"timestamp": timestamps})

df = duckdb.sql(
f"""
df = duckdb.sql(f"""
SELECT
t.timestamp,
review.customer_id,
Expand All @@ -323,8 +312,7 @@ def make_table(self, db: Database, timestamps: "pd.Series[pd.Timestamp]") -> Tab
GROUP BY
t.timestamp,
review.customer_id
"""
).df()
""").df()

return Table(
df=df,
Expand Down Expand Up @@ -360,8 +348,7 @@ def make_table(self, db: Database, timestamps: "pd.Series[pd.Timestamp]") -> Tab
300 # minimum length of review to be considered as detailed review
)

df = duckdb.sql(
f"""
df = duckdb.sql(f"""
SELECT
t.timestamp,
review.customer_id,
Expand All @@ -380,8 +367,7 @@ def make_table(self, db: Database, timestamps: "pd.Series[pd.Timestamp]") -> Tab
GROUP BY
t.timestamp,
review.customer_id
"""
).df()
""").df()

return Table(
df=df,
Expand Down
24 changes: 8 additions & 16 deletions relbench/tasks/arxiv.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,7 @@ def make_table(self, db: Database, timestamps: "pd.Series[pd.Timestamp]") -> Tab
papers = db.table_dict["papers"].df
citations = db.table_dict["citations"].df

df = duckdb.sql(
f"""
df = duckdb.sql(f"""
WITH paper_citations AS (
SELECT
t.timestamp AS date,
Expand All @@ -54,8 +53,7 @@ def make_table(self, db: Database, timestamps: "pd.Series[pd.Timestamp]") -> Tab
Paper_ID,
CASE WHEN citation_count > 0 THEN 1 ELSE 0 END AS cited
FROM paper_citations;
"""
).df()
""").df()

return Table(
df=df,
Expand Down Expand Up @@ -88,8 +86,7 @@ def make_table(self, db: Database, timestamps: "pd.Series[pd.Timestamp]") -> Tab
paperCategories = db.table_dict["paperCategories"].df
categories = db.table_dict["categories"].df

df = duckdb.sql(
f"""
df = duckdb.sql(f"""
WITH author_pubs AS (
SELECT
t.timestamp AS date,
Expand Down Expand Up @@ -127,8 +124,7 @@ def make_table(self, db: Database, timestamps: "pd.Series[pd.Timestamp]") -> Tab
LEFT JOIN categories c ON r.Primary_Category_ID = c.Category_ID
WHERE r.rn = 1
;
"""
).df()
""").df()

return Table(
df=df,
Expand All @@ -154,8 +150,7 @@ def make_table(self, db: Database, timestamps: "pd.Series[pd.Timestamp]") -> Tab
timestamp_df = pd.DataFrame({"timestamp": timestamps})
paperAuthors = db.table_dict["paperAuthors"].df

df = duckdb.sql(
f"""
df = duckdb.sql(f"""
WITH author_pubs AS (
SELECT
t.timestamp AS date,
Expand All @@ -168,8 +163,7 @@ def make_table(self, db: Database, timestamps: "pd.Series[pd.Timestamp]") -> Tab
GROUP BY t.timestamp, pa.Author_ID
)
SELECT date, Author_ID, publication_count FROM author_pubs;
"""
).df()
""").df()

return Table(
df=df,
Expand Down Expand Up @@ -199,8 +193,7 @@ def make_table(self, db: Database, timestamps: "pd.Series[pd.Timestamp]") -> Tab
papers = db.table_dict["papers"].df
citations = db.table_dict["citations"].df

df = duckdb.sql(
f"""
df = duckdb.sql(f"""
WITH paper_co_citations AS (
SELECT
t.timestamp AS date,
Expand All @@ -226,8 +219,7 @@ def make_table(self, db: Database, timestamps: "pd.Series[pd.Timestamp]") -> Tab
FROM paper_co_citations
GROUP BY date, Paper_ID
;
"""
).df()
""").df()

return Table(
df=df,
Expand Down
24 changes: 8 additions & 16 deletions relbench/tasks/avito.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,7 @@ def make_table(self, db: Database, timestamps: "pd.Series[pd.Timestamp]") -> Tab
ads_info = db.table_dict["AdsInfo"].df
search_stream = db.table_dict["SearchStream"].df
timestamp_df = pd.DataFrame({"timestamp": timestamps})
df = duckdb.sql(
f"""
df = duckdb.sql(f"""
SELECT
search_ads.AdID,
t.timestamp,
Expand All @@ -55,8 +54,7 @@ def make_table(self, db: Database, timestamps: "pd.Series[pd.Timestamp]") -> Tab
search_ads.AdID
HAVING
SUM(search_ads.isClick) > 0
"""
).df()
""").df()

return Table(
df=df,
Expand All @@ -81,8 +79,7 @@ def make_table(self, db: Database, timestamps: "pd.Series[pd.Timestamp]") -> Tab
user_info = db.table_dict["UserInfo"].df
visits_stream = db.table_dict["VisitStream"].df
timestamp_df = pd.DataFrame({"timestamp": timestamps})
df = duckdb.sql(
f"""
df = duckdb.sql(f"""
SELECT
visit_ads.UserID,
t.timestamp,
Expand All @@ -103,8 +100,7 @@ def make_table(self, db: Database, timestamps: "pd.Series[pd.Timestamp]") -> Tab
GROUP BY
t.timestamp,
visit_ads.UserID
"""
).df()
""").df()

return Table(
df=df,
Expand All @@ -131,8 +127,7 @@ def make_table(self, db: Database, timestamps: "pd.Series[pd.Timestamp]") -> Tab
search_info = db.table_dict["SearchInfo"].df
search_stream = db.table_dict["SearchStream"].df
timestamp_df = pd.DataFrame({"timestamp": timestamps})
df = duckdb.sql(
f"""
df = duckdb.sql(f"""
SELECT
search_ads.UserID,
t.timestamp,
Expand Down Expand Up @@ -160,8 +155,7 @@ def make_table(self, db: Database, timestamps: "pd.Series[pd.Timestamp]") -> Tab
GROUP BY
t.timestamp,
search_ads.UserID
"""
).df()
""").df()

return Table(
df=df,
Expand Down Expand Up @@ -191,8 +185,7 @@ def make_table(self, db: Database, timestamps: "pd.Series[pd.Timestamp]") -> Tab
visits_stream = db.table_dict["VisitStream"].df
timestamp_df = pd.DataFrame({"timestamp": timestamps})

df = duckdb.sql(
f"""
df = duckdb.sql(f"""
SELECT
visit_ads.UserID,
t.timestamp,
Expand All @@ -213,8 +206,7 @@ def make_table(self, db: Database, timestamps: "pd.Series[pd.Timestamp]") -> Tab
GROUP BY
t.timestamp,
visit_ads.UserID
"""
).df()
""").df()
return Table(
df=df,
fkey_col_to_pkey_table={
Expand Down
Loading
Loading