def render(self, params: Dict[str, Any],
            fetch_result: Optional[FetchResult]):
     with tempfile_context(prefix="output-",
                           suffix=".arrow") as output_path:
         errors = render(ArrowTable(),
                         params,
                         output_path,
                         fetch_result=fetch_result)
         arrow_table = ArrowTable.from_arrow_file_with_inferred_metadata(
             output_path)
         yield RenderResult(arrow_table,
                            [RenderError(I18nMessage(*e)) for e in errors])
Exemple #2
0
def _render_deprecated_parquet(
    input_path: Path,
    errors: List[RenderError],
    output_path: Path,
    params: Dict[str, Any],
) -> RenderResult:
    parquet.convert_parquet_file_to_arrow_file(input_path, output_path)
    result = RenderResult(
        ArrowTable.from_arrow_file_with_inferred_metadata(output_path), errors)

    if result.table.metadata.n_rows > 0 and not params["has_header"]:
        pandas_result = ProcessResult.from_arrow(result)
        dataframe = moduleutils.turn_header_into_first_row(
            pandas_result.dataframe)
        return ProcessResult(dataframe).to_arrow(output_path)

    return result