Convert table columns to proto values dict. Args: table: PyArrow RecordBatch containing the data. columns: List of (column_name, value_type) tuples to convert. allow_missing: If True, skip columns not found in table. If False, raise ValueError. Returns: Dict
(
table: pyarrow.RecordBatch,
columns: List[Tuple[str, ValueType]],
allow_missing: bool = False,
)
| 356 | |
| 357 | |
| 358 | def _columns_to_proto_values( |
| 359 | table: pyarrow.RecordBatch, |
| 360 | columns: List[Tuple[str, ValueType]], |
| 361 | allow_missing: bool = False, |
| 362 | ) -> Dict[str, List[ValueProto]]: |
| 363 | """Convert table columns to proto values dict. |
| 364 | |
| 365 | Args: |
| 366 | table: PyArrow RecordBatch containing the data. |
| 367 | columns: List of (column_name, value_type) tuples to convert. |
| 368 | allow_missing: If True, skip columns not found in table. If False, raise ValueError. |
| 369 | |
| 370 | Returns: |
| 371 | Dict mapping column names to lists of ValueProto. |
| 372 | """ |
| 373 | result: Dict[str, List[ValueProto]] = {} |
| 374 | for column, value_type in columns: |
| 375 | if column in table.column_names: |
| 376 | result[column] = python_values_to_proto_values( |
| 377 | table.column(column).to_numpy(zero_copy_only=False), value_type |
| 378 | ) |
| 379 | elif not allow_missing: |
| 380 | raise ValueError(f"Column {column} not found in table") |
| 381 | return result |
| 382 | |
| 383 | |
| 384 | def _build_entity_keys( |
no test coverage detected