Skip to content

Commit 8e60d95

Browse files
committed
fix issues
1 parent 893a974 commit 8e60d95

File tree

5 files changed

+35
-82
lines changed

5 files changed

+35
-82
lines changed

include/substrait/common/Exceptions.h

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,21 +12,21 @@ namespace error_code {
1212
//====================== User Error Codes ======================:
1313

1414
// An error raised when an argument verification fails
15-
inline constexpr auto kInvalidArgument = "INVALID_ARGUMENT";
15+
inline constexpr const char* kInvalidArgument = "INVALID_ARGUMENT";
1616

1717
// An error raised when a requested operation is not supported.
18-
inline constexpr auto kUnsupported = "UNSUPPORTED";
18+
inline constexpr const char* kUnsupported = "UNSUPPORTED";
1919

2020
//====================== Runtime Error Codes ======================:
2121

2222
// An error raised when the current state of a component is invalid.
23-
inline constexpr auto kInvalidState = "INVALID_STATE";
23+
inline constexpr const char* kInvalidState = "INVALID_STATE";
2424

2525
// An error raised when unreachable code point was executed.
26-
inline constexpr auto kUnreachableCode = "UNREACHABLE_CODE";
26+
inline constexpr const char* kUnreachableCode = "UNREACHABLE_CODE";
2727

2828
// An error raised when a requested operation is not implemented.
29-
inline constexpr auto kNotImplemented = "NOT_IMPLEMENTED";
29+
inline constexpr const char* kNotImplemented = "NOT_IMPLEMENTED";
3030

3131
} // namespace error_code
3232

include/substrait/type/Type.h

Lines changed: 23 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -14,27 +14,26 @@ enum class TypeKind : int8_t {
1414
kBool = 1,
1515
kI8 = 2,
1616
kI16 = 3,
17-
kI32 = 5,
18-
kI64 = 7,
19-
kFp32 = 10,
20-
kFp64 = 11,
21-
kString = 12,
22-
kBinary = 13,
23-
kTimestamp = 14,
24-
kDate = 16,
25-
kTime = 17,
26-
kIntervalYear = 19,
27-
kIntervalDay = 20,
28-
kTimestampTz = 29,
29-
kUuid = 32,
30-
kFixedChar = 21,
31-
kVarchar = 22,
32-
kFixedBinary = 23,
33-
kDecimal = 24,
34-
kStruct = 25,
35-
kList = 27,
36-
kMap = 28,
37-
kUserDefined = 30,
17+
kI32 = 4,
18+
kI64 = 5,
19+
kFp32 = 6,
20+
kFp64 = 7,
21+
kString = 8,
22+
kBinary = 9,
23+
kTimestamp = 10,
24+
kDate = 11,
25+
kTime = 12,
26+
kIntervalYear = 13,
27+
kIntervalDay = 14,
28+
kTimestampTz = 15,
29+
kUuid = 16,
30+
kFixedChar = 17,
31+
kVarchar = 18,
32+
kFixedBinary = 19,
33+
kDecimal = 20,
34+
kStruct = 21,
35+
kList = 22,
36+
kMap = 23,
3837
KIND_NOT_SET = 0,
3938
};
4039

@@ -179,12 +178,6 @@ struct TypeTraits<TypeKind::kMap> {
179178
static constexpr const char* typeString = "map";
180179
};
181180

182-
template <>
183-
struct TypeTraits<TypeKind::kUserDefined> {
184-
static constexpr const char* signature = "u!name";
185-
static constexpr const char* typeString = "user defined type";
186-
};
187-
188181
class ParameterizedType {
189182
public:
190183
explicit ParameterizedType(bool nullable = false) : nullable_(nullable) {}
@@ -400,31 +393,6 @@ class ParameterizedTypeBase : public ParameterizedType {
400393
: ParameterizedType(nullable) {}
401394
};
402395

403-
class UsedDefinedType : public ParameterizedTypeBase {
404-
public:
405-
UsedDefinedType(std::string value, bool nullable)
406-
: ParameterizedTypeBase(nullable), value_(std::move(value)) {}
407-
408-
[[nodiscard]] const std::string& value() const {
409-
return value_;
410-
}
411-
412-
[[nodiscard]] TypeKind kind() const override {
413-
return TypeKind::kUserDefined;
414-
}
415-
416-
[[nodiscard]] std::string signature() const override {
417-
return TypeTraits<TypeKind::kUserDefined>::signature;
418-
}
419-
420-
[[nodiscard]] bool isMatch(
421-
const std::shared_ptr<const ParameterizedType>& type) const override;
422-
423-
private:
424-
/// raw string of wildcard type.
425-
const std::string value_;
426-
};
427-
428396
/// A string literal type can present the 'any1'.
429397
class StringLiteral : public ParameterizedTypeBase {
430398
public:
@@ -673,16 +641,16 @@ std::shared_ptr<const Decimal> DECIMAL(int precision, int scale);
673641

674642
std::shared_ptr<const Varchar> VARCHAR(int len);
675643

676-
std::shared_ptr<const FixedChar> FChar(int len);
644+
std::shared_ptr<const FixedChar> FIXED_CHAR(int len);
677645

678-
std::shared_ptr<const FixedBinary> FBinary(int len);
646+
std::shared_ptr<const FixedBinary> FIXED_BINARY(int len);
679647

680648
std::shared_ptr<const List> LIST(const TypePtr& elementType);
681649

682650
std::shared_ptr<const Map> MAP(
683651
const TypePtr& keyType,
684652
const TypePtr& valueType);
685653

686-
std::shared_ptr<const Struct> ROW(const std::vector<TypePtr>& children);
654+
std::shared_ptr<const Struct> STRUCT(const std::vector<TypePtr>& children);
687655

688656
} // namespace substrait

substrait/function/tests/FunctionLookupTest.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ TEST_F(FunctionLookupTest, arithmetic_function) {
8787
TEST_F(FunctionLookupTest, aggregate) {
8888
// for intermediate type
8989
testAggregateFunctionLookup(
90-
{"avg", {ROW({DOUBLE(), BIGINT()})}, FLOAT()}, "avg:opt_fp32");
90+
{"avg", {STRUCT({DOUBLE(), BIGINT()})}, FLOAT()}, "avg:opt_fp32");
9191
}
9292

9393
TEST_F(FunctionLookupTest, logical) {

substrait/type/Type.cpp

Lines changed: 3 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -81,8 +81,6 @@ ParameterizedTypePtr ParameterizedType::decode(const std::string& rawType) {
8181
return std::make_shared<const ScalarType<TypeKind::kDate>>(nullable);
8282
} else if (TypeTraits<TypeKind::kTime>::typeString == baseType) {
8383
return std::make_shared<const ScalarType<TypeKind::kTime>>(nullable);
84-
} else if (matchingType.rfind("unknown", 0) == 0) {
85-
return std::make_shared<const UsedDefinedType>(rawType, nullable);
8684
} else {
8785
return std::make_shared<const StringLiteral>(rawType);
8886
}
@@ -471,7 +469,7 @@ std::shared_ptr<const FixedChar> FCHAR(int len) {
471469
return std::make_shared<const FixedChar>(len, false);
472470
}
473471

474-
std::shared_ptr<const FixedBinary> FBinary(int len) {
472+
std::shared_ptr<const FixedBinary> FIXED_BINARY(int len) {
475473
return std::make_shared<const FixedBinary>(len, false);
476474
}
477475

@@ -485,11 +483,11 @@ std::shared_ptr<const Map> MAP(
485483
return std::make_shared<const Map>(keyType, valueType, false);
486484
}
487485

488-
std::shared_ptr<const Struct> ROW(const std::vector<TypePtr>& children) {
486+
std::shared_ptr<const Struct> STRUCT(const std::vector<TypePtr>& children) {
489487
return std::make_shared<const Struct>(children, false);
490488
}
491489

492-
std::shared_ptr<const FixedChar> FChar(int len) {
490+
std::shared_ptr<const FixedChar> FIXED_CHAR(int len) {
493491
return std::make_shared<const FixedChar>(len);
494492
}
495493

@@ -506,12 +504,4 @@ bool StringLiteral::isMatch(
506504
}
507505
}
508506

509-
bool UsedDefinedType::isMatch(
510-
const std::shared_ptr<const ParameterizedType>& type) const {
511-
if (auto udt = std::dynamic_pointer_cast<const UsedDefinedType>(type)) {
512-
return value_ == udt->value_ && nullable() == udt->nullable();
513-
}
514-
return true;
515-
}
516-
517507
} // namespace substrait

substrait/type/tests/TypeTest.cpp

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -51,13 +51,13 @@ TEST_F(TypeTest, typeCreator) {
5151
testType(INTERVAL_DAY(), TypeKind::kIntervalDay, "iday");
5252
testType(INTERVAL_YEAR(), TypeKind::kIntervalYear, "iyear");
5353
testType(UUID(), TypeKind::kUuid, "uuid");
54-
testType(FChar(12), TypeKind::kFixedChar, "fchar<12>");
55-
testType(FBinary(12), TypeKind::kFixedBinary, "fbin<12>");
54+
testType(FIXED_CHAR(12), TypeKind::kFixedChar, "fchar<12>");
55+
testType(FIXED_BINARY(12), TypeKind::kFixedBinary, "fbin<12>");
5656
testType(VARCHAR(12), TypeKind::kVarchar, "vchar<12>");
5757
testType(DECIMAL(12,23), TypeKind::kDecimal, "dec<12,23>");
5858
testType(LIST(FLOAT()), TypeKind::kList, "list<fp32>");
5959
testType(MAP(STRING(),FLOAT()), TypeKind::kMap, "map<str,fp32>");
60-
testType(ROW({STRING(),FLOAT()}), TypeKind::kStruct, "struct<str,fp32>");
60+
testType(STRUCT({STRING(), FLOAT()}), TypeKind::kStruct, "struct<str,fp32>");
6161
}
6262

6363
TEST_F(TypeTest, decodeTest) {
@@ -155,9 +155,4 @@ TEST_F(TypeTest, decodeTest) {
155155
ASSERT_EQ(typePtr->signature(), "T");
156156
ASSERT_TRUE(typePtr->isWildcard());
157157
});
158-
159-
testDecode<UsedDefinedType>(
160-
"unknown", [](const std::shared_ptr<const UsedDefinedType>& typePtr) {
161-
ASSERT_EQ(typePtr->signature(), "u!name");
162-
});
163158
}

0 commit comments

Comments
 (0)