Skip to content

Commit 4bc8d01

Browse files
committed
change sort_direction to direction according to the spec
Signed-off-by: Junwang Zhao <[email protected]>
1 parent 91e3a72 commit 4bc8d01

File tree

4 files changed

+18
-18
lines changed

4 files changed

+18
-18
lines changed

src/iceberg/sort_field.cc

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -54,10 +54,10 @@ constexpr std::string_view ToString(NullOrder null_order) {
5454
} // namespace
5555

5656
SortField::SortField(int32_t source_id, std::shared_ptr<TransformFunction> transform,
57-
SortDirection sort_direction, NullOrder null_order)
57+
SortDirection direction, NullOrder null_order)
5858
: source_id_(source_id),
5959
transform_(std::move(transform)),
60-
sort_direction_(sort_direction),
60+
direction_(direction),
6161
null_order_(null_order) {}
6262

6363
int32_t SortField::source_id() const { return source_id_; }
@@ -66,20 +66,19 @@ std::shared_ptr<TransformFunction> const& SortField::transform() const {
6666
return transform_;
6767
}
6868

69-
SortDirection SortField::sort_direction() const { return sort_direction_; }
69+
SortDirection SortField::direction() const { return direction_; }
7070

7171
NullOrder SortField::null_order() const { return null_order_; }
7272

7373
std::string SortField::ToString() const {
7474
return std::format(
75-
"SortField(source_id={}, transform={}, sort_direction={}, null_order={})",
76-
source_id_, *transform_, iceberg::ToString(sort_direction_),
77-
iceberg::ToString(null_order_));
75+
"sort_filed(source_id={}, transform={}, direction={}, null_order={})", source_id_,
76+
*transform_, iceberg::ToString(direction_), iceberg::ToString(null_order_));
7877
}
7978

8079
bool SortField::Equals(const SortField& other) const {
8180
return source_id_ == other.source_id_ && *transform_ == *other.transform_ &&
82-
sort_direction_ == other.sort_direction_ && null_order_ == other.null_order_;
81+
direction_ == other.direction_ && null_order_ == other.null_order_;
8382
}
8483

8584
} // namespace iceberg

src/iceberg/sort_field.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -55,10 +55,10 @@ class ICEBERG_EXPORT SortField : public util::Formattable {
5555
/// \brief Construct a field.
5656
/// \param[in] source_id The source field ID.
5757
/// \param[in] transform The transform function.
58-
/// \param[in] sort_direction The sort direction.
58+
/// \param[in] direction The sort direction.
5959
/// \param[in] null_order The null order.
6060
SortField(int32_t source_id, std::shared_ptr<TransformFunction> transform,
61-
SortDirection sort_direction, NullOrder null_order);
61+
SortDirection direction, NullOrder null_order);
6262

6363
/// \brief Get the source field ID.
6464
int32_t source_id() const;
@@ -67,7 +67,7 @@ class ICEBERG_EXPORT SortField : public util::Formattable {
6767
const std::shared_ptr<TransformFunction>& transform() const;
6868

6969
/// \brief Get the sort direction.
70-
SortDirection sort_direction() const;
70+
SortDirection direction() const;
7171

7272
/// \brief Get the null order.
7373
NullOrder null_order() const;
@@ -88,7 +88,7 @@ class ICEBERG_EXPORT SortField : public util::Formattable {
8888

8989
int32_t source_id_;
9090
std::shared_ptr<TransformFunction> transform_;
91-
SortDirection sort_direction_;
91+
SortDirection direction_;
9292
NullOrder null_order_;
9393
};
9494

test/sort_field_test.cc

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,14 +46,14 @@ TEST(SortFieldTest, Basics) {
4646
SortField field(1, transform, SortDirection::kAscending, NullOrder::kFirst);
4747
EXPECT_EQ(1, field.source_id());
4848
EXPECT_EQ(*transform, *field.transform());
49-
EXPECT_EQ(SortDirection::kAscending, field.sort_direction());
49+
EXPECT_EQ(SortDirection::kAscending, field.direction());
5050
EXPECT_EQ(NullOrder::kFirst, field.null_order());
5151
EXPECT_EQ(
52-
"SortField(source_id=1, transform=identity, sort_direction=asc, "
52+
"sort_field(source_id=1, transform=identity, direction=asc, "
5353
"null_order=nulls-first)",
5454
field.ToString());
5555
EXPECT_EQ(
56-
"SortField(source_id=1, transform=identity, sort_direction=asc, "
56+
"sort_field(source_id=1, transform=identity, direction=asc, "
5757
"null_order=nulls-first)",
5858
std::format("{}", field));
5959
}

test/sort_order_test.cc

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -60,10 +60,11 @@ TEST(SortOrderTest, Basics) {
6060
ASSERT_EQ(st_field1, fields[0]);
6161
ASSERT_EQ(st_field2, fields[1]);
6262
auto sort_order_str =
63-
"sort_order[order_id<100>,\n SortField(source_id=5, transform=identity, "
64-
"sort_direction=asc, null_order=nulls-first)\n SortField(source_id=7, "
65-
"transform=identity, "
66-
"sort_direction=desc, null_order=nulls-first)\n]";
63+
"sort_order[order_id<100>,\n"
64+
" sort_field(source_id=5, transform=identity, direction=asc, "
65+
"null_order=nulls-first)\n"
66+
" sort_field(source_id=7, transform=identity, direction=desc, "
67+
"null_order=nulls-first)\n]";
6768
EXPECT_EQ(sort_order_str, sort_order.ToString());
6869
EXPECT_EQ(sort_order_str, std::format("{}", sort_order));
6970
}

0 commit comments

Comments
 (0)