hangedfish opened a new issue, #61119: URL: https://github.com/apache/doris/issues/61119
### Search before asking - [x] I had searched in the [issues](https://github.com/apache/doris/issues?q=is%3Aissue) and found no similar issues. ### Version 4.0.3 ### What's Wrong? When querying a STRUCT column that contains a string with double quotes (`"`), the output format does not escape the inner double quotes. Instead, Doris represents them by doubling the quotes (e.g., `""aa""`), which is its internal string literal rule. This output is not standard JSON and causes parsing failures in applications that expect valid JSON (e.g., MyBatis throws JSON parse error). Example: For a STRUCT value `STRUCT('"aa"')`, the direct query returns `{"a":""aa""}` instead of a properly escaped JSON string like `{"a":"\"aa\""}`. ### What You Expected? I expected the direct SELECT output of a STRUCT column to be a valid JSON string, with double quotes properly escaped using backslashes (`\"`), so that it can be parsed by standard JSON libraries without extra conversion. Alternatively, if the current format is intentional, it would be helpful to clarify the specification of STRUCT's text representation and consider aligning it with JSON standards for better interoperability. ### How to Reproduce? 1. Create a table with a STRUCT column: ```SQL CREATE TABLE t_st_test ( pk INT, st STRUCT<a: STRING> ) PROPERTIES ("replication_num" = "1"); ``` 2. Insert a row where the STRUCT's string field contains double quotes: ```SQL INSERT INTO t_st_test(pk, st) VALUES (1, STRUCT('"aa"')); ``` 3. Query the STRUCT column directly: ```SQL SELECT st FROM t_st_test; ``` **Actual output**: `{"a":""aa""}` **Expected output (for comparison)**: `{"a":"\"aa\""}` (obtained via `CAST(st AS JSON)`) ### Anything Else? * **Temporary workaround**: Use `CAST(st AS JSON)` in queries or create a view to provide a JSON-compatible output, e.g.: ```SQL CREATE VIEW v_st_test AS SELECT pk, CAST(st AS JSON) AS st FROM t_st_test; ``` However, this adds extra conversion overhead and requires application-level awareness. * **Question**: What is the defined output format for STRUCT when selected directly? Is it intended to be a JSON-compatible representation? If not, are there plans to make it JSON-compatible by default to reduce friction for applications? * This issue is particularly noticeable when string values contain double quotes, as it breaks JSON parsing in many client tools. ### Are you willing to submit PR? - [ ] Yes I am willing to submit a PR! ### Code of Conduct - [x] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct) -- 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]
