fresh-borzoni commented on code in PR #294:
URL: https://github.com/apache/fluss-rust/pull/294#discussion_r2785296549
##########
bindings/cpp/src/table.cpp:
##########
@@ -129,25 +129,54 @@ TableScan Table::NewScan() { return TableScan(table_); }
// TableScan implementation
TableScan::TableScan(ffi::Table* table) noexcept : table_(table) {}
-TableScan& TableScan::Project(std::vector<size_t> column_indices) {
+TableScan& TableScan::ProjectByIndex(std::vector<size_t> column_indices) {
projection_ = std::move(column_indices);
+ name_projection_.clear();
return *this;
}
+TableScan& TableScan::ProjectByName(std::vector<std::string> column_names) {
+ name_projection_ = std::move(column_names);
+ projection_.clear();
+ return *this;
+}
+
+std::vector<size_t> TableScan::ResolveNameProjection() const {
+ auto ffi_info = table_->get_table_info_from_table();
+ const auto& columns = ffi_info.schema.columns;
+
+ std::vector<size_t> indices;
+ for (const auto& name : name_projection_) {
+ bool found = false;
+ for (size_t i = 0; i < columns.size(); ++i) {
+ if (std::string(columns[i].name) == name) {
+ indices.push_back(i);
+ found = true;
+ break;
+ }
+ }
+ if (!found) {
+ throw std::runtime_error("Column '" + name + "' not found");
+ }
+ }
+ return indices;
+}
+
Result TableScan::CreateLogScanner(LogScanner& out) {
Review Comment:
better leave for #293, so not to blur scope here
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]