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

odbc_write_table: describe parameters only if column data is coherent #587

Merged
merged 2 commits into from
Jul 11, 2023

Conversation

detule
Copy link
Collaborator

@detule detule commented Jul 8, 2023

Fixes #586

When writing out our oracle specific implementation of odbcConnectionColumns we snooped on how the OEM driver implements the SQLColumns ODBC API call. As a result we inherited some issues - for example, the OEM query always returns 0 for the DATA_TYPE field in the result ( we return NA ).

This is a problem, because if the output of odbcConnectionColumns/SQLColumns is available, our dbWriteTable implementation will attempt to use it as a performance optimization / to reduce the number of round-trips to the server to describe each of the parameters of the INSERT query.

With this patch, we attempt to optimize ( pre-describe the parameters ) only if we have a coherent result from the odbcConnectionColumns query. Coherent is defined as data_type is not NA and the number of rows ( each row describing an individual parameter ) is equal to the number of parameters in the INSERT query.

Beyond this patch, we should snoop on the SIMBA driver as well to see if it has a better / more complete way of querying column types of existing tables, and use this to update the ORACLE specific implementation.

Finally, probably also worth thinking about

  • Adding ORACLE unit testing infrastructure.
  • Adding MSSQL / FreeTDS unit testing infrastructure as for that DB/Driver pairing the parameter description is not just an optimization, it is a necessity. It is important we don't disrupt how the parameter description works/is used in that case.

Also fixup formatting of Oracle specific odbcConnectionColumns
implementation.
@detule detule requested a review from hadley July 8, 2023 16:04
R/Table.R Outdated Show resolved Hide resolved
Co-authored-by: Hadley Wickham <[email protected]>
@detule detule merged commit fea0c49 into r-dbi:main Jul 11, 2023
19 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants