Java Code Examples for io.prestosql.spi.predicate.TupleDomain#withColumnDomains()
The following examples show how to use
io.prestosql.spi.predicate.TupleDomain#withColumnDomains() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: TestInformationSchemaMetadata.java From presto with Apache License 2.0 | 6 votes |
@Test public void testInformationSchemaPredicatePushdownWithoutTablePredicate() { TransactionId transactionId = transactionManager.beginTransaction(false); // predicate without table name predicates should not cause table level prefixes to be evaluated ImmutableMap.Builder<ColumnHandle, Domain> domains = new ImmutableMap.Builder<>(); domains.put(new InformationSchemaColumnHandle("table_schema"), Domain.singleValue(VARCHAR, Slices.utf8Slice("test_schema"))); Constraint constraint = new Constraint(TupleDomain.withColumnDomains(domains.build())); ConnectorSession session = createNewSession(transactionId); ConnectorMetadata metadata = new InformationSchemaMetadata("test_catalog", this.metadata); InformationSchemaTableHandle tableHandle = (InformationSchemaTableHandle) metadata.getTableHandle(session, new SchemaTableName("information_schema", "views")); tableHandle = metadata.applyFilter(session, tableHandle, constraint) .map(ConstraintApplicationResult::getHandle) .map(InformationSchemaTableHandle.class::cast) .orElseThrow(AssertionError::new); assertEquals(tableHandle.getPrefixes(), ImmutableSet.of(new QualifiedTablePrefix("test_catalog", "test_schema"))); }
Example 2
Source File: TestJdbcQueryBuilder.java From presto with Apache License 2.0 | 6 votes |
@Test public void testBuildSqlWithFloat() throws SQLException { TupleDomain<ColumnHandle> tupleDomain = TupleDomain.withColumnDomains(ImmutableMap.of( columns.get(10), Domain.create(SortedRangeSet.copyOf(REAL, ImmutableList.of( Range.equal(REAL, (long) floatToRawIntBits(100.0f + 0)), Range.equal(REAL, (long) floatToRawIntBits(100.008f + 0)), Range.equal(REAL, (long) floatToRawIntBits(100.0f + 14)))), false))); Connection connection = database.getConnection(); try (PreparedStatement preparedStatement = new QueryBuilder("\"").buildSql(jdbcClient, SESSION, connection, "", "", "test_table", Optional.empty(), columns, tupleDomain, Optional.empty(), identity()); ResultSet resultSet = preparedStatement.executeQuery()) { ImmutableSet.Builder<Long> longBuilder = ImmutableSet.builder(); ImmutableSet.Builder<Float> floatBuilder = ImmutableSet.builder(); while (resultSet.next()) { longBuilder.add((Long) resultSet.getObject("col_0")); floatBuilder.add((Float) resultSet.getObject("col_10")); } assertEquals(longBuilder.build(), ImmutableSet.of(0L, 14L)); assertEquals(floatBuilder.build(), ImmutableSet.of(100.0f, 114.0f)); } }
Example 3
Source File: TestInformationSchemaMetadata.java From presto with Apache License 2.0 | 6 votes |
@Test public void testInformationSchemaPredicatePushdownWithoutSchemaPredicate() { TransactionId transactionId = transactionManager.beginTransaction(false); // predicate without schema predicates should cause schemas to be enumerated when table predicates are present ImmutableMap.Builder<ColumnHandle, Domain> domains = new ImmutableMap.Builder<>(); domains.put(new InformationSchemaColumnHandle("table_name"), Domain.singleValue(VARCHAR, Slices.utf8Slice("test_view"))); Constraint constraint = new Constraint(TupleDomain.withColumnDomains(domains.build())); ConnectorSession session = createNewSession(transactionId); ConnectorMetadata metadata = new InformationSchemaMetadata("test_catalog", this.metadata); InformationSchemaTableHandle tableHandle = (InformationSchemaTableHandle) metadata.getTableHandle(session, new SchemaTableName("information_schema", "views")); tableHandle = metadata.applyFilter(session, tableHandle, constraint) .map(ConstraintApplicationResult::getHandle) .map(InformationSchemaTableHandle.class::cast) .orElseThrow(AssertionError::new); assertEquals(tableHandle.getPrefixes(), ImmutableSet.of(new QualifiedTablePrefix("test_catalog", "test_schema", "test_view"))); }
Example 4
Source File: TestInformationSchemaMetadata.java From presto with Apache License 2.0 | 6 votes |
/** * Tests information schema predicate pushdown when both schema and table name are specified. */ @Test public void testInformationSchemaPredicatePushdown() { TransactionId transactionId = transactionManager.beginTransaction(false); ImmutableMap.Builder<ColumnHandle, Domain> domains = new ImmutableMap.Builder<>(); domains.put(new InformationSchemaColumnHandle("table_schema"), Domain.singleValue(VARCHAR, Slices.utf8Slice("test_schema"))); domains.put(new InformationSchemaColumnHandle("table_name"), Domain.singleValue(VARCHAR, Slices.utf8Slice("test_view"))); Constraint constraint = new Constraint(TupleDomain.withColumnDomains(domains.build())); ConnectorSession session = createNewSession(transactionId); ConnectorMetadata metadata = new InformationSchemaMetadata("test_catalog", this.metadata); InformationSchemaTableHandle tableHandle = (InformationSchemaTableHandle) metadata.getTableHandle(session, new SchemaTableName("information_schema", "views")); tableHandle = metadata.applyFilter(session, tableHandle, constraint) .map(ConstraintApplicationResult::getHandle) .map(InformationSchemaTableHandle.class::cast) .orElseThrow(AssertionError::new); assertEquals(tableHandle.getPrefixes(), ImmutableSet.of(new QualifiedTablePrefix("test_catalog", "test_schema", "test_view"))); }
Example 5
Source File: IcebergPageSourceProvider.java From presto with Apache License 2.0 | 6 votes |
private static TupleDomain<ColumnDescriptor> getParquetTupleDomain(Map<List<String>, RichColumnDescriptor> descriptorsByPath, TupleDomain<IcebergColumnHandle> effectivePredicate) { if (effectivePredicate.isNone()) { return TupleDomain.none(); } ImmutableMap.Builder<ColumnDescriptor, Domain> predicate = ImmutableMap.builder(); effectivePredicate.getDomains().get().forEach((columnHandle, domain) -> { String baseType = columnHandle.getType().getTypeSignature().getBase(); // skip looking up predicates for complex types as Parquet only stores stats for primitives if (!baseType.equals(StandardTypes.MAP) && !baseType.equals(StandardTypes.ARRAY) && !baseType.equals(StandardTypes.ROW)) { RichColumnDescriptor descriptor = descriptorsByPath.get(ImmutableList.of(columnHandle.getName())); if (descriptor != null) { predicate.put(descriptor, domain); } } }); return TupleDomain.withColumnDomains(predicate.build()); }
Example 6
Source File: TestTupleDomainParquetPredicate.java From presto with Apache License 2.0 | 6 votes |
@Test(dataProvider = "typeForParquetInt32") public void testIntegerMatchesWithStatistics(Type typeForParquetInt32) throws ParquetCorruptionException { RichColumnDescriptor column = new RichColumnDescriptor( new ColumnDescriptor(new String[] {"path"}, INT32, 0, 0), new PrimitiveType(OPTIONAL, INT32, "Test column")); TupleDomain<ColumnDescriptor> effectivePredicate = TupleDomain.withColumnDomains(ImmutableMap.of( column, Domain.create(ValueSet.of(typeForParquetInt32, 42L, 43L, 44L, 112L), false))); TupleDomainParquetPredicate parquetPredicate = new TupleDomainParquetPredicate(effectivePredicate, singletonList(column)); assertTrue(parquetPredicate.matches(2, ImmutableMap.of(column, intColumnStats(32, 42)), ID, true)); assertFalse(parquetPredicate.matches(2, ImmutableMap.of(column, intColumnStats(30, 40)), ID, true)); assertEquals(parquetPredicate.matches(2, ImmutableMap.of(column, intColumnStats(1024, 0x10000 + 42)), ID, true), (typeForParquetInt32 != INTEGER)); // stats invalid for smallint/tinyint }
Example 7
Source File: TestMongoSession.java From presto with Apache License 2.0 | 5 votes |
@Test public void testBuildQueryIn() { TupleDomain<ColumnHandle> tupleDomain = TupleDomain.withColumnDomains(ImmutableMap.of( COL2, Domain.create(ValueSet.ofRanges(equal(createUnboundedVarcharType(), utf8Slice("hello")), equal(createUnboundedVarcharType(), utf8Slice("world"))), false))); Document query = MongoSession.buildQuery(tupleDomain); Document expected = new Document(COL2.getName(), new Document("$in", ImmutableList.of("hello", "world"))); assertEquals(query, expected); }
Example 8
Source File: TestCassandraClusteringPredicatesExtractor.java From presto with Apache License 2.0 | 5 votes |
@Test public void testGetUnenforcedPredicates() { TupleDomain<ColumnHandle> tupleDomain = TupleDomain.withColumnDomains( ImmutableMap.of( col2, Domain.singleValue(BIGINT, 34L), col4, Domain.singleValue(BIGINT, 26L))); CassandraClusteringPredicatesExtractor predicatesExtractor = new CassandraClusteringPredicatesExtractor(cassandraTable.getClusteringKeyColumns(), tupleDomain, cassandraVersion); TupleDomain<ColumnHandle> unenforcedPredicates = TupleDomain.withColumnDomains(ImmutableMap.of(col4, Domain.singleValue(BIGINT, 26L))); assertEquals(predicatesExtractor.getUnenforcedConstraints(), unenforcedPredicates); }
Example 9
Source File: ParquetPageSourceFactory.java From presto with Apache License 2.0 | 5 votes |
public static TupleDomain<ColumnDescriptor> getParquetTupleDomain( Map<List<String>, RichColumnDescriptor> descriptorsByPath, TupleDomain<HiveColumnHandle> effectivePredicate, MessageType fileSchema, boolean useColumnNames) { if (effectivePredicate.isNone()) { return TupleDomain.none(); } ImmutableMap.Builder<ColumnDescriptor, Domain> predicate = ImmutableMap.builder(); for (Entry<HiveColumnHandle, Domain> entry : effectivePredicate.getDomains().get().entrySet()) { HiveColumnHandle columnHandle = entry.getKey(); // skip looking up predicates for complex types as Parquet only stores stats for primitives if (columnHandle.getHiveType().getCategory() != PRIMITIVE || columnHandle.getColumnType() != REGULAR) { continue; } RichColumnDescriptor descriptor; if (useColumnNames) { descriptor = descriptorsByPath.get(ImmutableList.of(columnHandle.getName())); } else { org.apache.parquet.schema.Type parquetField = getParquetType(columnHandle, fileSchema, false); if (parquetField == null || !parquetField.isPrimitive()) { // Parquet file has fewer column than partition // Or the field is a complex type continue; } descriptor = descriptorsByPath.get(ImmutableList.of(parquetField.getName())); } if (descriptor != null) { predicate.put(descriptor, entry.getValue()); } } return TupleDomain.withColumnDomains(predicate.build()); }
Example 10
Source File: TestMongoSession.java From presto with Apache License 2.0 | 5 votes |
@Test public void testBuildQueryOr() { TupleDomain<ColumnHandle> tupleDomain = TupleDomain.withColumnDomains(ImmutableMap.of( COL1, Domain.create(ValueSet.ofRanges(lessThan(BIGINT, 100L), greaterThan(BIGINT, 200L)), false))); Document query = MongoSession.buildQuery(tupleDomain); Document expected = new Document("$or", asList( new Document(COL1.getName(), new Document("$lt", 100L)), new Document(COL1.getName(), new Document("$gt", 200L)))); assertEquals(query, expected); }
Example 11
Source File: TestJdbcQueryBuilder.java From presto with Apache License 2.0 | 5 votes |
@Test public void testBuildSqlWithTimestamp() throws SQLException { TupleDomain<ColumnHandle> tupleDomain = TupleDomain.withColumnDomains(ImmutableMap.of( columns.get(6), Domain.create(SortedRangeSet.copyOf(TIMESTAMP, ImmutableList.of( Range.equal(TIMESTAMP, toPrestoTimestamp(2016, 6, 3, 0, 23, 37)), Range.equal(TIMESTAMP, toPrestoTimestamp(2016, 10, 19, 16, 23, 37)), Range.range(TIMESTAMP, toPrestoTimestamp(2016, 6, 7, 8, 23, 37), false, toPrestoTimestamp(2016, 6, 9, 12, 23, 37), true))), false))); Connection connection = database.getConnection(); try (PreparedStatement preparedStatement = new QueryBuilder("\"").buildSql(jdbcClient, SESSION, connection, "", "", "test_table", Optional.empty(), columns, tupleDomain, Optional.empty(), identity()); ResultSet resultSet = preparedStatement.executeQuery()) { ImmutableSet.Builder<Timestamp> builder = ImmutableSet.builder(); while (resultSet.next()) { builder.add((Timestamp) resultSet.getObject("col_6")); } assertEquals(builder.build(), ImmutableSet.of( toTimestamp(2016, 6, 3, 0, 23, 37), toTimestamp(2016, 6, 8, 10, 23, 37), toTimestamp(2016, 6, 9, 12, 23, 37), toTimestamp(2016, 10, 19, 16, 23, 37))); assertContains(preparedStatement.toString(), "\"col_6\" > ?"); assertContains(preparedStatement.toString(), "\"col_6\" <= ?"); assertContains(preparedStatement.toString(), "\"col_6\" IN (?,?)"); } }
Example 12
Source File: DomainTranslator.java From presto with Apache License 2.0 | 5 votes |
@Override protected ExtractionResult visitIsNotNullPredicate(IsNotNullPredicate node, Boolean complement) { if (!(node.getValue() instanceof SymbolReference)) { return super.visitIsNotNullPredicate(node, complement); } Symbol symbol = Symbol.from(node.getValue()); Type columnType = checkedTypeLookup(symbol); Domain domain = complementIfNecessary(Domain.notNull(columnType), complement); return new ExtractionResult( TupleDomain.withColumnDomains(ImmutableMap.of(symbol, domain)), TRUE_LITERAL); }
Example 13
Source File: DomainTranslator.java From presto with Apache License 2.0 | 5 votes |
@Override protected ExtractionResult visitIsNullPredicate(IsNullPredicate node, Boolean complement) { if (!(node.getValue() instanceof SymbolReference)) { return super.visitIsNullPredicate(node, complement); } Symbol symbol = Symbol.from(node.getValue()); Type columnType = checkedTypeLookup(symbol); Domain domain = complementIfNecessary(Domain.onlyNull(columnType), complement); return new ExtractionResult( TupleDomain.withColumnDomains(ImmutableMap.of(symbol, domain)), TRUE_LITERAL); }
Example 14
Source File: LocalDynamicFiltersCollector.java From presto with Apache License 2.0 | 5 votes |
public synchronized TupleDomain<Symbol> getDynamicFilter(Set<Symbol> probeSymbols) { Map<Symbol, Domain> probeSymbolDomains = dynamicFilterDomainsResult.entrySet().stream() .filter(entry -> probeSymbols.contains(entry.getKey())) .collect(toImmutableMap(Map.Entry::getKey, Map.Entry::getValue)); return TupleDomain.withColumnDomains(probeSymbolDomains); }
Example 15
Source File: TestJdbcQueryBuilder.java From presto with Apache License 2.0 | 4 votes |
@Test public void testAggregationWithFilter() throws SQLException { TupleDomain<ColumnHandle> tupleDomain = TupleDomain.withColumnDomains(ImmutableMap.of( this.columns.get(1), Domain.create(ValueSet.ofRanges(Range.lessThan(DOUBLE, 200042.0)), true))); List<JdbcColumnHandle> projectedColumns = ImmutableList.of( this.columns.get(2), new JdbcColumnHandle( Optional.of("sum(\"col_0\")"), "s", JDBC_BIGINT, BIGINT, true, Optional.empty())); Connection connection = database.getConnection(); try (PreparedStatement preparedStatement = new QueryBuilder("\"").buildSql( jdbcClient, SESSION, connection, "", "", "test_table", Optional.of(ImmutableList.of(ImmutableList.of(this.columns.get(2)))), projectedColumns, tupleDomain, Optional.empty(), identity())) { assertThat(lastQuery) .isEqualTo("" + "SELECT \"col_2\" AS \"col_2\", sum(\"col_0\") AS \"s\" " + "FROM \"test_table\" " + "WHERE ((\"col_1\" < ?) OR \"col_1\" IS NULL) " + "GROUP BY \"col_2\""); try (ResultSet resultSet = preparedStatement.executeQuery()) { Multiset<List<Object>> actual = read(resultSet); assertThat(actual) .isEqualTo(ImmutableMultiset.of( ImmutableList.of(false, BigDecimal.valueOf(1764)), ImmutableList.of(true, BigDecimal.valueOf(1722)))); } } }
Example 16
Source File: DynamicFilterService.java From presto with Apache License 2.0 | 4 votes |
private static TupleDomain<ColumnHandle> translateSummaryToTupleDomain(DynamicFilterId filterId, Domain summary, Map<DynamicFilterId, ColumnHandle> sourceColumnHandles) { ColumnHandle sourceColumnHandle = requireNonNull(sourceColumnHandles.get(filterId), () -> format("Source column handle for dynamic filter %s is null", filterId)); return TupleDomain.withColumnDomains(ImmutableMap.of(sourceColumnHandle, summary)); }
Example 17
Source File: TestDatabaseShardManager.java From presto with Apache License 2.0 | 4 votes |
public void expected(List<ShardInfo> shards) { TupleDomain<RaptorColumnHandle> predicate = TupleDomain.withColumnDomains(domains); Set<ShardNodes> actual = getShardNodes(tableId, predicate); assertEquals(actual, toShardNodes(shards)); }
Example 18
Source File: TestShardMetadataRecordCursor.java From presto with Apache License 2.0 | 4 votes |
@Test public void testSimple() { ShardManager shardManager = createShardManager(dbi); // Add shards to the table long tableId = 1; OptionalInt bucketNumber = OptionalInt.empty(); UUID uuid1 = UUID.randomUUID(); UUID uuid2 = UUID.randomUUID(); UUID uuid3 = UUID.randomUUID(); ShardInfo shardInfo1 = new ShardInfo(uuid1, bucketNumber, ImmutableSet.of("node1"), ImmutableList.of(), 1, 10, 100, 0x1234); ShardInfo shardInfo2 = new ShardInfo(uuid2, bucketNumber, ImmutableSet.of("node2"), ImmutableList.of(), 2, 20, 200, 0xCAFEBABEDEADBEEFL); ShardInfo shardInfo3 = new ShardInfo(uuid3, bucketNumber, ImmutableSet.of("node3"), ImmutableList.of(), 3, 30, 300, 0xFEDCBA0987654321L); List<ShardInfo> shards = ImmutableList.of(shardInfo1, shardInfo2, shardInfo3); long transactionId = shardManager.beginTransaction(); shardManager.commitShards( transactionId, tableId, ImmutableList.of( new ColumnInfo(1, BIGINT), new ColumnInfo(2, DATE)), shards, Optional.empty(), 0); Slice schema = utf8Slice(DEFAULT_TEST_ORDERS.getSchemaName()); Slice table = utf8Slice(DEFAULT_TEST_ORDERS.getTableName()); DateTime date1 = DateTime.parse("2015-01-01T00:00"); DateTime date2 = DateTime.parse("2015-01-02T00:00"); TupleDomain<Integer> tupleDomain = TupleDomain.withColumnDomains( ImmutableMap.<Integer, Domain>builder() .put(0, Domain.singleValue(createVarcharType(10), schema)) .put(1, Domain.create(ValueSet.ofRanges(lessThanOrEqual(createVarcharType(10), table)), true)) .put(8, Domain.create(ValueSet.ofRanges(lessThanOrEqual(BIGINT, date1.getMillis()), greaterThan(BIGINT, date2.getMillis())), true)) .put(9, Domain.create(ValueSet.ofRanges(lessThanOrEqual(BIGINT, date1.getMillis()), greaterThan(BIGINT, date2.getMillis())), true)) .build()); List<MaterializedRow> actual; try (RecordCursor cursor = new ShardMetadataSystemTable(dbi).cursor(null, SESSION, tupleDomain)) { actual = getMaterializedResults(cursor, SHARD_METADATA.getColumns()); } assertEquals(actual.size(), 3); List<MaterializedRow> expected = ImmutableList.of( new MaterializedRow(DEFAULT_PRECISION, schema, table, utf8Slice(uuid1.toString()), null, 100L, 10L, 1L, utf8Slice("0000000000001234"), null, null, null, null), new MaterializedRow(DEFAULT_PRECISION, schema, table, utf8Slice(uuid2.toString()), null, 200L, 20L, 2L, utf8Slice("cafebabedeadbeef"), null, null, null, null), new MaterializedRow(DEFAULT_PRECISION, schema, table, utf8Slice(uuid3.toString()), null, 300L, 30L, 3L, utf8Slice("fedcba0987654321"), null, null, null, null)); assertEquals(actual, expected); }
Example 19
Source File: TestOrcPredicates.java From presto with Apache License 2.0 | 4 votes |
private void testOrcPredicates(ConnectorSession session) throws Exception { List<TestColumn> columnsToWrite = ImmutableList.of(columnPrimitiveInteger, columnStruct, columnPrimitiveBigInt); File file = File.createTempFile("test", "orc_predicate"); file.delete(); try { // Write data OrcFileWriterFactory writerFactory = new OrcFileWriterFactory(HDFS_ENVIRONMENT, TYPE_MANAGER, new NodeVersion("test"), HIVE_STORAGE_TIME_ZONE, false, STATS, new OrcWriterOptions()); FileSplit split = createTestFile(file.getAbsolutePath(), ORC, HiveCompressionCodec.NONE, columnsToWrite, session, NUM_ROWS, writerFactory); TupleDomain<TestColumn> testingPredicate; // Verify predicates on base column List<TestColumn> columnsToRead = columnsToWrite; // All rows returned for a satisfying predicate testingPredicate = TupleDomain.withColumnDomains(ImmutableMap.of(columnPrimitiveBigInt, Domain.singleValue(BIGINT, 6L))); assertFilteredRows(testingPredicate, columnsToRead, session, split, NUM_ROWS); // No rows returned for a mismatched predicate testingPredicate = TupleDomain.withColumnDomains(ImmutableMap.of(columnPrimitiveBigInt, Domain.singleValue(BIGINT, 1L))); assertFilteredRows(testingPredicate, columnsToRead, session, split, 0); // Verify predicates on projected column TestColumn projectedColumn = new TestColumn( columnStruct.getBaseName(), columnStruct.getBaseObjectInspector(), ImmutableList.of("field1"), ImmutableList.of(1), javaLongObjectInspector, 5L, 5L, false); columnsToRead = ImmutableList.of(columnPrimitiveBigInt, projectedColumn); // All rows returned for a satisfying predicate testingPredicate = TupleDomain.withColumnDomains(ImmutableMap.of(projectedColumn, Domain.singleValue(BIGINT, 5L))); assertFilteredRows(testingPredicate, columnsToRead, session, split, NUM_ROWS); // No rows returned for a mismatched predicate testingPredicate = TupleDomain.withColumnDomains(ImmutableMap.of(projectedColumn, Domain.singleValue(BIGINT, 6L))); assertFilteredRows(testingPredicate, columnsToRead, session, split, 0); } finally { file.delete(); } }
Example 20
Source File: TestPulsarSplitManager.java From pulsar with Apache License 2.0 | 4 votes |
@Test(dataProvider = "rewriteNamespaceDelimiter", singleThreaded = true) public void testPublishTimePredicatePushdown(String delimiter) throws Exception { updateRewriteNamespaceDelimiterIfNeeded(delimiter); TopicName topicName = TOPIC_1; setup(); log.info("!----- topic: %s -----!", topicName); PulsarTableHandle pulsarTableHandle = new PulsarTableHandle(pulsarConnectorId.toString(), topicName.getNamespace(), topicName.getLocalName(), topicName.getLocalName()); Map<ColumnHandle, Domain> domainMap = new HashMap<>(); Domain domain = Domain.create(ValueSet.ofRanges(Range.range(TIMESTAMP, currentTimeMs + 1L, true, currentTimeMs + 50L, true)), false); domainMap.put(PulsarInternalColumn.PUBLISH_TIME.getColumnHandle(pulsarConnectorId.toString(), false), domain); TupleDomain<ColumnHandle> tupleDomain = TupleDomain.withColumnDomains(domainMap); PulsarTableLayoutHandle pulsarTableLayoutHandle = new PulsarTableLayoutHandle(pulsarTableHandle, tupleDomain); final ResultCaptor<Collection<PulsarSplit>> resultCaptor = new ResultCaptor<>(); doAnswer(resultCaptor).when(this.pulsarSplitManager) .getSplitsNonPartitionedTopic(anyInt(), any(), any(), any(), any(), any()); ConnectorSplitSource connectorSplitSource = this.pulsarSplitManager.getSplits( mock(ConnectorTransactionHandle.class), mock(ConnectorSession.class), pulsarTableLayoutHandle, null); verify(this.pulsarSplitManager, times(1)) .getSplitsNonPartitionedTopic(anyInt(), any(), any(), any(), any(), any()); int totalSize = 0; int initalStart = 1; for (PulsarSplit pulsarSplit : resultCaptor.getResult()) { assertEquals(pulsarSplit.getConnectorId(), pulsarConnectorId.toString()); assertEquals(pulsarSplit.getSchemaName(), topicName.getNamespace()); assertEquals(pulsarSplit.getTableName(), topicName.getLocalName()); assertEquals(pulsarSplit.getSchema(), new String(topicsToSchemas.get(topicName.getSchemaName()).getSchema())); assertEquals(pulsarSplit.getSchemaType(), topicsToSchemas.get(topicName.getSchemaName()).getType()); assertEquals(pulsarSplit.getStartPositionEntryId(), initalStart); assertEquals(pulsarSplit.getStartPositionLedgerId(), 0); assertEquals(pulsarSplit.getStartPosition(), PositionImpl.get(0, initalStart)); assertEquals(pulsarSplit.getEndPositionLedgerId(), 0); assertEquals(pulsarSplit.getEndPositionEntryId(), initalStart + pulsarSplit.getSplitSize()); assertEquals(pulsarSplit.getEndPosition(), PositionImpl.get(0, initalStart + pulsarSplit .getSplitSize())); initalStart += pulsarSplit.getSplitSize(); totalSize += pulsarSplit.getSplitSize(); } assertEquals(totalSize, 49); }