Skip to content

Commit

Permalink
Min precision should be 1
Browse files Browse the repository at this point in the history
  • Loading branch information
rui-mo committed Apr 4, 2024
1 parent efb7e77 commit 88c3d99
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
2 changes: 1 addition & 1 deletion velox/type/Type.h
Original file line number Diff line number Diff line change
Expand Up @@ -664,7 +664,7 @@ class DecimalType : public ScalarType<KIND> {
public:
static_assert(KIND == TypeKind::BIGINT || KIND == TypeKind::HUGEINT);
static constexpr uint8_t kMaxPrecision = KIND == TypeKind::BIGINT ? 18 : 38;
static constexpr uint8_t kMinPrecision = KIND == TypeKind::BIGINT ? 0 : 19;
static constexpr uint8_t kMinPrecision = KIND == TypeKind::BIGINT ? 1 : 19;

inline bool equivalent(const Type& other) const override {
if (!Type::hasSameTypeId(other)) {
Expand Down
3 changes: 3 additions & 0 deletions velox/type/tests/TypeTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -228,6 +228,9 @@ TEST(TypeTest, shortDecimal) {
EXPECT_NE(*DECIMAL(9, 5), *shortDecimal);
EXPECT_NE(*DECIMAL(10, 4), *shortDecimal);

VELOX_ASSERT_THROW(
DECIMAL(0, 0), "Precision of decimal type must be at least 1");

EXPECT_STREQ(shortDecimal->name(), "DECIMAL");
EXPECT_EQ(shortDecimal->parameters().size(), 2);
EXPECT_TRUE(
Expand Down

0 comments on commit 88c3d99

Please sign in to comment.