-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Allow table name with dots by a PinotConfiguration switch #8713
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
Conversation
pinot-broker/src/main/java/org/apache/pinot/broker/requesthandler/BaseBrokerRequestHandler.java
Outdated
Show resolved
Hide resolved
pinot-segment-local/src/main/java/org/apache/pinot/segment/local/utils/TableConfigUtils.java
Outdated
Show resolved
Hide resolved
pinot-spi/src/main/java/org/apache/pinot/spi/utils/CommonConstants.java
Outdated
Show resolved
Hide resolved
|
IMO this doesn't even need a feature flag. We're not breaking any behavior. Keeps things simple. |
|
@apucher Good point. Let me list down the things we are trying to handle with
If we allow |
|
it should be easy to parse the table name since it needs to be present in the FROM clause. are nested field selects a thing yet? |
I think the
We don't support it yet, but it is in our roadmap, so we should take them into consideration I think using dot in table name (or any field name) is in general bad practice because dot is already reserved for other purpose. @dongxiaoman I think we should just use Some reference about not using
|
|
There's precedent for using dots as separators across databases/schemas in MySQL, MSSQL, and others. It's tricky in the sense that underscores are much more commonly used in name tables. Both, underscores and dots, could work. My hunch is that we'll ultimately have to support dots (to separate namespaces) as most cloud analytics systems already do:
|
|
Agree on using dot to connect db/namespace and table name and column name (this is the standard SQL syntax). |
|
@Jackie-Jiang Agree that using dot in table name is in general practice not so compatible. I already saw JDBC H2 error if I copy/paste the Full integration test because JDBC engine treat dots as separator by default. That is why I hide the support with a feature flag. cc @apucher . The H2 error can be bypassed by using backticks. Meanwhile, as I mentioned, table name with dots can provide a transition/middle ground before we fully support full multi-tenant/DB concept. If this is not breaking other features, providing extra flexibility (extra knob) will help support more use cases, it actually expands Pinot's scope |
|
Sounds good. I think we can limit the flexibility of the table name to contain at most one dot, and assume the name is constructed from
|
f4f77f9 to
c484a75
Compare
...t-segment-local/src/test/java/org/apache/pinot/segment/local/utils/TableConfigUtilsTest.java
Outdated
Show resolved
Hide resolved
| String tableName = tableConfig.getTableName(); | ||
| if (tableName.contains(".") || tableName.contains(" ")) { | ||
| throw new IllegalStateException("Table name: '" + tableName + "' containing '.' or space is not allowed"); | ||
| if (tableName.contains(".") && !allowDots) { |
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.
Let's check that the table name contains at most one dot, and put some comments explaining we allow table name with embedded database 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.
Added logic and also unit tests
pinot-spi/src/main/java/org/apache/pinot/spi/utils/CommonConstants.java
Outdated
Show resolved
Hide resolved
| */ | ||
| private String getActualTableName(String tableName) { | ||
| @VisibleForTesting | ||
| static String getActualTableName(String tableName, TableCache tableCache, BrokerRoutingManager routingManager, |
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.
We might not want to change this method. Even if we allow table name with database, we should probably still support the case of table name without 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.
Right now the code change has only one effect:
If we allow dots in table name, we will avoid striping the [database_name]. from the table name. This will be needed in our case, that we wish to treat [database_name].[table_name] as the whole actual table name.
This behavior is under the feature flag so will be backwards compatible.
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.
What I meant is that the existing code should already be able to handle the [database_name].[table_name] as the table name (line 773, 801, 812 in the original code). We don't need to introduce the extra logic of reading properties from the config.
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 see. I did not expect the behavior to be the same but you are right.
I am still keeping the unit tests since they will ensure our expected behavior is not broken
Codecov Report
@@ Coverage Diff @@
## master #8713 +/- ##
============================================
- Coverage 68.17% 62.86% -5.32%
+ Complexity 4619 4605 -14
============================================
Files 1735 1689 -46
Lines 91320 89304 -2016
Branches 13644 13415 -229
============================================
- Hits 62258 56141 -6117
- Misses 24714 29132 +4418
+ Partials 4348 4031 -317
Flags with carried forward coverage won't be shown. Click here to find out more.
Continue to review full report at Codecov.
|
6fb5f84 to
2b6898a
Compare
pinot-common/src/main/java/org/apache/pinot/common/config/provider/TableCache.java
Outdated
Show resolved
Hide resolved
80edebc to
9e8d510
Compare
Jackie-Jiang
left a comment
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.
LGTM other wise
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
...oller/src/main/java/org/apache/pinot/controller/api/resources/PinotTableRestletResource.java
Outdated
Show resolved
Hide resolved
...ler/src/main/java/org/apache/pinot/controller/api/resources/TableConfigsRestletResource.java
Outdated
Show resolved
Hide resolved
pinot-segment-local/src/main/java/org/apache/pinot/segment/local/utils/TableConfigUtils.java
Outdated
Show resolved
Hide resolved
pinot-segment-local/src/main/java/org/apache/pinot/segment/local/utils/TableConfigUtils.java
Outdated
Show resolved
Hide resolved
pinot-segment-local/src/main/java/org/apache/pinot/segment/local/utils/TableConfigUtils.java
Outdated
Show resolved
Hide resolved
cbd751f to
94d6b8c
Compare
94d6b8c to
3d1ec09
Compare
|
@Jackie-Jiang Sorry for the late response. Can you please have another quick look? All comments addressed |
Description
Following changes in #5734,
Allows table name with dots by a shared pinot property. This will allow table name format like
namespace.table_nameto avoid table_name conflict while providing some mitigation/middle ground before Pinot table goes true multi-tenant.The use case this one PR enabled will be for some users sharing a same Pinot Cluster, with the below Example rules (not in Pinot, but only with the wrapper/UI or some toolset visible to user):
test;testand write query freely/naturally with table name likeuser_namespace.testExtended feature
Extract column name only after the last dot in cases like
SELECT db.namespace.table.column_name from db.namespace.table. In the example the table name will bedb.namespace.tableTests Done
Many Unit tests
Release Notes
pinot.table.name.dots.enabledconfig to Controllers and Brokers to allow table name with dots.