Merge "tp: fix hasty autosubmit+1 merge failures" into main
diff --git a/src/trace_processor/perfetto_sql/intrinsics/operators/interval_intersect_operator.h b/src/trace_processor/perfetto_sql/intrinsics/operators/interval_intersect_operator.h
index cdc02f9..896d1a7 100644
--- a/src/trace_processor/perfetto_sql/intrinsics/operators/interval_intersect_operator.h
+++ b/src/trace_processor/perfetto_sql/intrinsics/operators/interval_intersect_operator.h
@@ -75,7 +75,9 @@
         query_results.clear();
         index = 0;
         auto* tree_ptr = trees.Find(tree_key);
-        PERFETTO_DCHECK(tree_ptr);
+        if (!tree_ptr) {
+          return;
+        }
         (*tree_ptr)->FindOverlaps(start, end, query_results);
       }
     };
diff --git a/test/trace_processor/diff_tests/tables/tests.py b/test/trace_processor/diff_tests/tables/tests.py
index aa14035..7502625 100644
--- a/test/trace_processor/diff_tests/tables/tests.py
+++ b/test/trace_processor/diff_tests/tables/tests.py
@@ -299,6 +299,32 @@
         70,7
         """))
 
+  def test_ii_wrong_partition(self):
+    return DiffTestBlueprint(
+        trace=TextProto(''),
+        query="""
+        CREATE PERFETTO TABLE A
+        AS
+        WITH x(id, ts, ts_end, c0) AS (VALUES(1, 1, 2, 1), (2, 3, 4, 2))
+        SELECT * FROM x;
+
+        CREATE PERFETTO TABLE B
+        AS
+        WITH x(id, ts, ts_end, c0) AS (VALUES(1, 5, 6, 3))
+        SELECT * FROM x;
+
+        SELECT
+        a.id AS a_id,
+        b.id AS b_id
+        FROM __intrinsic_ii_with_interval_tree('A', 'c0') a
+        JOIN __intrinsic_ii_with_interval_tree('B', 'c0') b
+        USING (c0)
+        WHERE a.ts < b.ts_end AND a.ts_end > b.ts;
+        """,
+        out=Csv("""
+        "a_id","b_id"
+        """))
+
   # Null printing
   def test_nulls(self):
     return DiffTestBlueprint(