MeihanLi commented on PR #17177:
URL: https://github.com/apache/pinot/pull/17177#issuecomment-3564913513
> > ```
> > "SELECT col1 FROM table1 WHERE col2 IN (100, 200, 300)"
> > => "SELECT `col1` FROM `table1` WHERE `col2` IN (?, ?, ?)"
> > "SELECT col1 FROM table1 WHERE col2 IN (SELECT col2 FROM table2 WHERE
col3 = 100)"
> > => "SELECT `col1` FROM `table1` WHERE `col2` IN (SELECT `col2` FROM
`table2` WHERE `col3` = ?)"
> > ```
>
> Can we generate only one ? for IN
@kishoreg Thanks for the suggestion, we now generate only one ? for IN/NOT
clause with all non-preserved data literals.
Case 1: All values are data literals → replace entire list with a single ?
```
"SELECT col1 FROM table1 WHERE col2 IN (1)";
"SELECT col1 FROM table1 WHERE col2 IN (1, 2, 3)";
"SELECT col1 FROM table1 WHERE col2 IN (5, 10, 15, 20, 25, 30)";
-> SELECT col1 FROM table1 WHERE col2 IN (?)
```
Case 2: Contains any of the following → visit each value individually and
replace only data literals
- Preserved literals (NULL, etc.): IN (1, NULL, 3) → IN (?, NULL, ?)
- Expressions: IN (col1 + 1, 2) → IN (col1 + ?, ?)
- Function calls: IN (UPPER('a'), LOWER('b')) → IN (UPPER(?), LOWER(?))
- Subquery: IN (SELECT ...) → visits the subquery normally
You can check QueryFingerprintVisitor::visitIn function and
QueryFingerprintVisitorTest for more 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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]