-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
Allow passing database context through database
http header
#12417
Conversation
- Allow passing database through http header - Create v2 endpoints for ones which accept table name as path param or part of request body.
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #12417 +/- ##
============================================
- Coverage 61.75% 61.65% -0.10%
+ Complexity 207 198 -9
============================================
Files 2436 2455 +19
Lines 133233 134004 +771
Branches 20636 20781 +145
============================================
+ Hits 82274 82623 +349
- Misses 44911 45246 +335
- Partials 6048 6135 +87
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. |
cc @zhtaoxiang to also take a look |
pinot-broker/src/main/java/org/apache/pinot/broker/broker/helix/BaseBrokerStarter.java
Outdated
Show resolved
Hide resolved
pinot-broker/src/main/java/org/apache/pinot/broker/requesthandler/BaseBrokerRequestHandler.java
Outdated
Show resolved
Hide resolved
pinot-common/src/main/java/org/apache/pinot/common/utils/DatabaseUtils.java
Outdated
Show resolved
Hide resolved
pinot-common/src/main/java/org/apache/pinot/common/utils/DatabaseUtils.java
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.
Can we also process the path parameter during the request filtering? IIRC there is a filter that can be applied after matching the path, and I don't like the idea of adding all these v2 APIs
pinot-common/src/main/java/org/apache/pinot/common/utils/DatabaseUtils.java
Outdated
Show resolved
Hide resolved
pinot-common/src/main/java/org/apache/pinot/common/utils/DatabaseUtils.java
Outdated
Show resolved
Hide resolved
pinot-common/src/main/java/org/apache/pinot/common/utils/DatabaseUtils.java
Outdated
Show resolved
Hide resolved
pinot-common/src/main/java/org/apache/pinot/common/utils/DatabaseUtils.java
Outdated
Show resolved
Hide resolved
pinot-common/src/main/java/org/apache/pinot/common/utils/DatabaseUtils.java
Outdated
Show resolved
Hide resolved
pinot-common/src/main/java/org/apache/pinot/common/utils/DatabaseUtils.java
Outdated
Show resolved
Hide resolved
pinot-common/src/main/java/org/apache/pinot/common/utils/DatabaseUtils.java
Outdated
Show resolved
Hide resolved
Hey @Jackie-Jiang we can't update the URI in post match phase and path param context is only available there (doc ref). |
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.
I don't think we need to define a "default" database. If database is provided, then it is not default; if it is not provided, we should directly use table name as is
pinot-broker/src/main/java/org/apache/pinot/broker/requesthandler/BaseBrokerRequestHandler.java
Outdated
Show resolved
Hide resolved
pinot-broker/src/main/java/org/apache/pinot/broker/requesthandler/BaseBrokerRequestHandler.java
Outdated
Show resolved
Hide resolved
pinot-common/src/main/java/org/apache/pinot/common/config/provider/TableCache.java
Outdated
Show resolved
Hide resolved
pinot-common/src/main/java/org/apache/pinot/common/utils/DatabaseUtils.java
Outdated
Show resolved
Hide resolved
pinot-common/src/main/java/org/apache/pinot/common/utils/DatabaseUtils.java
Outdated
Show resolved
Hide resolved
pinot-common/src/main/java/org/apache/pinot/common/utils/DatabaseUtils.java
Show resolved
Hide resolved
pinot-common/src/main/java/org/apache/pinot/common/utils/DatabaseUtils.java
Outdated
Show resolved
Hide resolved
pinot-common/src/main/java/org/apache/pinot/common/utils/DatabaseUtils.java
Outdated
Show resolved
Hide resolved
pinot-common/src/main/java/org/apache/pinot/common/config/provider/TableCache.java
Outdated
Show resolved
Hide resolved
pinot-common/src/main/java/org/apache/pinot/common/utils/DatabaseUtils.java
Outdated
Show resolved
Hide resolved
pinot-common/src/main/java/org/apache/pinot/common/utils/DatabaseUtils.java
Outdated
Show resolved
Hide resolved
...ntroller/src/main/java/org/apache/pinot/controller/helix/core/PinotHelixResourceManager.java
Outdated
Show resolved
Hide resolved
...ntroller/src/main/java/org/apache/pinot/controller/helix/core/PinotHelixResourceManager.java
Outdated
Show resolved
Hide resolved
...ntroller/src/main/java/org/apache/pinot/controller/helix/core/PinotHelixResourceManager.java
Outdated
Show resolved
Hide resolved
if (schemas != null) { | ||
return schemas.stream().filter(schemaName -> isPartOfDatabase(schemaName, databaseName)) | ||
.collect(Collectors.toList()); | ||
if (databaseName != null) { |
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.
This will return all schemas when databaseName
is null
, shouldn't the null
database name be considered as the default
database and only return schemas under the default
database?
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.
Good call. We need to loop over all schemas
Preconditions.checkState( | ||
DatabaseUtils.translateTableName(tableConfigs.getTableName(), headers).equals(translatedTableName), | ||
"Table name mismatch: %s is not equivalent to %s", tableConfigs.getTableName(), tableName); | ||
tableConfigs.setTableName(DatabaseUtils.translateTableName(tableConfigs.getTableName(), headers)); |
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.
setting the table name here will make all the validations on table/schema names redundant which are part of validateConfig(tableConfigs, typesToSkip);
called below. This in a way will allow user to pass invalid schema or realtime/offline table names as ultimately it gets overridden by the translated raw table name.
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.
Good point. Changed the order
@shounakmk219 do we have documentation on this feature? |
Description
This PR aims to allow a way of passing the database context along with the API requests without disrupting the existing APIs.
The database context will be passed as a
database
http header along with the API requests. It is part of the effort to support database concept in Pinot #12333Release Notes
database
http header