You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pinot.apache.org by "xiangfu0 (via GitHub)" <gi...@apache.org> on 2026/08/24 20:56:47 UTC
[PR] Add qualified SQL identifier sanitization utility [pinot]
xiangfu0 opened a new pull request, #19352:
URL: https://github.com/apache/pinot/pull/19352
Adds `ParserUtils.sanitizeIdentifier` for safely re-emitting raw or prequoted qualified identifiers.
The utility:
- preserves valid bare Pinot identifiers and wildcards
- splits qualification only outside quoted components
- normalizes backtick and double-quoted components
- escapes unsafe components with `SqlUtils.quoteIdentifier`
- rejects malformed qualification and quoted structure
This supports query builders that receive identifiers parsed from SQL and need to preserve unquoted case-resolution semantics while preventing identifier content from changing the generated statement structure.
Validation:
- `ParserUtilsTest`: 36 tests, 0 failures
- `spotless:apply`, `license:format`, `checkstyle:check`, and `license:check` on `pinot-common`
- `git diff --check`
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@pinot.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@pinot.apache.org
For additional commands, e-mail: commits-help@pinot.apache.org
Re: [PR] Add SQL input sanitization utilities [pinot]
Posted by "xiangfu0 (via GitHub)" <gi...@apache.org>.
xiangfu0 merged PR #19352:
URL: https://github.com/apache/pinot/pull/19352
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@pinot.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@pinot.apache.org
For additional commands, e-mail: commits-help@pinot.apache.org
Re: [PR] Add qualified SQL identifier sanitization utility [pinot]
Posted by "codecov-commenter (via GitHub)" <gi...@apache.org>.
codecov-commenter commented on PR #19352:
URL: https://github.com/apache/pinot/pull/19352#issuecomment-5401670635
## [Codecov](https://app.codecov.io/gh/apache/pinot/pull/19352?dropdown=coverage&src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) Report
:x: Patch coverage is `93.24324%` with `5 lines` in your changes missing coverage. Please review.
:white_check_mark: Project coverage is 57.89%. Comparing base ([`7b6acd3`](https://app.codecov.io/gh/apache/pinot/commit/7b6acd3d5907acba8e7f7031b74be74c9e68f255?dropdown=coverage&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)) to head ([`c7691e1`](https://app.codecov.io/gh/apache/pinot/commit/c7691e16b9996fd011a29b87fbad7a92649d1d1b?dropdown=coverage&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)).
:warning: Report is 1 commits behind head on master.
| [Files with missing lines](https://app.codecov.io/gh/apache/pinot/pull/19352?dropdown=coverage&src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | Patch % | Lines |
|---|---|---|
| [...java/org/apache/pinot/sql/parsers/ParserUtils.java](https://app.codecov.io/gh/apache/pinot/pull/19352?src=pr&el=tree&filepath=pinot-common%2Fsrc%2Fmain%2Fjava%2Forg%2Fapache%2Fpinot%2Fsql%2Fparsers%2FParserUtils.java&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#diff-cGlub3QtY29tbW9uL3NyYy9tYWluL2phdmEvb3JnL2FwYWNoZS9waW5vdC9zcWwvcGFyc2Vycy9QYXJzZXJVdGlscy5qYXZh) | 93.24% | [1 Missing and 4 partials :warning: ](https://app.codecov.io/gh/apache/pinot/pull/19352?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) |
> :exclamation: There is a different number of reports uploaded between BASE (7b6acd3) and HEAD (c7691e1). Click for more details.
>
> <details><summary>HEAD has 24 uploads less than BASE</summary>
>
>| Flag | BASE (7b6acd3) | HEAD (c7691e1) |
>|------|------|------|
>|lane-a|2|0|
>|integration|4|0|
>|java-25|6|1|
>|integration2|2|0|
>|temurin|6|1|
>|lane-b|2|0|
>|unittests|2|1|
>|integration1|2|0|
>|unittests2|1|0|
></details>
<details><summary>Additional details and impacted files</summary>
```diff
@@ Coverage Diff @@
## master #19352 +/- ##
============================================
- Coverage 67.12% 57.89% -9.23%
+ Complexity 1424 1 -1423
============================================
Files 3468 2665 -803
Lines 222353 162340 -60013
Branches 34999 26281 -8718
============================================
- Hits 149247 93994 -55253
+ Misses 61200 60365 -835
+ Partials 11906 7981 -3925
```
| [Flag](https://app.codecov.io/gh/apache/pinot/pull/19352/flags?src=pr&el=flags&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | Coverage Δ | |
|---|---|---|
| [integration](https://app.codecov.io/gh/apache/pinot/pull/19352/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `?` | |
| [integration1](https://app.codecov.io/gh/apache/pinot/pull/19352/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `?` | |
| [integration2](https://app.codecov.io/gh/apache/pinot/pull/19352/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `?` | |
| [java-25](https://app.codecov.io/gh/apache/pinot/pull/19352/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `57.89% <93.24%> (-9.23%)` | :arrow_down: |
| [lane-a](https://app.codecov.io/gh/apache/pinot/pull/19352/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `?` | |
| [lane-b](https://app.codecov.io/gh/apache/pinot/pull/19352/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `?` | |
| [temurin](https://app.codecov.io/gh/apache/pinot/pull/19352/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `57.89% <93.24%> (-9.23%)` | :arrow_down: |
| [unittests](https://app.codecov.io/gh/apache/pinot/pull/19352/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `57.89% <93.24%> (-9.22%)` | :arrow_down: |
| [unittests1](https://app.codecov.io/gh/apache/pinot/pull/19352/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `57.89% <93.24%> (+<0.01%)` | :arrow_up: |
| [unittests2](https://app.codecov.io/gh/apache/pinot/pull/19352/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `?` | |
Flags with carried forward coverage won't be shown. [Click here](https://docs.codecov.io/docs/carryforward-flags?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#carryforward-flags-in-the-pull-request-comment) to find out more.
</details>
[:umbrella: View full report in Codecov by Harness](https://app.codecov.io/gh/apache/pinot/pull/19352?dropdown=coverage&src=pr&el=continue&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache).
:loudspeaker: Have feedback on the report? [Share it here](https://about.codecov.io/codecov-pr-comment-feedback/?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache).
<details><summary> :rocket: New features to boost your workflow: </summary>
- :package: [JS Bundle Analysis](https://docs.codecov.com/docs/javascript-bundle-analysis): Save yourself from yourself by tracking and limiting bundle sizes in JS merges.
</details>
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@pinot.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@pinot.apache.org
For additional commands, e-mail: commits-help@pinot.apache.org
Re: [PR] Add SQL input sanitization utilities [pinot]
Posted by "xiangfu0 (via GitHub)" <gi...@apache.org>.
xiangfu0 commented on code in PR #19352:
URL: https://github.com/apache/pinot/pull/19352#discussion_r3847674536
##########
pinot-common/src/main/java/org/apache/pinot/sql/parsers/ParserUtils.java:
##########
@@ -18,14 +18,41 @@
*/
package org.apache.pinot.sql.parsers;
+import java.util.ArrayList;
import java.util.List;
+import java.util.Objects;
+import java.util.StringJoiner;
import org.apache.pinot.common.request.Expression;
+import org.apache.pinot.common.request.ExpressionType;
+import org.apache.pinot.spi.utils.SqlUtils;
public class ParserUtils {
private ParserUtils() {
}
+ /// Converts a raw or SQL-quoted identifier into a safe SQL identifier fragment. Qualified identifiers are split on
+ /// dots outside quoted components. Valid bare Pinot identifier components and wildcards remain bare, while other
+ /// components are double-quoted. Backtick-quoted and double-quoted components are normalized to double quotes.
+ ///
+ /// @param identifier Raw or SQL-quoted identifier, optionally qualified
+ /// @return Identifier formatted for use in a SQL statement
+ /// @throws NullPointerException If the identifier is null
+ /// @throws IllegalArgumentException If the identifier is empty or has invalid quoted structure
+ public static String sanitizeIdentifier(String identifier) {
+ Objects.requireNonNull(identifier, "identifier cannot be null");
Review Comment:
Removed the explicit null check. The unannotated identifier argument now follows Pinot non-null conventions.
##########
pinot-common/src/main/java/org/apache/pinot/sql/parsers/ParserUtils.java:
##########
@@ -18,14 +18,41 @@
*/
package org.apache.pinot.sql.parsers;
+import java.util.ArrayList;
import java.util.List;
+import java.util.Objects;
+import java.util.StringJoiner;
import org.apache.pinot.common.request.Expression;
+import org.apache.pinot.common.request.ExpressionType;
+import org.apache.pinot.spi.utils.SqlUtils;
public class ParserUtils {
private ParserUtils() {
}
+ /// Converts a raw or SQL-quoted identifier into a safe SQL identifier fragment. Qualified identifiers are split on
+ /// dots outside quoted components. Valid bare Pinot identifier components and wildcards remain bare, while other
+ /// components are double-quoted. Backtick-quoted and double-quoted components are normalized to double quotes.
+ ///
+ /// @param identifier Raw or SQL-quoted identifier, optionally qualified
+ /// @return Identifier formatted for use in a SQL statement
+ /// @throws NullPointerException If the identifier is null
+ /// @throws IllegalArgumentException If the identifier is empty or has invalid quoted structure
+ public static String sanitizeIdentifier(String identifier) {
+ Objects.requireNonNull(identifier, "identifier cannot be null");
+ String trimmed = identifier.trim();
+ if (trimmed.isEmpty()) {
+ throw new IllegalArgumentException("identifier cannot be empty");
+ }
+
+ StringJoiner result = new StringJoiner(".");
Review Comment:
Added a fast path for identifiers with no `.`, backtick, or double quote. It avoids qualified-name splitting and `StringJoiner` allocation while preserving `*` through the segment sanitizer.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@pinot.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@pinot.apache.org
For additional commands, e-mail: commits-help@pinot.apache.org
Re: [PR] Add qualified SQL identifier sanitization utility [pinot]
Posted by "Jackie-Jiang (via GitHub)" <gi...@apache.org>.
Jackie-Jiang commented on code in PR #19352:
URL: https://github.com/apache/pinot/pull/19352#discussion_r3847487273
##########
pinot-common/src/main/java/org/apache/pinot/sql/parsers/ParserUtils.java:
##########
@@ -18,14 +18,41 @@
*/
package org.apache.pinot.sql.parsers;
+import java.util.ArrayList;
import java.util.List;
+import java.util.Objects;
+import java.util.StringJoiner;
import org.apache.pinot.common.request.Expression;
+import org.apache.pinot.common.request.ExpressionType;
+import org.apache.pinot.spi.utils.SqlUtils;
public class ParserUtils {
private ParserUtils() {
}
+ /// Converts a raw or SQL-quoted identifier into a safe SQL identifier fragment. Qualified identifiers are split on
+ /// dots outside quoted components. Valid bare Pinot identifier components and wildcards remain bare, while other
+ /// components are double-quoted. Backtick-quoted and double-quoted components are normalized to double quotes.
+ ///
+ /// @param identifier Raw or SQL-quoted identifier, optionally qualified
+ /// @return Identifier formatted for use in a SQL statement
+ /// @throws NullPointerException If the identifier is null
+ /// @throws IllegalArgumentException If the identifier is empty or has invalid quoted structure
+ public static String sanitizeIdentifier(String identifier) {
+ Objects.requireNonNull(identifier, "identifier cannot be null");
Review Comment:
(nit) We don't usually do this check, but assume unannotated argument as non-null
##########
pinot-common/src/main/java/org/apache/pinot/sql/parsers/ParserUtils.java:
##########
@@ -18,14 +18,41 @@
*/
package org.apache.pinot.sql.parsers;
+import java.util.ArrayList;
import java.util.List;
+import java.util.Objects;
+import java.util.StringJoiner;
import org.apache.pinot.common.request.Expression;
+import org.apache.pinot.common.request.ExpressionType;
+import org.apache.pinot.spi.utils.SqlUtils;
public class ParserUtils {
private ParserUtils() {
}
+ /// Converts a raw or SQL-quoted identifier into a safe SQL identifier fragment. Qualified identifiers are split on
+ /// dots outside quoted components. Valid bare Pinot identifier components and wildcards remain bare, while other
+ /// components are double-quoted. Backtick-quoted and double-quoted components are normalized to double quotes.
+ ///
+ /// @param identifier Raw or SQL-quoted identifier, optionally qualified
+ /// @return Identifier formatted for use in a SQL statement
+ /// @throws NullPointerException If the identifier is null
+ /// @throws IllegalArgumentException If the identifier is empty or has invalid quoted structure
+ public static String sanitizeIdentifier(String identifier) {
+ Objects.requireNonNull(identifier, "identifier cannot be null");
+ String trimmed = identifier.trim();
+ if (trimmed.isEmpty()) {
+ throw new IllegalArgumentException("identifier cannot be empty");
+ }
+
+ StringJoiner result = new StringJoiner(".");
Review Comment:
Please optimize for the common case where this is no `.` or quote. Same for other places. We should only pay overhead for the uncommon case
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@pinot.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@pinot.apache.org
For additional commands, e-mail: commits-help@pinot.apache.org