You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@gluten.apache.org by "wForget (via GitHub)" <gi...@apache.org> on 2024/11/01 08:48:07 UTC

[I] [VL][1.2] Result mismatch of get_json_object when json string has newline [incubator-gluten]

wForget opened a new issue, #7777:
URL: https://github.com/apache/incubator-gluten/issues/7777

   ### Backend
   
   VL (Velox)
   
   ### Bug description
   
   sql:
   ```
   select get_json_object('{"c1":"test\ntest"}', '$.c1')
   ```
   
   result of gluten 1.2.0 with velox:
   ```
   +--------------------------------------------+--+
   | get_json_object({"c1":"test
   test"}, $.c1)  |
   +--------------------------------------------+--+
   | NULL                                       |
   +--------------------------------------------+--+
   ```
   
   result of valilla spark:
   ```
   +--------------------------------------------+--+
   | get_json_object({"c1":"test
   test"}, $.c1)  |
   +--------------------------------------------+--+
   | test
   test                                  |
   +--------------------------------------------+--+
   ```
   
   ### Spark version
   
   None
   
   ### Spark configurations
   
   _No response_
   
   ### System information
   
   _No response_
   
   ### Relevant logs
   
   _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: commits-unsubscribe@gluten.apache.org.apache.org

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


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@gluten.apache.org
For additional commands, e-mail: commits-help@gluten.apache.org


Re: [I] [VL][1.2] Result mismatch of get_json_object when json string has newline [incubator-gluten]

Posted by "PHILO-HE (via GitHub)" <gi...@apache.org>.
PHILO-HE commented on issue #7777:
URL: https://github.com/apache/incubator-gluten/issues/7777#issuecomment-2456273902

   > @wForget, it's strange. I just applied the below patch to test your case on Velox side ([1.2.0 velox branch](https://github.com/oap-project/velox/commits/gluten-1.2.0)), the test passed.
   > 
   > ```
   > diff --git a/velox/functions/sparksql/tests/JsonFunctionsTest.cpp b/velox/functions/sparksql/tests/JsonFunctionsTest.cpp
   > index c0c8ecc90..f9448733a 100644
   > --- a/velox/functions/sparksql/tests/JsonFunctionsTest.cpp
   > +++ b/velox/functions/sparksql/tests/JsonFunctionsTest.cpp
   > @@ -119,5 +119,9 @@ TEST_F(GetJsonObjectTest, nullResult) {
   >        std::nullopt);
   >  }
   >  
   > +TEST_F(GetJsonObjectTest, escaped) {
   > +  EXPECT_EQ(getJsonObject(R"({"c1":"test\ntest"})", "$.c1"), "test\ntest");
   > +}
   > +
   >  } // namespace
   >  } // namespace facebook::velox::functions::sparksql::test
   > ```
   
   Using regular string instead of raw string can reproduce this issue. It also occurs on the main branch. I found Presto also allows control characters, like Spark. We may have to change simdjson's code to fix this issue. But not sure whether it is acceptable. See Velox PR: https://github.com/facebookincubator/velox/pull/11433


-- 
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@gluten.apache.org

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


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@gluten.apache.org
For additional commands, e-mail: commits-help@gluten.apache.org


Re: [I] [VL][1.2] Result mismatch of get_json_object when json string has newline [incubator-gluten]

Posted by "PHILO-HE (via GitHub)" <gi...@apache.org>.
PHILO-HE commented on issue #7777:
URL: https://github.com/apache/incubator-gluten/issues/7777#issuecomment-2454217471

   @wForget, it's a known incompatibility issue in using single quotes. See dock [link](https://github.com/apache/incubator-gluten/blob/48d312a58e8554b5a0af0b998051d6217870415f/docs/velox-backend-limitations.md#json-functions).
   
   As far as I know, using single quote to enclose JSON content is not allowed in JSON standard. Not sure why Spark allows using it to replace double quote. We have no plan to support it.


-- 
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@gluten.apache.org

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


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@gluten.apache.org
For additional commands, e-mail: commits-help@gluten.apache.org


Re: [I] [VL][1.2] Result mismatch of get_json_object when json string has newline [incubator-gluten]

Posted by "PHILO-HE (via GitHub)" <gi...@apache.org>.
PHILO-HE commented on issue #7777:
URL: https://github.com/apache/incubator-gluten/issues/7777#issuecomment-2453990536

   @wForget, it's strange. I just applied the below patch to test your case on Velox side ([1.2.0 velox branch](https://github.com/oap-project/velox/commits/gluten-1.2.0)), the test passed.
   
   ```
   diff --git a/velox/functions/sparksql/tests/JsonFunctionsTest.cpp b/velox/functions/sparksql/tests/JsonFunctionsTest.cpp
   index c0c8ecc90..f9448733a 100644
   --- a/velox/functions/sparksql/tests/JsonFunctionsTest.cpp
   +++ b/velox/functions/sparksql/tests/JsonFunctionsTest.cpp
   @@ -119,5 +119,9 @@ TEST_F(GetJsonObjectTest, nullResult) {
          std::nullopt);
    }
    
   +TEST_F(GetJsonObjectTest, escaped) {
   +  EXPECT_EQ(getJsonObject(R"({"c1":"test\ntest"})", "$.c1"), "test\ntest");
   +}
   +
    } // namespace
    } // namespace facebook::velox::functions::sparksql::test
   
   ```


-- 
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@gluten.apache.org

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


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@gluten.apache.org
For additional commands, e-mail: commits-help@gluten.apache.org


Re: [I] [VL][1.2] Result mismatch of get_json_object when json string has newline [incubator-gluten]

Posted by "wForget (via GitHub)" <gi...@apache.org>.
wForget commented on issue #7777:
URL: https://github.com/apache/incubator-gluten/issues/7777#issuecomment-2454189341

   I guess this may be due to spark using some non-standard json parsing behavior.
   
   https://github.com/apache/spark/blob/c53dac05058c48ae1edad7912e8cc82533839ca0/sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/jsonExpressions.scala#L112-L113


-- 
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@gluten.apache.org

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


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@gluten.apache.org
For additional commands, e-mail: commits-help@gluten.apache.org


Re: [I] [VL][1.2] Result mismatch of get_json_object when json string has newline [incubator-gluten]

Posted by "PHILO-HE (via GitHub)" <gi...@apache.org>.
PHILO-HE commented on issue #7777:
URL: https://github.com/apache/incubator-gluten/issues/7777#issuecomment-2454037821

   @wForget, no, it's escaped. Just verified by printing `getJsonObject(R"({"c1":"test\ntest"})", "$.c1")`


-- 
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@gluten.apache.org

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


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@gluten.apache.org
For additional commands, e-mail: commits-help@gluten.apache.org


Re: [I] [VL][1.2] Result mismatch of get_json_object when json string has newline [incubator-gluten]

Posted by "wForget (via GitHub)" <gi...@apache.org>.
wForget commented on issue #7777:
URL: https://github.com/apache/incubator-gluten/issues/7777#issuecomment-2454015381

   > R"({"c1":"test\ntest"})"
   
   Does this mean that `\n` is not escaped?


-- 
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@gluten.apache.org

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


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@gluten.apache.org
For additional commands, e-mail: commits-help@gluten.apache.org


Re: [I] [VL][1.2] Result mismatch of get_json_object when json string has newline [incubator-gluten]

Posted by "rui-mo (via GitHub)" <gi...@apache.org>.
rui-mo commented on issue #7777:
URL: https://github.com/apache/incubator-gluten/issues/7777#issuecomment-2453690972

   cc: @PHILO-HE 


-- 
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@gluten.apache.org

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


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@gluten.apache.org
For additional commands, e-mail: commits-help@gluten.apache.org


Re: [I] [VL][1.2] Result mismatch of get_json_object when json string has newline [incubator-gluten]

Posted by "wForget (via GitHub)" <gi...@apache.org>.
wForget commented on issue #7777:
URL: https://github.com/apache/incubator-gluten/issues/7777#issuecomment-2454120339

   > @wForget, no, it's escaped. Just verified by printing `getJsonObject(R"({"c1":"test\ntest"})", "$.c1")`
   
   Could you try:
   
   ```
   const std::string json= R"(
     {
       "c1":"test
   test"
     }
     )";
   getJsonObject(json, "$.c1")
   ```


-- 
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@gluten.apache.org

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


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@gluten.apache.org
For additional commands, e-mail: commits-help@gluten.apache.org


Re: [I] [VL][1.2] Result mismatch of get_json_object when json string has newline [incubator-gluten]

Posted by "wForget (via GitHub)" <gi...@apache.org>.
wForget commented on issue #7777:
URL: https://github.com/apache/incubator-gluten/issues/7777#issuecomment-2454200011

   It seems that `SINGLE QUOTES` is also not allowed.
   
   ```
   select get_json_object('{\'c1\':\'test test\'}', '$.c1');
   ```
   
   gluten disabled:
   
   ```
   +--------------------------------------------+--+
   | get_json_object({'c1':'test test'}, $.c1)  |
   +--------------------------------------------+--+
   | test test                                  |
   +--------------------------------------------+--+
   ```
   
   gluten enabled:
   
   ```
   +--------------------------------------------+--+
   | get_json_object({'c1':'test test'}, $.c1)  |
   +--------------------------------------------+--+
   | NULL                                       |
   +--------------------------------------------+--+
   ```


-- 
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@gluten.apache.org

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


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@gluten.apache.org
For additional commands, e-mail: commits-help@gluten.apache.org