-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Add system tables support with registry and broker wiring #17291
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
There was a problem hiding this 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 introduces a system table SPI and infrastructure to expose virtual metadata tables (like system.tables and system.instances) queryable via standard SQL through the broker. It includes:
- Core SPI classes for system tables (request, response, filter, provider, config utils) in pinot-spi
- A registry and provider implementations for
system.tables(with table size/metadata fetching) andsystem.instances(stub) - Broker wiring to handle system table queries with projection, filtering, and offset/limit support
- Database utility updates to allow system tables to bypass database prefix validation
- Admin client enhancement to fetch table sizes from the controller
Reviewed changes
Copilot reviewed 20 out of 20 changed files in this pull request and generated 5 comments.
Show a summary per file
| File | Description |
|---|---|
| pinot-spi/src/main/java/org/apache/pinot/spi/systemtable/*.java | Introduces system table SPI classes (Request, Response, Filter, Provider, ConfigUtils) |
| pinot-common/src/main/java/org/apache/pinot/common/systemtable/SystemTableRegistry.java | Adds registry to manage system table providers |
| pinot-common/src/main/java/org/apache/pinot/common/systemtable/provider/*.java | Implements TablesSystemTableProvider and InstancesSystemTableProvider |
| pinot-common/src/main/java/org/apache/pinot/common/utils/DatabaseUtils.java | Adds bypass logic for system tables to skip database prefix validation |
| pinot-broker/src/main/java/org/apache/pinot/broker/requesthandler/*.java | Updates request handlers to route system table queries through new system table path |
| pinot-broker/src/main/java/org/apache/pinot/broker/broker/helix/BaseBrokerStarter.java | Wires system table providers into broker startup |
| pinot-clients/pinot-java-client/src/main/java/org/apache/pinot/client/admin/PinotTableAdminClient.java | Adds getTableSize method to fetch table size from controller |
| pinot-broker/pom.xml | Adds pinot-java-client dependency to support admin client usage |
| pinot-integration-tests/src/test/java/org/apache/pinot/integration/tests/SystemTableIntegrationTest.java | Adds integration test for system.tables querying |
| pinot-common/src/test/java/org/apache/pinot/common/systemtable/provider/TablesSystemTableProviderTest.java | Adds unit test for TablesSystemTableProvider |
| pinot-broker/src/test/java/org/apache/pinot/broker/requesthandler/SystemTableBrokerRequestHandlerTest.java | Adds unit test for system table request handling |
| pinot-broker/src/test/java/org/apache/pinot/broker/requesthandler/*.java | Updates existing tests to inject SystemTableRegistry |
...on/src/main/java/org/apache/pinot/common/systemtable/provider/TablesSystemTableProvider.java
Outdated
Show resolved
Hide resolved
...on/src/main/java/org/apache/pinot/common/systemtable/provider/TablesSystemTableProvider.java
Outdated
Show resolved
Hide resolved
...rc/main/java/org/apache/pinot/broker/requesthandler/BaseSingleStageBrokerRequestHandler.java
Outdated
Show resolved
Hide resolved
...rc/main/java/org/apache/pinot/broker/requesthandler/BaseSingleStageBrokerRequestHandler.java
Outdated
Show resolved
Hide resolved
pinot-common/src/main/java/org/apache/pinot/common/utils/DatabaseUtils.java
Outdated
Show resolved
Hide resolved
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## master #17291 +/- ##
============================================
- Coverage 63.19% 62.99% -0.21%
- Complexity 1480 1541 +61
============================================
Files 3173 3186 +13
Lines 189896 191259 +1363
Branches 29057 29280 +223
============================================
+ Hits 120011 120482 +471
- Misses 60558 61372 +814
- Partials 9327 9405 +78
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
Copilot reviewed 20 out of 20 changed files in this pull request and generated 6 comments.
...on/src/main/java/org/apache/pinot/common/systemtable/provider/TablesSystemTableProvider.java
Outdated
Show resolved
Hide resolved
...on/src/main/java/org/apache/pinot/common/systemtable/provider/TablesSystemTableProvider.java
Outdated
Show resolved
Hide resolved
...rc/main/java/org/apache/pinot/broker/requesthandler/BaseSingleStageBrokerRequestHandler.java
Outdated
Show resolved
Hide resolved
...on/src/main/java/org/apache/pinot/common/systemtable/provider/TablesSystemTableProvider.java
Outdated
Show resolved
Hide resolved
...rc/main/java/org/apache/pinot/broker/requesthandler/BaseSingleStageBrokerRequestHandler.java
Outdated
Show resolved
Hide resolved
...on/src/main/java/org/apache/pinot/common/systemtable/provider/TablesSystemTableProvider.java
Outdated
Show resolved
Hide resolved
4ed0ef7 to
c50b6f3
Compare
0b3775f to
32d43a8
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
Copilot reviewed 20 out of 20 changed files in this pull request and generated 10 comments.
...on/src/main/java/org/apache/pinot/common/systemtable/provider/TablesSystemTableProvider.java
Outdated
Show resolved
Hide resolved
...on/src/main/java/org/apache/pinot/common/systemtable/provider/TablesSystemTableProvider.java
Outdated
Show resolved
Hide resolved
...on/src/main/java/org/apache/pinot/common/systemtable/provider/TablesSystemTableProvider.java
Outdated
Show resolved
Hide resolved
...rc/main/java/org/apache/pinot/broker/requesthandler/BaseSingleStageBrokerRequestHandler.java
Outdated
Show resolved
Hide resolved
...on/src/main/java/org/apache/pinot/common/systemtable/provider/TablesSystemTableProvider.java
Outdated
Show resolved
Hide resolved
...on/src/main/java/org/apache/pinot/common/systemtable/provider/TablesSystemTableProvider.java
Outdated
Show resolved
Hide resolved
...rc/main/java/org/apache/pinot/broker/requesthandler/BaseSingleStageBrokerRequestHandler.java
Outdated
Show resolved
Hide resolved
...rc/main/java/org/apache/pinot/broker/requesthandler/BaseSingleStageBrokerRequestHandler.java
Outdated
Show resolved
Hide resolved
...on/src/main/java/org/apache/pinot/common/systemtable/provider/TablesSystemTableProvider.java
Outdated
Show resolved
Hide resolved
pinot-broker/src/main/java/org/apache/pinot/broker/broker/helix/BaseBrokerStarter.java
Outdated
Show resolved
Hide resolved
32d43a8 to
59de5cf
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
Copilot reviewed 20 out of 20 changed files in this pull request and generated 5 comments.
Comments suppressed due to low confidence (1)
pinot-common/src/main/java/org/apache/pinot/common/systemtable/provider/TablesSystemTableProvider.java:1
- The
initialCapacitylogic is incorrect whenhasLimitis false. Setting capacity to 0 when no limit is specified will cause ArrayList to grow dynamically, potentially causing multiple resizes. Consider usingsortedTableNames.size()as the initial capacity when no limit is specified.
/**
...tem-table/src/main/java/org/apache/pinot/systemtable/provider/TablesSystemTableProvider.java
Outdated
Show resolved
Hide resolved
...on/src/main/java/org/apache/pinot/common/systemtable/provider/TablesSystemTableProvider.java
Outdated
Show resolved
Hide resolved
...rc/main/java/org/apache/pinot/broker/requesthandler/BaseSingleStageBrokerRequestHandler.java
Outdated
Show resolved
Hide resolved
...rc/main/java/org/apache/pinot/broker/requesthandler/BaseSingleStageBrokerRequestHandler.java
Outdated
Show resolved
Hide resolved
pinot-common/src/main/java/org/apache/pinot/common/utils/DatabaseUtils.java
Outdated
Show resolved
Hide resolved
59de5cf to
fc4f982
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
Copilot reviewed 20 out of 20 changed files in this pull request and generated 3 comments.
pinot-common/src/main/java/org/apache/pinot/common/utils/DatabaseUtils.java
Show resolved
Hide resolved
...on/src/main/java/org/apache/pinot/common/systemtable/provider/TablesSystemTableProvider.java
Outdated
Show resolved
Hide resolved
...rc/main/java/org/apache/pinot/broker/requesthandler/BaseSingleStageBrokerRequestHandler.java
Outdated
Show resolved
Hide resolved
fc4f982 to
7c57ff4
Compare
pinot-common/src/main/java/org/apache/pinot/common/systemtable/SystemTableRegistry.java
Outdated
Show resolved
Hide resolved
pinot-common/src/main/java/org/apache/pinot/common/systemtable/SystemTableRegistry.java
Outdated
Show resolved
Hide resolved
pinot-common/src/main/java/org/apache/pinot/common/systemtable/SystemTableRegistry.java
Outdated
Show resolved
Hide resolved
pinot-common/src/main/java/org/apache/pinot/common/systemtable/SystemTableRegistry.java
Outdated
Show resolved
Hide resolved
pinot-common/src/main/java/org/apache/pinot/common/systemtable/SystemTableRegistry.java
Outdated
Show resolved
Hide resolved
pinot-common/src/main/java/org/apache/pinot/common/systemtable/SystemTableRegistry.java
Outdated
Show resolved
Hide resolved
pinot-common/src/main/java/org/apache/pinot/common/systemtable/SystemTableRegistry.java
Outdated
Show resolved
Hide resolved
...rc/main/java/org/apache/pinot/broker/requesthandler/BaseSingleStageBrokerRequestHandler.java
Outdated
Show resolved
Hide resolved
pinot-spi/src/main/java/org/apache/pinot/spi/systemtable/SystemTableRequest.java
Outdated
Show resolved
Hide resolved
pinot-spi/src/main/java/org/apache/pinot/spi/systemtable/SystemTableResponse.java
Outdated
Show resolved
Hide resolved
7c57ff4 to
f4b4b1d
Compare
c39949d to
1811dfa
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
Copilot reviewed 24 out of 25 changed files in this pull request and generated 4 comments.
Comments suppressed due to low confidence (1)
pinot-common/src/main/java/org/apache/pinot/common/systemtable/provider/TablesSystemTableProvider.java:1
- Converting arbitrary objects to bytes via
toString().getBytes()may not produce meaningful results for complex objects. Consider documenting the expected input types or adding validation to ensure only appropriate types are converted to bytes.
/**
...on/src/main/java/org/apache/pinot/common/systemtable/provider/TablesSystemTableProvider.java
Outdated
Show resolved
Hide resolved
...s/pinot-java-client/src/main/java/org/apache/pinot/client/admin/PinotSegmentAdminClient.java
Outdated
Show resolved
Hide resolved
...roker/src/main/java/org/apache/pinot/broker/requesthandler/BrokerRequestHandlerDelegate.java
Outdated
Show resolved
Hide resolved
...tem-table/src/main/java/org/apache/pinot/systemtable/provider/TablesSystemTableProvider.java
Outdated
Show resolved
Hide resolved
df73191 to
5bab828
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
Copilot reviewed 30 out of 31 changed files in this pull request and generated 2 comments.
...src/main/java/org/apache/pinot/common/systemtable/datasource/InMemorySystemTableSegment.java
Outdated
Show resolved
Hide resolved
...s/pinot-java-client/src/main/java/org/apache/pinot/client/admin/PinotSegmentAdminClient.java
Outdated
Show resolved
Hide resolved
5bab828 to
564d450
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
Copilot reviewed 30 out of 31 changed files in this pull request and generated 3 comments.
...roker/src/main/java/org/apache/pinot/broker/requesthandler/BrokerRequestHandlerDelegate.java
Outdated
Show resolved
Hide resolved
...er/src/main/java/org/apache/pinot/broker/requesthandler/SystemTableBrokerRequestHandler.java
Outdated
Show resolved
Hide resolved
...er/src/main/java/org/apache/pinot/broker/requesthandler/SystemTableBrokerRequestHandler.java
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
Copilot reviewed 30 out of 31 changed files in this pull request and generated 1 comment.
...s/pinot-java-client/src/main/java/org/apache/pinot/client/admin/PinotSegmentAdminClient.java
Outdated
Show resolved
Hide resolved
5540416 to
70a02ab
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
Copilot reviewed 35 out of 36 changed files in this pull request and generated 5 comments.
Comments suppressed due to low confidence (1)
pinot-plugins/pinot-system-table/src/main/java/org/apache/pinot/systemtable/provider/TablesSystemTableProvider.java:68
- The cache TTL configuration is read once at class load time, making it impossible to update without restarting the broker. Consider implementing dynamic configuration reloading to allow runtime adjustments of cache behavior.
private static final long SIZE_CACHE_TTL_MS = getNonNegativeLongProperty(SIZE_CACHE_TTL_MS_PROPERTY,
DEFAULT_SIZE_CACHE_TTL_MS);
...tem-table/src/main/java/org/apache/pinot/systemtable/provider/TablesSystemTableProvider.java
Show resolved
Hide resolved
...src/main/java/org/apache/pinot/common/systemtable/datasource/InMemorySystemTableSegment.java
Outdated
Show resolved
Hide resolved
pinot-common/src/main/java/org/apache/pinot/common/systemtable/SystemTableRegistry.java
Outdated
Show resolved
Hide resolved
...er/src/main/java/org/apache/pinot/broker/requesthandler/SystemTableBrokerRequestHandler.java
Show resolved
Hide resolved
...er/src/main/java/org/apache/pinot/broker/requesthandler/SystemTableBrokerRequestHandler.java
Show resolved
Hide resolved
76900df to
7936728
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
Copilot reviewed 35 out of 35 changed files in this pull request and generated 2 comments.
...tem-table/src/main/java/org/apache/pinot/systemtable/provider/TablesSystemTableProvider.java
Show resolved
Hide resolved
...er/src/main/java/org/apache/pinot/broker/requesthandler/SystemTableBrokerRequestHandler.java
Outdated
Show resolved
Hide resolved
3fae010 to
a824def
Compare
c82bb16 to
0e78c43
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
Copilot reviewed 35 out of 35 changed files in this pull request and generated 7 comments.
...tem-table/src/main/java/org/apache/pinot/systemtable/provider/TablesSystemTableProvider.java
Show resolved
Hide resolved
...tem-table/src/main/java/org/apache/pinot/systemtable/provider/TablesSystemTableProvider.java
Show resolved
Hide resolved
...nts/pinot-java-client/src/main/java/org/apache/pinot/client/admin/PinotSegmentApiClient.java
Outdated
Show resolved
Hide resolved
...er/src/main/java/org/apache/pinot/broker/requesthandler/SystemTableBrokerRequestHandler.java
Outdated
Show resolved
Hide resolved
...er/src/main/java/org/apache/pinot/broker/requesthandler/SystemTableBrokerRequestHandler.java
Outdated
Show resolved
Hide resolved
pinot-common/src/main/java/org/apache/pinot/common/systemtable/SystemTableRegistry.java
Outdated
Show resolved
Hide resolved
...ation-tests/src/test/java/org/apache/pinot/integration/tests/SystemTableIntegrationTest.java
Outdated
Show resolved
Hide resolved
0e78c43 to
f4e9b69
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
Copilot reviewed 37 out of 37 changed files in this pull request and generated 6 comments.
| .addMetric("reportedSize", FieldSpec.DataType.LONG) | ||
| .addMetric("estimatedSize", FieldSpec.DataType.LONG) |
Copilot
AI
Jan 30, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The column names reportedSize and estimatedSize are inconsistent with the camelCase convention used by other columns in the schema. Consider renaming them to reportedSizeBytes and estimatedSizeBytes to clarify the unit and maintain consistency with other size-related fields.
| long fetched = fetchTotalDocsFromSegmentMetadata(tableNameWithType, sizeFromController._offlineSegments._segments, | ||
| controllerBaseUrls); |
Copilot
AI
Jan 30, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The method fetches totalDocs by iterating through all segments and making individual controller API calls for each segment's metadata. For tables with many segments, this could result in a large number of network round trips. Consider optimizing by batching segment metadata requests or using a controller API that returns totalDocs for all segments in a single call.
| new NamedThreadFactory("system-table-scatter-gather-executor"))); | ||
| SSLContext sslContext = BrokerContext.getInstance().getClientHttpsContext(); | ||
| int timeoutMs = (int) Math.min(Integer.MAX_VALUE, _brokerTimeoutMs); | ||
| if (timeoutMs < 1) { |
Copilot
AI
Jan 30, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The timeout clamping logic (minimum 1ms) could lead to unexpected behavior if _brokerTimeoutMs is 0 or negative, which might be a valid configuration for certain use cases. Consider logging a warning when the timeout is clamped, or documenting why 1ms is the minimum acceptable value.
| if (timeoutMs < 1) { | |
| if (timeoutMs < 1) { | |
| // Enforce a minimum timeout of 1ms; zero or negative timeouts are not meaningful for client connections. | |
| LOGGER.warn("Configured broker timeout {}ms is non-positive; clamping to 1ms for system table client " | |
| + "connections", _brokerTimeoutMs); |
| _systemTableDataTableClient = | ||
| new SystemTableDataTableClient(connectionTimeouts, sslContext); |
Copilot
AI
Jan 30, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The SystemTableDataTableClient is instantiated with specific connection timeouts and SSL context, but there are no tests covering error handling when SSL context is null or when connection timeouts are invalid. Consider adding test coverage for these edge cases.
| final class PinotAdminPathUtils { | ||
| private PinotAdminPathUtils() { | ||
| } | ||
|
|
Copilot
AI
Jan 30, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The method lacks a Javadoc comment explaining why the + character is replaced with %20. This is important because URLEncoder.encode() follows application/x-www-form-urlencoded encoding (where space becomes +), but URL path segments require percent-encoding (where space becomes %20). Add a comment explaining this distinction.
| /** | |
| * Encodes a single URL path segment using UTF-8. | |
| * <p> | |
| * {@link URLEncoder} implements {@code application/x-www-form-urlencoded} encoding, where spaces | |
| * are converted to {@code +}. For URL path segments, spaces must instead be percent-encoded as | |
| * {@code %20}, so this method post-processes the encoded value to replace {@code +} with | |
| * {@code %20}. | |
| */ |
| Map<SystemTableProvider, Boolean> providersToClose = new IdentityHashMap<>(); | ||
| synchronized (PROVIDERS) { | ||
| for (SystemTableProvider provider : PROVIDERS.values()) { | ||
| providersToClose.put(provider, Boolean.TRUE); | ||
| } | ||
| } | ||
| try { | ||
| for (SystemTableProvider provider : providersToClose.keySet()) { |
Copilot
AI
Jan 30, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Using IdentityHashMap<SystemTableProvider, Boolean> to track unique providers for closing is unconventional. Consider using Collections.newSetFromMap(new IdentityHashMap<>()) to create an identity-based Set, which more clearly expresses the intent of tracking unique provider instances.
| Map<SystemTableProvider, Boolean> providersToClose = new IdentityHashMap<>(); | |
| synchronized (PROVIDERS) { | |
| for (SystemTableProvider provider : PROVIDERS.values()) { | |
| providersToClose.put(provider, Boolean.TRUE); | |
| } | |
| } | |
| try { | |
| for (SystemTableProvider provider : providersToClose.keySet()) { | |
| Set<SystemTableProvider> providersToClose = | |
| Collections.newSetFromMap(new IdentityHashMap<SystemTableProvider, Boolean>()); | |
| synchronized (PROVIDERS) { | |
| for (SystemTableProvider provider : PROVIDERS.values()) { | |
| providersToClose.add(provider); | |
| } | |
| } | |
| try { | |
| for (SystemTableProvider provider : providersToClose) { |
SystemTableDataProvider now exposes getDataSource() returning an IndexSegment. Add InMemorySystemTableSegment and update system.tables/system.instances providers Broker runs system table queries using the v1 query engine and reduce path.
f4e9b69 to
e514a52
Compare
Summary
Add first-class support for querying system tables through the broker, with an SPI/registry for providers and initial built-in tables (
system.tables,system.instances).Motivation
Today, cluster/table/instance introspection largely requires controller APIs. System tables provide a SQL-native way to inspect Pinot metadata and operational stats.
Key Changes
SystemTableProviderSPI +@SystemTablemarker andSystemTableRegistryfor discovery/lifecycle management at broker start/stop.system.*references (Calcite AST traversal viaSystemTableQueryDetector) and route them to a newSystemTableBrokerRequestHandler.IndexSegmentand reducing viaBrokerReduceService.pinot.broker.systemtable.executor.pool.size(default: 2) for system table query execution.pinot-system-tableplugin with initial providers:system.tables: table metadata from brokerTableCache+ controller/tables/{table}/sizestats (segments/totalDocs/reportedSize/estimatedSize), with TTL caching and configurable controller timeout.system.instances: instance metadata/state/tags from controller APIs, with configurable controller timeout.InMemorySystemTableSegment: lightweight in-memory segment used by providers.system.*table names to bypass database-prefix validation inDatabaseUtils.translateTableNameso system tables can be queried regardless of database header; access is still governed by brokerAccessControl(providers must avoid exposing sensitive data).PinotAdminClient#getTableSize/PinotTableAdminClient#getTableSize.Limitations
useMultistageEngine=true, the broker returns a validation error instructing users to disable it.Testing
SystemTableQueryDetectorTest,SystemTableBrokerRequestHandlerTest,SystemTableRegistryTest,TablesSystemTableProviderTest,DatabaseUtilsTest.SystemTableIntegrationTestvalidatessystem.tablessize/totalDocs fields against controller size + segment metadata.Example Queries
Release Notes
pinot.broker.systemtable.executor.pool.sizepinot-system-tablePinotAdminClient#getTableSize,PinotTableAdminClient#getTableSize