github-actions[bot] commented on code in PR #62741:
URL: https://github.com/apache/doris/pull/62741#discussion_r3145202724
##########
be/src/core/data_type_serde/data_type_struct_serde.cpp:
##########
@@ -587,14 +587,20 @@ Status
DataTypeStructSerDe::from_string_strict_mode(StringRef& str, IColumn& col
void DataTypeStructSerDe::to_string(const IColumn& column, size_t row_num,
BufferWritable& bw,
const DataTypeSerDe::FormatOptions&
options) const {
const auto& struct_column = assert_cast<const ColumnStruct&>(column);
+
+ // Enable JSON escaping for nested strings in STRUCT
+ FormatOptions struct_options = options;
+ struct_options.escape_char = '\\';
Review Comment:
This only turns on escaping for `STRUCT::to_string()`, but the user-facing
text path for top-level `ARRAY` and `MAP` still goes through
`DataTypeArraySerDe::to_string()` / `DataTypeMapSerDe::to_string()` with
`escape_char == 0` from `VMysqlResultWriter` and `CastToString`. So `SELECT
array('"a"', '"b"')` still renders as `[""a"", ""b""]` (you can still see that
in the updated `test_query_json_insert.out` golden), which means the PR does
not actually fix the stated `STRUCT/MAP/ARRAY` scope yet. Please either enable
escaping for the parallel array/map text serializers too, or set the flag once
at the top-level DORIS text-output entry point so every nested string path is
covered consistently.
##########
regression-test/suites/query_p0/sql_functions/struct_functions/test_struct_special_chars.groovy:
##########
@@ -0,0 +1,68 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements. See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership. The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License. You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied. See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+suite("test_struct_special_chars") {
+ def tableName = "t_struct_special_chars"
+
+ sql "DROP TABLE IF EXISTS ${tableName}"
+ sql """
+ CREATE TABLE ${tableName} (
+ pk INT,
+ st STRUCT<a: STRING>
+ ) PROPERTIES ("replication_num" = "1")
+ """
+
+ // Insert string with double quotes
+ sql """INSERT INTO ${tableName}(pk, st) VALUES (1, STRUCT('"aa"'))"""
+
+ // Direct SELECT should output valid JSON with escaped quotes
+ qt_select_struct_quotes """SELECT st FROM ${tableName} WHERE pk = 1"""
Review Comment:
Issue #61119 and the PR description both call out `STRUCT/MAP/ARRAY`, but
this new regression only exercises `STRUCT`. Since array/map use parallel
text-serialization paths, this suite does not prove the full fix or catch the
still-broken array/map cases. Please add array<string> / map<string,string>
cases with quotes, backslashes, newlines, and tabs here as well.
--
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]