Skip to content

syntax error when dbWriteTable to Redshift due to lack of quotes #164

Closed

Description

@HarlanH
dbWriteTable(con, "prd_intent_segment", dat_db[1:100,], overwrite=TRUE, copy=FALSE)
Error in result_create(conn@ptr, statement) : Failed to prepare query: ERROR: syntax error at or near "17" LINE 4: ...7-01-01, 2017-01-31, full_time, FALSE, 2018-01-08 17:19:07.3... ^

When I debug, I get the following:

<SQL> INSERT INTO "prd_intent_segment"
  ("user_id", "period_from", "period_to", "segment", "segment_known", "estimated_at")
VALUES
  (947851, 2017-01-01, 2017-01-31, full_time, FALSE, 2018-01-08 17:19:07.33743 UTC),
  (947851, 2017-02-01, 2017-02-28, full_time, FALSE, 2018-01-08 17:19:07.33743 UTC),
...

Manually editing this and putting in quotes around the date and timestamp columns seems to resolve the problem.

R version 3.4.2 (2017-09-28)
Platform: x86_64-apple-darwin16.7.0 (64-bit)
Running under: macOS High Sierra 10.13.2
DBI_0.7-12
RPostgres_1.0-4

Activity

  1. changed the title [-]syntax error when dbWriteTable to Redshift with a POSIXct column[/-] [+]syntax error when dbWriteTable to Redshift due to lack of quotes[/+] on Jan 8, 2018
  2. HarlanH commented on Jan 8, 2018

    @HarlanH
    Author

    See also r-dbi/DBI#204

  3. krlmlr commented on Apr 30, 2018

    @krlmlr
    Member

    Thanks. Can you please try dbWriteTable(copy = FALSE) or the new dbAppendTable()?

  4. krlmlr commented on Dec 17, 2019

    @krlmlr
    Member

    We don't currently support Redshift very well. Closing in favor of #215.

  5. github-actions commented on Dec 17, 2020

    @github-actions
    Contributor

    This old thread has been automatically locked. If you think you have found something related to this, please open a new issue and link to this old issue if necessary.

  6. locked and limited conversation to collaborators on Dec 17, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions