forked from apache/doris
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Fix](Nereids) Fix datatype length wrong when string contains chinese (…
…apache#29885) When varchar literal contains chinese, the length of varchar should not be the length of the varchar, it should be the actual length of the using byte. Chinese is represented by unicode, a chinese char occypy 4 byte at mostly. So if meet chinese in varchar literal, we set the length is 4* length. for example as following: > CREATE MATERIALIZED VIEW test_varchar_literal_mv > BUILD IMMEDIATE REFRESH AUTO ON MANUAL > DISTRIBUTED BY RANDOM BUCKETS 2 > PROPERTIES ('replication_num' = '1') > AS > select case when l_orderkey > 1 then "一二三四" else "五六七八" end as field_1 from lineitem; mysql> desc test_varchar_literal_mv; the def of materialized view is as following: +---------+-------------+------+-------+---------+-------+ | Field | Type | Null | Key | Default | Extra | +---------+-------------+------+-------+---------+-------+ | field_1 | VARCHAR(16) | No | false | NULL | NONE | +---------+-------------+------+-------+---------+-------+
- Loading branch information
Showing
6 changed files
with
119 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
35 changes: 35 additions & 0 deletions
35
fe/fe-core/src/test/java/org/apache/doris/nereids/util/UtilsTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
// 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. | ||
|
||
package org.apache.doris.nereids.util; | ||
|
||
import org.junit.jupiter.api.Assertions; | ||
import org.junit.jupiter.api.Test; | ||
|
||
/** | ||
* The tests for utils | ||
*/ | ||
public class UtilsTest { | ||
@Test | ||
public void containChinese() { | ||
String chinese = "123数据库"; | ||
Assertions.assertTrue(Utils.containChinese(chinese)); | ||
|
||
String en = "database123"; | ||
Assertions.assertFalse(Utils.containChinese(en)); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -60,3 +60,6 @@ zhangsang 200 | |
-- !select_union -- | ||
11 111 | ||
|
||
-- !desc_mv -- | ||
field_1 VARCHAR(16) No false \N NONE | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters