Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(c/driver/postgresql): Fix ingest of streams with zero arrays #2073

Merged

Conversation

paleolimbot
Copy link
Member

@paleolimbot paleolimbot commented Aug 12, 2024

I think this didn't work because we only ever wrote COPY output to the connection after each array, so if there were no arrays, there was no header sent!

Closes #2071.

After this PR:

library(adbcdrivermanager)
#> Warning: package 'adbcdrivermanager' was built under R version 4.3.3

con <- adbc_database_init(
  adbcpostgresql::adbcpostgresql(), 
  uri = "postgresql://localhost:5432/postgres?user=postgres&password=password"
) |> 
  adbc_connection_init()

con |> 
  execute_adbc("DROP TABLE IF EXISTS no_integers")

nanoarrow::basic_array_stream(
  list(), 
  nanoarrow::na_struct(list(x = nanoarrow::na_int32()))
) |> 
  write_adbc(con, "no_integers")

con |> 
  read_adbc("SELECT * from no_integers") |> 
  tibble::as_tibble()
#> # A tibble: 0 × 1
#> # ℹ 1 variable: x <int>

Created on 2024-08-11 with reprex v2.1.0

@paleolimbot paleolimbot marked this pull request as ready for review August 12, 2024 15:02
@github-actions github-actions bot added this to the ADBC Libraries 14 milestone Aug 12, 2024
Copy link
Member

@lidavidm lidavidm left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

@lidavidm lidavidm merged commit 96a04ae into apache:main Aug 12, 2024
67 checks passed
@paleolimbot paleolimbot deleted the c-driver-postgresql-zero-size-append branch August 17, 2024 01:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

c/driver/postgresql: Cursor.adbc_ingest() throws an error when an empty table is passed
2 participants