1 | /* | |
2 | * Copyright OpenSearch Contributors | |
3 | * SPDX-License-Identifier: Apache-2.0 | |
4 | */ | |
5 | ||
6 | ||
7 | package org.opensearch.sql.data.type; | |
8 | ||
9 | import static org.opensearch.sql.data.type.ExprCoreType.UNKNOWN; | |
10 | ||
11 | import java.util.Arrays; | |
12 | import java.util.List; | |
13 | import org.opensearch.sql.data.model.ExprValue; | |
14 | import org.opensearch.sql.expression.Expression; | |
15 | ||
16 | /** | |
17 | * The Type of {@link Expression} and {@link ExprValue}. | |
18 | */ | |
19 | public interface ExprType { | |
20 | /** | |
21 | * Is compatible with other types. | |
22 | */ | |
23 | default boolean isCompatible(ExprType other) { | |
24 |
1
1. isCompatible : negated conditional → KILLED |
if (this.equals(other)) { |
25 |
1
1. isCompatible : replaced boolean return with false for org/opensearch/sql/data/type/ExprType::isCompatible → KILLED |
return true; |
26 | } else { | |
27 |
1
1. isCompatible : negated conditional → KILLED |
if (other.equals(UNKNOWN)) { |
28 |
1
1. isCompatible : replaced boolean return with true for org/opensearch/sql/data/type/ExprType::isCompatible → KILLED |
return false; |
29 | } | |
30 | for (ExprType parentTypeOfOther : other.getParent()) { | |
31 |
1
1. isCompatible : negated conditional → KILLED |
if (isCompatible(parentTypeOfOther)) { |
32 |
1
1. isCompatible : replaced boolean return with false for org/opensearch/sql/data/type/ExprType::isCompatible → KILLED |
return true; |
33 | } | |
34 | } | |
35 |
1
1. isCompatible : replaced boolean return with true for org/opensearch/sql/data/type/ExprType::isCompatible → KILLED |
return false; |
36 | } | |
37 | } | |
38 | ||
39 | /** | |
40 | * Should cast this type to other type or not. By default, cast is always required | |
41 | * if the given type is different from this type. | |
42 | * @param other other data type | |
43 | * @return true if cast is required, otherwise false | |
44 | */ | |
45 | default boolean shouldCast(ExprType other) { | |
46 |
2
1. shouldCast : negated conditional → KILLED 2. shouldCast : replaced boolean return with true for org/opensearch/sql/data/type/ExprType::shouldCast → KILLED |
return !this.equals(other); |
47 | } | |
48 | ||
49 | /** | |
50 | * Get the parent type. | |
51 | */ | |
52 | default List<ExprType> getParent() { | |
53 |
1
1. getParent : replaced return value with Collections.emptyList for org/opensearch/sql/data/type/ExprType::getParent → KILLED |
return Arrays.asList(UNKNOWN); |
54 | } | |
55 | ||
56 | /** | |
57 | * Get the type name. | |
58 | */ | |
59 | String typeName(); | |
60 | ||
61 | /** | |
62 | * Get the legacy type name for old engine. | |
63 | */ | |
64 | default String legacyTypeName() { | |
65 |
1
1. legacyTypeName : replaced return value with "" for org/opensearch/sql/data/type/ExprType::legacyTypeName → KILLED |
return typeName(); |
66 | } | |
67 | } | |
Mutations | ||
24 |
1.1 |
|
25 |
1.1 |
|
27 |
1.1 |
|
28 |
1.1 |
|
31 |
1.1 |
|
32 |
1.1 |
|
35 |
1.1 |
|
46 |
1.1 2.2 |
|
53 |
1.1 |
|
65 |
1.1 |