Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 7 additions & 4 deletions be/src/exec/tablet_info.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ Status OlapTableSchemaParam::init(const POlapTableSchemaParam& pschema) {
for (auto& col : pschema.partial_update_input_columns()) {
_partial_update_input_columns.insert(col);
}
std::unordered_map<std::pair<std::string, std::string>, SlotDescriptor*> slots_map;
std::unordered_map<std::pair<std::string, FieldType>, SlotDescriptor*> slots_map;
_tuple_desc = _obj_pool.add(new TupleDescriptor(pschema.tuple_desc()));
// When FE version is less than 2.0.3, But BE upgrade to 2.0.3,
// the filed col_type in slot_desc is INVALID_TYPE default.
Expand All @@ -81,7 +81,8 @@ Status OlapTableSchemaParam::init(const POlapTableSchemaParam& pschema) {
_tuple_desc->add_slot(slot_desc);
string data_type;
EnumToString(TPrimitiveType, to_thrift(slot_desc->col_type()), data_type);
slots_map.emplace(std::make_pair(to_lower(slot_desc->col_name()), std::move(data_type)),
slots_map.emplace(std::make_pair(to_lower(slot_desc->col_name()),
TabletColumn::get_field_type_by_string(data_type)),
slot_desc);
}

Expand All @@ -92,8 +93,10 @@ Status OlapTableSchemaParam::init(const POlapTableSchemaParam& pschema) {
for (auto& pcolumn_desc : p_index.columns_desc()) {
if (!_is_partial_update ||
_partial_update_input_columns.count(pcolumn_desc.name()) > 0) {
std::string col_type = has_invalid_type ? "INVALID_TYPE" : pcolumn_desc.type();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can't remove this

auto it = slots_map.find(std::make_pair(to_lower(pcolumn_desc.name()), col_type));
auto it = slots_map.find(std::make_pair(
to_lower(pcolumn_desc.name()),
TabletColumn::get_field_type_by_string(
has_invalid_type ? "INVALID_TYPE" : pcolumn_desc.type())));
if (it == std::end(slots_map)) {
return Status::InternalError("unknown index column, column={}, type={}",
pcolumn_desc.name(), pcolumn_desc.type());
Expand Down
1 change: 0 additions & 1 deletion be/src/pipeline/pipeline_task.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -308,7 +308,6 @@ Status PipelineTask::_collect_query_statistics() {
return Status::OK();
}


Status PipelineTask::try_close() {
if (_try_close_flag) {
return Status::OK();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -373,6 +373,40 @@ public static ScalarType createDecimalV3Type(String precisionStr, String scaleSt
return type;
}

public static ScalarType createDecimalV2Type() {
Preconditions.checkState(!Config.disable_decimalv2, "DecimalV2 is disable in fe.conf!");
return DEFAULT_DECIMALV2;
}

public static ScalarType createDecimalV2Type(int precision) {
Preconditions.checkState(!Config.disable_decimalv2, "DecimalV2 is disable in fe.conf!");
return createDecimalV2Type(precision, DEFAULT_SCALE);
}

public static ScalarType createDecimalV2Type(int precision, int scale) {
Preconditions.checkState(!Config.disable_decimalv2, "DecimalV2 is disable in fe.conf!");
ScalarType type = new ScalarType(PrimitiveType.DECIMALV2);
type.precision = precision;
type.scale = scale;
return type;
}

public static ScalarType createDecimalV2Type(String precisionStr) {
Preconditions.checkState(!Config.disable_decimalv2, "DecimalV2 is disable in fe.conf!");
ScalarType type = new ScalarType(PrimitiveType.DECIMALV2);
type.precisionStr = precisionStr;
type.scaleStr = null;
return type;
}

public static ScalarType createDecimalV2Type(String precisionStr, String scaleStr) {
Preconditions.checkState(!Config.disable_decimalv2, "DecimalV2 is disable in fe.conf!");
ScalarType type = new ScalarType(PrimitiveType.DECIMALV2);
type.precisionStr = precisionStr;
type.scaleStr = scaleStr;
return type;
}

public static PrimitiveType getSuitableDecimalType(int precision, boolean decimalV2) {
if (decimalV2 && !Config.enable_decimal_conversion) {
return PrimitiveType.DECIMALV2;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,7 @@ DAY: 'DAY';
DAYS_ADD: 'DAYS_ADD';
DAYS_SUB: 'DAYS_SUB';
DECIMAL: 'DECIMAL';
DECIMALV2: 'DECIMALV2';
DECIMALV3: 'DECIMALV3';
DECOMMISSION: 'DECOMMISSION';
DEFAULT: 'DEFAULT';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -490,6 +490,7 @@ primitiveColType:
| type=VARCHAR
| type=CHAR
| type=DECIMAL
| type=DECIMALV2
| type=DECIMALV3
| type=ALL
;
Expand Down Expand Up @@ -610,6 +611,7 @@ nonReserved
| DAYS_ADD
| DAYS_SUB
| DECIMAL
| DECIMALV2
| DECIMALV3
| DEFERRED
| DEMAND
Expand Down
13 changes: 13 additions & 0 deletions fe/fe-core/src/main/cup/sql_parser.cup
Original file line number Diff line number Diff line change
Expand Up @@ -328,6 +328,7 @@ terminal String
KW_DATEV2,
KW_DAY,
KW_DECIMAL,
KW_DECIMALV2,
KW_DECIMALV3,
KW_DECOMMISSION,
KW_DEFAULT,
Expand Down Expand Up @@ -6285,6 +6286,16 @@ type ::=
{: RESULT = ScalarType.createDecimalV3Type(precision); :}
| KW_DECIMALV3 LPAREN ident_or_text:precision COMMA ident_or_text:scale RPAREN
{: RESULT = ScalarType.createDecimalV3Type(precision, scale); :}
| KW_DECIMALV2 LPAREN INTEGER_LITERAL:precision RPAREN
{: RESULT = ScalarType.createDecimalV2Type(precision.intValue()); :}
| KW_DECIMALV2 LPAREN INTEGER_LITERAL:precision COMMA INTEGER_LITERAL:scale RPAREN
{: RESULT = ScalarType.createDecimalV2Type(precision.intValue(), scale.intValue()); :}
| KW_DECIMALV2
{: RESULT = ScalarType.createDecimalV2Type(); :}
| KW_DECIMALV2 LPAREN ident_or_text:precision RPAREN
{: RESULT = ScalarType.createDecimalV2Type(precision); :}
| KW_DECIMALV2 LPAREN ident_or_text:precision COMMA ident_or_text:scale RPAREN
{: RESULT = ScalarType.createDecimalV2Type(precision, scale); :}
| KW_HLL
{: ScalarType type = ScalarType.createHllType();
RESULT = type;
Expand Down Expand Up @@ -7402,6 +7413,8 @@ keyword ::=
{: RESULT = id; :}
| KW_DEMAND:id
{: RESULT = id; :}
| KW_DECIMALV2:id
{: RESULT = id; :}
| KW_DECIMALV3:id
{: RESULT = id; :}
| KW_DIAGNOSE:id
Expand Down
1 change: 1 addition & 0 deletions fe/fe-core/src/main/jflex/sql_scanner.flex
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,7 @@ import org.apache.doris.qe.SqlModeHelper;
keywordMap.put("time", new Integer(SqlParserSymbols.KW_TIME));
keywordMap.put("day", new Integer(SqlParserSymbols.KW_DAY));
keywordMap.put("decimal", new Integer(SqlParserSymbols.KW_DECIMAL));
keywordMap.put("decimalv2", new Integer(SqlParserSymbols.KW_DECIMALV2));
keywordMap.put("decimalv3", new Integer(SqlParserSymbols.KW_DECIMALV3));
keywordMap.put("decommission", new Integer(SqlParserSymbols.KW_DECOMMISSION));
keywordMap.put("default", new Integer(SqlParserSymbols.KW_DEFAULT));
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
-- This file is automatically generated. You should know what you did if you want to edit this
-- !select_all --
\N \N \N \N
1.10000 1.20000 1.30000 1.40000
2.10000 1.20000 1.30000 1.40000

-- !select_pred_decimal32_key --
1.10000 1.20000 1.30000 1.40000

-- !select_pred_decimal32_key --
1.10000 1.20000 1.30000 1.40000

Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
// 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_uniq_tab_decimalv2") {

def table1 = "test_uniq_tab_decimalv2"

sql "drop table if exists ${table1}"

sql """
CREATE TABLE IF NOT EXISTS `${table1}` (
`decimal_key1` decimalv2(8, 5) NULL COMMENT "",
`decimal_key2` decimalv2(16, 5) NULL COMMENT "",
`decimal_value1` decimalv2(8, 5) NULL COMMENT "",
`decimal_value2` decimalv2(16, 5) NULL COMMENT "",
) ENGINE=OLAP
UNIQUE KEY(`decimal_key1`, `decimal_key2`)
COMMENT "OLAP"
DISTRIBUTED BY HASH(`decimal_key1`, `decimal_key2`) BUCKETS 8
PROPERTIES (
"replication_allocation" = "tag.location.default: 1",
"in_memory" = "false",
"storage_format" = "V2"
)
"""

sql """insert into ${table1} values(1.1,1.2,1.3,1.4),
(1.1,1.2,1.3,1.4),
(1.1,1.2,1.3,1.4),
(1.1,1.2,1.3,1.4),
(1.1,1.2,1.3,1.4),
(2.1,1.2,1.3,1.4),
(2.1,1.2,1.3,1.4),
(2.1,1.2,1.3,1.4),
(NULL, NULL, NULL, NULL)
"""
qt_select_all "select * from ${table1} order by decimal_key1"

qt_select_pred_decimal32_key "select * from ${table1} where decimal_key1 = 1.1 order by decimal_key1"
qt_select_pred_decimal32_key "select * from ${table1} where decimal_key1 < 1.1111111111111111111 order by decimal_key1"
sql "drop table if exists ${table1}"
}