LakshSingla opened a new pull request, #14780:
URL: https://github.com/apache/druid/pull/14780

   ### Description
   InvalidNullByteFault for MSQ displayed the query column name (the one that 
is used internally while planning and executing the query) instead of the 
output column name (the one that is given by the user). Sometimes the two are 
similar, however, for columns involving expressions, it is not the case.
   It can be misleading for someone who is not familiar with this quirk, and 
even then it would require reading the native plan to figure out the culprit 
column.
   
   This PR uses the output column name while surfacing the fault since that is 
readily visible to the user while executing the query.
   
   <hr>
   
   For a query like:
   
   ```sql
   WITH "ext" AS (SELECT *
   FROM TABLE(
     EXTERN(
       '{"type":"inline","data":"{\"desc\":\"Normal row\",\"text\":\"Hi I am a 
normal row\"}\n{\"desc\":\"Row with NULL\",\"text\":\"There is a null in\\u0000 
here somewhere\"}\n{\"desc\":\"Anther normal row\",\"text\":\"Nice\"}\n"}',
       '{"type":"json"}'
     )
   ) EXTEND ("desc" VARCHAR, "text" VARCHAR))
   SELECT
     "desc",
     REPLACE("text", 'a', 'A') AS "text"
   FROM "ext"
   ```
   Original Behaviour:
   
   ```InvalidNullByte: Invalid null byte at source [external input source: 
InlineInputSource{data='{"desc":"Normal row","text":"Hi I am a normal row"} 
{"desc":"Row with NULL","text":"There is a null in\u0000 here somewhere"} 
{"desc":"Anther normal row","text":"Nice"} '}], rowNumber [2], column[v0], 
value[There is A null in here somewhere], position[18]. Consider sanitizing the 
string using REPLACE("v0", U&'\0000', '') AS v0. ```
   
   Notice it refers to the column as 'v0'
   
   Modified Behaviour
   ```InvalidNullByte: Invalid null byte at source [external input source: 
InlineInputSource{data='{"desc":"Normal row","text":"Hi I am a normal row"} 
{"desc":"Row with NULL","text":"There is a null in\u0000 here somewhere"} 
{"desc":"Anther normal row","text":"Nice"} '}], rowNumber [2], column[text], 
value[There is A null in here somewhere], position[18]. Consider sanitizing the 
string using REPLACE("text", U&'\0000', '') AS text. ```
   
   <hr>
   
   Note, for columns without alias, it will display it as `EXPR$<number>` which 
is still more informative than something like v0. 
   
   ```sql
   WITH "ext" AS (SELECT *
   FROM TABLE(
     EXTERN(
       '{"type":"inline","data":"{\"desc\":\"Normal row\",\"text\":\"Hi I am a 
normal row\"}\n{\"desc\":\"Row with NULL\",\"text\":\"There is a null in\\u0000 
here somewhere\"}\n{\"desc\":\"Anther normal row\",\"text\":\"Nice\"}\n"}',
       '{"type":"json"}'
     )
   ) EXTEND ("desc" VARCHAR, "text" VARCHAR))
   SELECT
     "desc",
     REPLACE("text", 'a', 'A')
   FROM "ext"
   ```
   Modified Behaviour
   ```InvalidNullByte: Invalid null byte at source [external input source: 
InlineInputSource{data='{"desc":"Normal row","text":"Hi I am a normal row"} 
{"desc":"Row with NULL","text":"There is a null in\u0000 here somewhere"} 
{"desc":"Anther normal row","text":"Nice"} '}], rowNumber [2], column[EXPR$1], 
value[There is A null in here somewhere], position[18]. Consider sanitizing the 
string using REPLACE("EXPR$1", U&'\0000', '') AS EXPR$1. ```
   
   <hr>
   
   This PR has:
   
   - [x] been self-reviewed.
      - [ ] using the [concurrency 
checklist](https://github.com/apache/druid/blob/master/dev/code-review/concurrency.md)
 (Remove this item if the PR doesn't have any relation to concurrency.)
   - [ ] added documentation for new or modified features or behaviors.
   - [ ] a release note entry in the PR description.
   - [x] added Javadocs for most classes and all non-trivial methods. Linked 
related entities via Javadoc links.
   - [ ] added or updated version, license, or notice information in 
[licenses.yaml](https://github.com/apache/druid/blob/master/dev/license.md)
   - [x] added comments explaining the "why" and the intent of the code 
wherever would not be obvious for an unfamiliar reader.
   - [x] added unit tests or modified existing tests to cover new code paths, 
ensuring the threshold for [code 
coverage](https://github.com/apache/druid/blob/master/dev/code-review/code-coverage.md)
 is met.
   - [ ] added integration tests.
   - [ ] been tested in a test Druid cluster.
   


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