Skip to content

Conversation

@rivudhk
Copy link
Contributor

@rivudhk rivudhk commented Dec 24, 2025

Fixes: #4901

Copilot AI review requested due to automatic review settings December 24, 2025 16:32
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR adds comprehensive test coverage for AS OF joins with various ON clause configurations, addressing issue #4901. The tests validate different scenarios including multiple joins, complex conditions, aggregations, and error handling.

Key Changes:

  • Added new test file with 7 test classes covering different AS OF join ON clause patterns
  • Added validation for illegal ON clause usage (non-equality comparisons)
  • Integrated new tests into the test suite via main.py import

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 5 comments.

File Description
python/tests/runtime_aggtest/asof_tests/test_asof_multi_on.py New test file containing 7 test classes for AS OF joins with various ON clause scenarios including multi-joins, complex types, aggregations, and computed values
python/tests/runtime_aggtest/asof_tests/test_asof_illarg.py Added test case for illegal ON clause condition (inequality comparison) to validate error handling
python/tests/runtime_aggtest/asof_tests/main.py Imported new test module to include it in test execution

from tests.runtime_aggtest.aggtst_base import TstView


class asof_multi_asof(TstView):
Copy link

Copilot AI Dec 24, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Class name 'asof_multi_asof' contains redundant 'asof' repetition. Consider renaming to 'asof_multi_join' or 'multi_asof_join' for clarity.

Suggested change
class asof_multi_asof(TstView):
class asof_multi_join(TstView):

Copilot uses AI. Check for mistakes.
{"id": 4, "t1_intt": 25, "t2_intt": None},
{"id": 5, "t1_intt": None, "t2_intt": None},
]
self.sql = """CREATE MATERIALIZED VIEW asof_multiasof AS SELECT
Copy link

Copilot AI Dec 24, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

View name 'asof_multiasof' should match the class name pattern or use underscores consistently. Consider 'asof_multi_asof' to match the class naming convention.

Suggested change
self.sql = """CREATE MATERIALIZED VIEW asof_multiasof AS SELECT
self.sql = """CREATE MATERIALIZED VIEW asof_multi_asof AS SELECT

Copilot uses AI. Check for mistakes.
Comment on lines 99 to 118
{"id": 1, "t1_intt": 10, "intervall": 20},
{"id": 2, "t1_intt": 15, "intervall": 2},
{"id": 3, "t1_intt": 20, "intervall": -1},
{"id": 4, "t1_intt": 25, "intervall": -1},
{"id": 5, "t1_intt": None, "intervall": None},
]
self.sql = """CREATE MATERIALIZED VIEW asof_computed_int_on AS
WITH joined AS (
SELECT t1.id,
t1.intt AS t1_intt,
t2.intt AS t2_intt,
TIMESTAMPDIFF(YEAR, t1.tmestmp, t2.tmestmp) AS intervall
FROM asof_tbl1 t1
JOIN asof_tbl2 t2
ON t1.id = t2.id
)
SELECT j.id, j.t1_intt, intervall
FROM joined j
LEFT ASOF JOIN asof_tbl3 t3
MATCH_CONDITION (j.intervall >= t3.intt)
Copy link

Copilot AI Dec 24, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Corrected spelling of 'intervall' to 'interval'.

Suggested change
{"id": 1, "t1_intt": 10, "intervall": 20},
{"id": 2, "t1_intt": 15, "intervall": 2},
{"id": 3, "t1_intt": 20, "intervall": -1},
{"id": 4, "t1_intt": 25, "intervall": -1},
{"id": 5, "t1_intt": None, "intervall": None},
]
self.sql = """CREATE MATERIALIZED VIEW asof_computed_int_on AS
WITH joined AS (
SELECT t1.id,
t1.intt AS t1_intt,
t2.intt AS t2_intt,
TIMESTAMPDIFF(YEAR, t1.tmestmp, t2.tmestmp) AS intervall
FROM asof_tbl1 t1
JOIN asof_tbl2 t2
ON t1.id = t2.id
)
SELECT j.id, j.t1_intt, intervall
FROM joined j
LEFT ASOF JOIN asof_tbl3 t3
MATCH_CONDITION (j.intervall >= t3.intt)
{"id": 1, "t1_intt": 10, "interval": 20},
{"id": 2, "t1_intt": 15, "interval": 2},
{"id": 3, "t1_intt": 20, "interval": -1},
{"id": 4, "t1_intt": 25, "interval": -1},
{"id": 5, "t1_intt": None, "interval": None},
]
self.sql = """CREATE MATERIALIZED VIEW asof_computed_int_on AS
WITH joined AS (
SELECT t1.id,
t1.intt AS t1_intt,
t2.intt AS t2_intt,
TIMESTAMPDIFF(YEAR, t1.tmestmp, t2.tmestmp) AS interval
FROM asof_tbl1 t1
JOIN asof_tbl2 t2
ON t1.id = t2.id
)
SELECT j.id, j.t1_intt, interval
FROM joined j
LEFT ASOF JOIN asof_tbl3 t3
MATCH_CONDITION (j.interval >= t3.intt)

Copilot uses AI. Check for mistakes.
Comment on lines 99 to 118
{"id": 1, "t1_intt": 10, "intervall": 20},
{"id": 2, "t1_intt": 15, "intervall": 2},
{"id": 3, "t1_intt": 20, "intervall": -1},
{"id": 4, "t1_intt": 25, "intervall": -1},
{"id": 5, "t1_intt": None, "intervall": None},
]
self.sql = """CREATE MATERIALIZED VIEW asof_computed_int_on AS
WITH joined AS (
SELECT t1.id,
t1.intt AS t1_intt,
t2.intt AS t2_intt,
TIMESTAMPDIFF(YEAR, t1.tmestmp, t2.tmestmp) AS intervall
FROM asof_tbl1 t1
JOIN asof_tbl2 t2
ON t1.id = t2.id
)
SELECT j.id, j.t1_intt, intervall
FROM joined j
LEFT ASOF JOIN asof_tbl3 t3
MATCH_CONDITION (j.intervall >= t3.intt)
Copy link

Copilot AI Dec 24, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Field name 'intervall' is misspelled. Should be 'interval' to match standard SQL terminology.

Suggested change
{"id": 1, "t1_intt": 10, "intervall": 20},
{"id": 2, "t1_intt": 15, "intervall": 2},
{"id": 3, "t1_intt": 20, "intervall": -1},
{"id": 4, "t1_intt": 25, "intervall": -1},
{"id": 5, "t1_intt": None, "intervall": None},
]
self.sql = """CREATE MATERIALIZED VIEW asof_computed_int_on AS
WITH joined AS (
SELECT t1.id,
t1.intt AS t1_intt,
t2.intt AS t2_intt,
TIMESTAMPDIFF(YEAR, t1.tmestmp, t2.tmestmp) AS intervall
FROM asof_tbl1 t1
JOIN asof_tbl2 t2
ON t1.id = t2.id
)
SELECT j.id, j.t1_intt, intervall
FROM joined j
LEFT ASOF JOIN asof_tbl3 t3
MATCH_CONDITION (j.intervall >= t3.intt)
{"id": 1, "t1_intt": 10, "interval": 20},
{"id": 2, "t1_intt": 15, "interval": 2},
{"id": 3, "t1_intt": 20, "interval": -1},
{"id": 4, "t1_intt": 25, "interval": -1},
{"id": 5, "t1_intt": None, "interval": None},
]
self.sql = """CREATE MATERIALIZED VIEW asof_computed_int_on AS
WITH joined AS (
SELECT t1.id,
t1.intt AS t1_intt,
t2.intt AS t2_intt,
TIMESTAMPDIFF(YEAR, t1.tmestmp, t2.tmestmp) AS interval
FROM asof_tbl1 t1
JOIN asof_tbl2 t2
ON t1.id = t2.id
)
SELECT j.id, j.t1_intt, interval
FROM joined j
LEFT ASOF JOIN asof_tbl3 t3
MATCH_CONDITION (j.interval >= t3.intt)

Copilot uses AI. Check for mistakes.
Comment on lines 99 to 118
{"id": 1, "t1_intt": 10, "intervall": 20},
{"id": 2, "t1_intt": 15, "intervall": 2},
{"id": 3, "t1_intt": 20, "intervall": -1},
{"id": 4, "t1_intt": 25, "intervall": -1},
{"id": 5, "t1_intt": None, "intervall": None},
]
self.sql = """CREATE MATERIALIZED VIEW asof_computed_int_on AS
WITH joined AS (
SELECT t1.id,
t1.intt AS t1_intt,
t2.intt AS t2_intt,
TIMESTAMPDIFF(YEAR, t1.tmestmp, t2.tmestmp) AS intervall
FROM asof_tbl1 t1
JOIN asof_tbl2 t2
ON t1.id = t2.id
)
SELECT j.id, j.t1_intt, intervall
FROM joined j
LEFT ASOF JOIN asof_tbl3 t3
MATCH_CONDITION (j.intervall >= t3.intt)
Copy link

Copilot AI Dec 24, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Column reference 'intervall' should be 'interval' to match corrected naming.

Suggested change
{"id": 1, "t1_intt": 10, "intervall": 20},
{"id": 2, "t1_intt": 15, "intervall": 2},
{"id": 3, "t1_intt": 20, "intervall": -1},
{"id": 4, "t1_intt": 25, "intervall": -1},
{"id": 5, "t1_intt": None, "intervall": None},
]
self.sql = """CREATE MATERIALIZED VIEW asof_computed_int_on AS
WITH joined AS (
SELECT t1.id,
t1.intt AS t1_intt,
t2.intt AS t2_intt,
TIMESTAMPDIFF(YEAR, t1.tmestmp, t2.tmestmp) AS intervall
FROM asof_tbl1 t1
JOIN asof_tbl2 t2
ON t1.id = t2.id
)
SELECT j.id, j.t1_intt, intervall
FROM joined j
LEFT ASOF JOIN asof_tbl3 t3
MATCH_CONDITION (j.intervall >= t3.intt)
{"id": 1, "t1_intt": 10, "interval": 20},
{"id": 2, "t1_intt": 15, "interval": 2},
{"id": 3, "t1_intt": 20, "interval": -1},
{"id": 4, "t1_intt": 25, "interval": -1},
{"id": 5, "t1_intt": None, "interval": None},
]
self.sql = """CREATE MATERIALIZED VIEW asof_computed_int_on AS
WITH joined AS (
SELECT t1.id,
t1.intt AS t1_intt,
t2.intt AS t2_intt,
TIMESTAMPDIFF(YEAR, t1.tmestmp, t2.tmestmp) AS interval
FROM asof_tbl1 t1
JOIN asof_tbl2 t2
ON t1.id = t2.id
)
SELECT j.id, j.t1_intt, interval
FROM joined j
LEFT ASOF JOIN asof_tbl3 t3
MATCH_CONDITION (j.interval >= t3.intt)

Copilot uses AI. Check for mistakes.
@mihaibudiu mihaibudiu added this pull request to the merge queue Dec 24, 2025
Merged via the queue into main with commit 489eae0 Dec 24, 2025
1 check passed
@mihaibudiu mihaibudiu deleted the as-of-new branch December 24, 2025 19:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[SQL] Comprehensive tests for ASOF JOIN

3 participants