Skip to content

Commit

Permalink
pg2arrow: moved empty results check to the end of file creation.
Browse files Browse the repository at this point in the history
issue reported at #824.
the old implementation checked empty results per worker basis.
  • Loading branch information
kaigai committed Oct 14, 2024
1 parent 2968a6c commit 9389fb7
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
2 changes: 0 additions & 2 deletions arrow-tools/pgsql_client.c
Original file line number Diff line number Diff line change
Expand Up @@ -1059,8 +1059,6 @@ sqldb_begin_query(void *sqldb_state,
pgstate->res = res;
pgstate->nitems = PQntuples(res);
pgstate->index = 0;
if (pgstate->nitems == 0)
Elog("SQL query has empty results: %s", sqldb_command);

for (int depth=1; depth <= pgstate->n_depth; depth++)
{
Expand Down
8 changes: 8 additions & 0 deletions arrow-tools/sql2arrow.c
Original file line number Diff line number Diff line change
Expand Up @@ -1604,6 +1604,14 @@ int main(int argc, char * const argv[])
0);
sql_table_clear(table);
}

/* check whether any results were written */
if (table->numRecordBatches == 0)
{
if (!append_filename)
unlink(table->filename);
Elog("SQL query has empty results: %s", sqldb_command);
}
/* write out footer portion */
writeArrowFooter(table);

Expand Down

0 comments on commit 9389fb7

Please sign in to comment.