boluor commented on issue #3023:
URL: https://github.com/apache/doris-website/issues/3023#issuecomment-4525175803

   Thanks for the careful report. The behavior described against 2.1.5-rc02 
looks like an engine-side constant-folding bug at that time, not a doc bug. I 
re-ran your exact query (and several variants) against a current Doris 4.x 
cluster — `SUBSTRING_INDEX` now honors a dynamic `n` column correctly and 
matches MySQL.
   
   Reproduction (Doris 4.x):
   
   ```sql
   SELECT n, SUBSTRING_INDEX(bindedition, ',', n) AS res
   FROM (SELECT "_35_,_21_,_30_,_33_" AS bindedition) t1
   INNER JOIN (SELECT 1 AS n UNION ALL SELECT 2 AS n UNION ALL SELECT 3 AS n) 
t2 ON 1=1
   ORDER BY n;
   ```
   
   Result:
   
   ```
   +---+-----------------+
   | n | res             |
   +---+-----------------+
   | 1 | _35_            |
   | 2 | _35_,_21_       |
   | 3 | _35_,_21_,_30_  |
   +---+-----------------+
   ```
   
   Also confirmed working with `n` from a persistent table, with `CAST(n AS 
INT)`, and with negative `n` (right-side counting): `n=-1 → _33_`, `n=-2 → 
_30_,_33_`, `n=-3 → _21_,_30_,_33_`.
   
   `SUBSTRING_INDEX`'s `<field>` argument is documented to accept INT and does 
broadcast over column values in current versions, so the docs need no change. 
The fix should also be in recent 2.1.x patch releases — please try the latest 
2.1 build if you need to stay on that branch.
   
   Closing as engine-fixed. Please reopen if you can still reproduce on a 
recent 2.1.x or 3.x release.


-- 
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]

Reply via email to