Skip to content

Commit

Permalink
Fix NPE for spatial left join
Browse files Browse the repository at this point in the history
The failure started happening with the update to fastutil 8.5.12 in 5e9bb46
  • Loading branch information
martint committed Aug 30, 2023
1 parent 1aca030 commit bbdef06
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ public int[] findJoinPositions(int probePosition, Page probe, int probeGeometryC
}
});

return matchingPositions.toIntArray(null);
return matchingPositions.toIntArray();
}

private boolean testReferencePoint(Envelope probeEnvelope, OGCGeometry buildGeometry, int partition)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
import io.trino.plugin.hive.metastore.Database;
import io.trino.plugin.hive.metastore.HiveMetastore;
import io.trino.spi.security.PrincipalType;
import io.trino.sql.query.QueryAssertions;
import io.trino.testing.AbstractTestQueryFramework;
import io.trino.testing.DistributedQueryRunner;
import org.testng.annotations.Test;
Expand All @@ -29,6 +30,7 @@
import static io.trino.plugin.hive.metastore.file.TestingFileHiveMetastore.createTestingFileHiveMetastore;
import static io.trino.testing.TestingSession.testSessionBuilder;
import static java.lang.String.format;
import static org.assertj.core.api.Assertions.assertThat;

public class TestSpatialJoins
extends AbstractTestQueryFramework
Expand Down Expand Up @@ -399,4 +401,21 @@ public void testSpatialJoinOverFullJoinWithOrPredicate()
"ON ST_Contains(ST_GeometryFromText(b.wkt), ST_Point(a.latitude1, a.longitude1)) OR ST_Contains(ST_GeometryFromText(b.wkt), ST_Point(a.latitude2, a.longitude2))",
"VALUES ('x', 'a'), ('y', 'b'), ('y', 'c'), (NULL, 'd'), (NULL, 'empty'), ('z', NULL), (NULL, 'null'), ('null', NULL)");
}

@Test
public void testLeftJoin()
{
assertThat(new QueryAssertions(getQueryRunner()).query("""
WITH
points(lat, lon) AS ( VALUES (0.5, 0.5), (2, 2) ),
polygons(id, x) AS ( VALUES (1, ST_GeometryFromText('POLYGON ((0 0, 0 1, 1 1, 1 0, 0 0))')) )
SELECT id, lat, lon
FROM points LEFT JOIN polygons ON st_contains(x, ST_Point(lat, lon))
"""))
.matches("""
VALUES
(1, 0.5, 0.5),
(NULL, 2, 2)
""");
}
}

0 comments on commit bbdef06

Please sign in to comment.