DatabaseConnector icon indicating copy to clipboard operation
DatabaseConnector copied to clipboard

DatabaseConnector dbplyr failing on duckdb when joining more than 2 tables

Open schuemie opened this issue 1 year ago • 1 comments

With some recent release of a dependency (unsure which), the dbplyr interface no longer works for duckdb when joining more than 2 tables in a single statement. The reason for the failure is that dbplyr (its SQL Server backend) generates table aliases that are just numbers, which duckdb does not accept. For example, the SQL might look like this:

SELECT
  person.*,
  2.observation_period_start_date AS observation_period_start_date,
  2.observation_period_end_date AS observation_period_end_date,
  2.period_type_concept_id AS period_type_concept_id,
  3.observation_period_start_date AS dummy
FROM main.person
LEFT JOIN main.observation_period 2
  ON (person.person_id = 2.person_id)
LEFT JOIN main.observation_period 3
  ON (person.person_id = 3.person_id);

I think this might be a good occasion to think about switching out the backend for the native duckdb one, as @ablack3 is working on here. Adam, any chance you can finish this in the near future?

schuemie avatar Apr 11 '24 16:04 schuemie