MCPcopy Create free account
hub / github.com/apache/arrow / DropNullTable

Function DropNullTable

cpp/src/arrow/compute/kernels/vector_selection.cc:142–171  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

140}
141
142Result<Datum> DropNullTable(const std::shared_ptr<Table>& table, ExecContext* ctx) {
143 if (table->num_rows() == 0) {
144 return table;
145 }
146 // Compute an upper bound of the final null count
147 int64_t null_count = 0;
148 for (const auto& col : table->columns()) {
149 for (const auto& column_chunk : col->chunks()) {
150 null_count += column_chunk->null_count();
151 }
152 }
153 if (null_count == 0) {
154 return table;
155 }
156
157 arrow::RecordBatchVector filtered_batches;
158 TableBatchReader batch_iter(*table);
159 while (true) {
160 ARROW_ASSIGN_OR_RAISE(auto batch, batch_iter.Next());
161 if (batch == nullptr) {
162 break;
163 }
164 ARROW_ASSIGN_OR_RAISE(auto filtered_datum, DropNullRecordBatch(batch, ctx))
165 if (filtered_datum.length() > 0) {
166 filtered_batches.push_back(filtered_datum.record_batch());
167 }
168 }
169
170 return Table::FromRecordBatches(table->schema(), filtered_batches);
171}
172const FunctionDoc drop_null_doc(
173 "Drop nulls from the input",
174 ("The output is populated with values from the input (Array, ChunkedArray,\n"

Callers 1

ExecuteImplMethod · 0.85

Calls 7

columnsMethod · 0.80
push_backMethod · 0.80
num_rowsMethod · 0.45
chunksMethod · 0.45
null_countMethod · 0.45
lengthMethod · 0.45
schemaMethod · 0.45

Tested by

no test coverage detected