You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@datafusion.apache.org by "Blizzara (via GitHub)" <gi...@apache.org> on 2024/07/11 10:27:31 UTC

[I] regexp_replace fails when pattern or replacement is a scalar NULL [datafusion]

Blizzara opened a new issue, #11410:
URL: https://github.com/apache/datafusion/issues/11410

   ### Describe the bug
   
   regexp_replace fails to produce correct number of rows if either `pattern` or `replacement` arg is a scalar NULL.  
   
   I think this is due to https://github.com/apache/datafusion/blob/7a23ea9bce32dc8ae195caa8ca052673031c06c9/datafusion/functions/src/regex/regexpreplace.rs#L316 `fetch_string_arg` not passing the correct length to the `_regexp_replace_early_abort` function - when this specific arg is a scalar, its "array len" is just 1, and the abort function creates a 1-len array as the result.
   
   ### To Reproduce
   
   Normal case - values are valid scalars or array nulls:
   ```
   > select regexp_replace(col, 'a', 'c') from (values ('a'), ('b')) as tbl(col);
   +---------------------------------------------+
   | regexp_replace(tbl.col,Utf8("a"),Utf8("c")) |
   +---------------------------------------------+
   | c                                           |
   | b                                           |
   +---------------------------------------------+
   2 row(s) fetched. 
   Elapsed 0.001 seconds.
   
   > select regexp_replace(col, ncol, 'c') from (values ('a', NULL), ('b', NULL)) as tbl(col, ncol);
   +--------------------------------------------+
   | regexp_replace(tbl.col,tbl.ncol,Utf8("c")) |
   +--------------------------------------------+
   |                                            |
   |                                            |
   +--------------------------------------------+
   ```
   
   Failing case - pattern or replacement is a scalar NULL:
   ```
   > select regexp_replace(col, NULL, 'c') from (values ('a'), ('b')) as tbl(col);
   Internal error: UDF returned a different number of rows than expected. Expected: 2, Got: 1.
   This was likely caused by a bug in DataFusion's code and we would welcome that you file an bug report in our issue tracker
   
   > select regexp_replace(col, 'a', NULL) from (values ('a'), ('b')) as tbl(col);
   Internal error: UDF returned a different number of rows than expected. Expected: 2, Got: 1.
   This was likely caused by a bug in DataFusion's code and we would welcome that you file an bug report in our issue tracker
   ```
   
   ### Expected behavior
   
   _No response_
   
   ### Additional context
   
   _No response_


-- 
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: github-unsubscribe@datafusion.apache.org.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For additional commands, e-mail: github-help@datafusion.apache.org


Re: [I] regexp_replace fails when pattern or replacement is a scalar NULL [datafusion]

Posted by "Weijun-H (via GitHub)" <gi...@apache.org>.
Weijun-H commented on issue #11410:
URL: https://github.com/apache/datafusion/issues/11410#issuecomment-2225601291

   take


-- 
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: github-unsubscribe@datafusion.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For additional commands, e-mail: github-help@datafusion.apache.org


Re: [I] regexp_replace fails when pattern or replacement is a scalar NULL [datafusion]

Posted by "alamb (via GitHub)" <gi...@apache.org>.
alamb closed issue #11410: regexp_replace fails when pattern or replacement is a scalar NULL
URL: https://github.com/apache/datafusion/issues/11410


-- 
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: github-unsubscribe@datafusion.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For additional commands, e-mail: github-help@datafusion.apache.org