Harsh Motwani created SPARK-51740:
-------------------------------------

             Summary: get_json_object path parsing ignores leading spaces
                 Key: SPARK-51740
                 URL: https://issues.apache.org/jira/browse/SPARK-51740
             Project: Spark
          Issue Type: Bug
          Components: SQL
    Affects Versions: 3.5.0
            Reporter: Harsh Motwani
             Fix For: 4.0.0


The `get_json_object` expression does not consider leading spaces in the JSON 
path. In this example, the second key is referenced even though the path refers 
to the first key:

{code:java}
scala> spark.sql("""select get_json_object('{" a b c ": " leading space 
present", "a b c ": "leading space absent"}', "$[' a b c ']")""").show()
+------------------------------------------------------------------------------------------------------+
|get_json_object({" a b c ": " leading space present", "a b c ": "leading space 
absent"}, $[' a b c '])|
+------------------------------------------------------------------------------------------------------+
|                                                                               
   leading space absent|
+------------------------------------------------------------------------------------------------------+

{code}




--
This message was sent by Atlassian Jira
(v8.20.10#820010)

---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscr...@spark.apache.org
For additional commands, e-mail: issues-h...@spark.apache.org

Reply via email to