I have a json object column in a table (using redshift as our data warehouse) that contains web event properties:
{
"Page URL":"http://foo.bar/some-utm-properties",
"discount_code":"some discount code",
"eventSource":"fooevent",
"uniqueId":"1234xyz",
"referringDomain":"foobar.com",
}
I am trying to extract the values from the object for the key "Page URL". I am able to write a query that returns values for the other keys that do not contain a space, however this one I have not been able to figure out.
Below is the query i have written that is successful for the other keys but not "Page URL"
with parse as (
select
event_properties,
json_parse(event_properties) as event_prop_json
from web_event
)
select
event_prop_json.["Page URL"] as page_url,
event_prop_json.["discount_code"] as discount_code
from parse
From this query on the above object I get the below results:
Column A | Column B |
---|---|
NULL | "some discount code" |
I have tried various methods of configuring the query statement ( event_prop_json.[""Page URL""], event_prop_json.["\"Page URL\""], event_prop_json."Page URL", event_prop_json.'"Page URL"', etc.) some with errors others returning NULL as well. Any help would be greatly appreciated!
Are you sure it is the space? I suspect it is the upper case letters. Redshift by default is case insensitive (translates to lower case) but when dealing with super keys it translates everything to lower case.
Try turning on case sensitivity:
SET enable_case_sensitive_identifier TO true;
However, this enables case sensitivity for all table and column references so you may need to modify some queries or turn this option on and off around they queries that need case sensitivity.