4747import io .trino .spi .connector .ColumnHandle ;
4848import io .trino .spi .connector .ConnectorSession ;
4949import io .trino .spi .connector .ConnectorSplitSource .ConnectorSplitBatch ;
50+ import io .trino .spi .connector .Constraint ;
5051import io .trino .spi .connector .DynamicFilter ;
5152import io .trino .spi .connector .SchemaTableName ;
5253import io .trino .spi .predicate .Domain ;
@@ -154,7 +155,7 @@ public void tearDown()
154155 public void testNoPathFilter ()
155156 throws Exception
156157 {
157- BackgroundHiveSplitLoader backgroundHiveSplitLoader = backgroundHiveSplitLoader (TEST_LOCATIONS , TupleDomain .none ());
158+ BackgroundHiveSplitLoader backgroundHiveSplitLoader = backgroundHiveSplitLoader (TEST_LOCATIONS , TupleDomain .none (), Constraint . alwaysTrue () );
158159
159160 HiveSplitSource hiveSplitSource = hiveSplitSource (backgroundHiveSplitLoader );
160161 backgroundHiveSplitLoader .start (hiveSplitSource );
@@ -205,7 +206,8 @@ public void testPathFilter()
205206 {
206207 BackgroundHiveSplitLoader backgroundHiveSplitLoader = backgroundHiveSplitLoader (
207208 TEST_LOCATIONS ,
208- LOCATION_DOMAIN );
209+ LOCATION_DOMAIN ,
210+ Constraint .alwaysTrue ());
209211
210212 HiveSplitSource hiveSplitSource = hiveSplitSource (backgroundHiveSplitLoader );
211213 backgroundHiveSplitLoader .start (hiveSplitSource );
@@ -214,13 +216,32 @@ public void testPathFilter()
214216 assertThat (paths .get (0 )).isEqualTo (LOCATION .toString ());
215217 }
216218
219+ @ Test
220+ public void testPathConstraint ()
221+ throws Exception
222+ {
223+ BackgroundHiveSplitLoader backgroundHiveSplitLoader = backgroundHiveSplitLoader (
224+ TEST_LOCATIONS ,
225+ LOCATION_DOMAIN ,
226+ new Constraint (
227+ TupleDomain .all (),
228+ LOCATION_DOMAIN .transformKeys (ColumnHandle .class ::cast ).asPredicate (),
229+ Set .of (pathColumnHandle ())));
230+
231+ HiveSplitSource hiveSplitSource = hiveSplitSource (backgroundHiveSplitLoader );
232+ backgroundHiveSplitLoader .start (hiveSplitSource );
233+ List <String > paths = drain (hiveSplitSource );
234+ assertThat (paths ).containsExactly (LOCATION .toString ());
235+ }
236+
217237 @ Test
218238 public void testPathFilterOneBucketMatchPartitionedTable ()
219239 throws Exception
220240 {
221241 BackgroundHiveSplitLoader backgroundHiveSplitLoader = backgroundHiveSplitLoader (
222242 TEST_LOCATIONS ,
223243 LOCATION_DOMAIN ,
244+ Constraint .alwaysTrue (),
224245 Optional .of (new HiveBucketFilter (Set .of (0 , 1 ))),
225246 PARTITIONED_TABLE ,
226247 Optional .of (new HiveTablePartitioning (true , BUCKETING_V1 , BUCKET_COUNT , BUCKET_COLUMN_HANDLES , false , List .of (), true )));
@@ -239,6 +260,7 @@ public void testPathFilterBucketedPartitionedTable()
239260 BackgroundHiveSplitLoader backgroundHiveSplitLoader = backgroundHiveSplitLoader (
240261 TEST_LOCATIONS ,
241262 LOCATION_DOMAIN ,
263+ Constraint .alwaysTrue (),
242264 Optional .empty (),
243265 PARTITIONED_TABLE ,
244266 Optional .of (
@@ -474,6 +496,7 @@ public HivePartitionMetadata next()
474496 }
475497 },
476498 TupleDomain .all (),
499+ Constraint .alwaysTrue (),
477500 DynamicFilter .EMPTY ,
478501 new Duration (0 , SECONDS ),
479502 TESTING_TYPE_MANAGER ,
@@ -796,6 +819,7 @@ public void testBuildManifestFileIterator()
796819 schema ,
797820 List .of (),
798821 TupleDomain .all (),
822+ Constraint .alwaysTrue (),
799823 () -> true ,
800824 ImmutableMap .of (),
801825 Optional .empty (),
@@ -837,6 +861,7 @@ public void testBuildManifestFileIteratorNestedDirectory()
837861 schema ,
838862 List .of (),
839863 TupleDomain .all (),
864+ Constraint .alwaysTrue (),
840865 () -> true ,
841866 ImmutableMap .of (),
842867 Optional .empty (),
@@ -875,6 +900,7 @@ public void testBuildManifestFileIteratorWithCacheInvalidation()
875900 schema ,
876901 List .of (),
877902 TupleDomain .all (),
903+ Constraint .alwaysTrue (),
878904 () -> true ,
879905 ImmutableMap .of (),
880906 Optional .empty (),
@@ -1056,6 +1082,7 @@ private BackgroundHiveSplitLoader backgroundHiveSplitLoader(
10561082 return backgroundHiveSplitLoader (
10571083 fileSystemFactory ,
10581084 TupleDomain .all (),
1085+ Constraint .alwaysTrue (),
10591086 dynamicFilter ,
10601087 dynamicFilteringProbeBlockingTimeoutMillis ,
10611088 Optional .empty (),
@@ -1079,12 +1106,14 @@ private static TrinoFileSystemFactory createTestingFileSystem(Collection<Locatio
10791106
10801107 private BackgroundHiveSplitLoader backgroundHiveSplitLoader (
10811108 List <Location > locations ,
1082- TupleDomain <HiveColumnHandle > tupleDomain )
1109+ TupleDomain <HiveColumnHandle > tupleDomain ,
1110+ Constraint constraint )
10831111 throws IOException
10841112 {
10851113 return backgroundHiveSplitLoader (
10861114 locations ,
10871115 tupleDomain ,
1116+ constraint ,
10881117 Optional .empty (),
10891118 SIMPLE_TABLE ,
10901119 Optional .empty ());
@@ -1093,37 +1122,23 @@ private BackgroundHiveSplitLoader backgroundHiveSplitLoader(
10931122 private BackgroundHiveSplitLoader backgroundHiveSplitLoader (
10941123 List <Location > locations ,
10951124 TupleDomain <HiveColumnHandle > compactEffectivePredicate ,
1125+ Constraint constraint ,
10961126 Optional <HiveBucketFilter > hiveBucketFilter ,
10971127 Table table ,
10981128 Optional <HiveTablePartitioning > tablePartitioning )
10991129 throws IOException
1100- {
1101- return backgroundHiveSplitLoader (
1102- locations ,
1103- compactEffectivePredicate ,
1104- hiveBucketFilter ,
1105- table ,
1106- tablePartitioning ,
1107- Optional .empty ());
1108- }
1109-
1110- private BackgroundHiveSplitLoader backgroundHiveSplitLoader (
1111- List <Location > locations ,
1112- TupleDomain <HiveColumnHandle > compactEffectivePredicate ,
1113- Optional <HiveBucketFilter > hiveBucketFilter ,
1114- Table table ,
1115- Optional <HiveTablePartitioning > tablePartitioning ,
1116- Optional <ValidWriteIdList > validWriteIds )
1117- throws IOException
11181130 {
11191131 TrinoFileSystemFactory fileSystemFactory = createTestingFileSystem (locations );
11201132 return backgroundHiveSplitLoader (
11211133 fileSystemFactory ,
11221134 compactEffectivePredicate ,
1135+ constraint ,
1136+ DynamicFilter .EMPTY ,
1137+ new Duration (0 , SECONDS ),
11231138 hiveBucketFilter ,
11241139 table ,
11251140 tablePartitioning ,
1126- validWriteIds );
1141+ Optional . empty () );
11271142 }
11281143
11291144 private BackgroundHiveSplitLoader backgroundHiveSplitLoader (
@@ -1137,6 +1152,7 @@ private BackgroundHiveSplitLoader backgroundHiveSplitLoader(
11371152 return backgroundHiveSplitLoader (
11381153 fileSystemFactory ,
11391154 compactEffectivePredicate ,
1155+ Constraint .alwaysTrue (),
11401156 DynamicFilter .EMPTY ,
11411157 new Duration (0 , SECONDS ),
11421158 hiveBucketFilter ,
@@ -1148,6 +1164,7 @@ private BackgroundHiveSplitLoader backgroundHiveSplitLoader(
11481164 private BackgroundHiveSplitLoader backgroundHiveSplitLoader (
11491165 TrinoFileSystemFactory fileSystemFactory ,
11501166 TupleDomain <HiveColumnHandle > compactEffectivePredicate ,
1167+ Constraint constraint ,
11511168 DynamicFilter dynamicFilter ,
11521169 Duration dynamicFilteringProbeBlockingTimeout ,
11531170 Optional <HiveBucketFilter > hiveBucketFilter ,
@@ -1166,6 +1183,7 @@ private BackgroundHiveSplitLoader backgroundHiveSplitLoader(
11661183 table ,
11671184 hivePartitionMetadatas .iterator (),
11681185 compactEffectivePredicate ,
1186+ constraint ,
11691187 dynamicFilter ,
11701188 dynamicFilteringProbeBlockingTimeout ,
11711189 TESTING_TYPE_MANAGER ,
@@ -1210,6 +1228,7 @@ private BackgroundHiveSplitLoader backgroundHiveSplitLoader(
12101228 SIMPLE_TABLE ,
12111229 partitions .iterator (),
12121230 TupleDomain .none (),
1231+ Constraint .alwaysTrue (),
12131232 DynamicFilter .EMPTY ,
12141233 new Duration (0 , SECONDS ),
12151234 TESTING_TYPE_MANAGER ,
@@ -1237,6 +1256,7 @@ private BackgroundHiveSplitLoader backgroundHiveSplitLoaderOfflinePartitions()
12371256 SIMPLE_TABLE ,
12381257 createPartitionMetadataWithOfflinePartitions (),
12391258 TupleDomain .all (),
1259+ Constraint .alwaysTrue (),
12401260 DynamicFilter .EMPTY ,
12411261 new Duration (0 , SECONDS ),
12421262 TESTING_TYPE_MANAGER ,
0 commit comments