Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

297
Vistas
Writing Data from R to Redshift issue

I have been trying to push data created in a work space on R server back to Redshift. Using dbWriteTable(), I can successfully create the table, but the data are not being written to this newly created table and the following error is produced:

> dbWriteTable(con, c("schema", "table"), value = df,append=TRUE, 
row.names=FALSE)

Error in postgresqlpqExec(new.con, sql4) : 

  RS-DBI driver: (could not Retrieve the result : ERROR:  syntax error at or 
near "STDIN"
LINE 1: COPY "schema"."table" FROM STDIN
                                      ^
)

Notes on the code:

  • 'con' refers to the Redshift connection, the code for that in generic form is as follows:

    con <- dbConnect(drv, host="host_name",
                     port="port_id",
                     dbname="db_name",
                     user="username",
                     password="password")
    
  • I cannot give full examples with data due to restrictions on the data.

Originally, I thought it could be a permissions issue within the work space. But, I have found an extremely slow solution by creating the table using dbSendQuery() and then looping through each row of the dataframe I wish to insert into Redshift via another call to dbSendQuery(). This tells me the issue must be related to something other then permissions since I can complete the task inefficiently.

Any comments or proposals related to this error are greatly appreciated, thank you.

over 4 years ago · Santiago Trujillo
1 Respuestas
Responde la pregunta

0

It looks like your client "R" application is trying to use Postgres COPY ... FROM STDIN syntax. "FROM STDIN" is not supported syntax for the Redshift COPY command, see Redshift COPY.

Options you might consider are inserting row by row (as you were doing with dbSendQuery()), but this will be slow, or outputting your data to a CSV file that can be uploaded to Amazon S3 and from there loaded using COPY with S3 as a data source (fast).

over 4 years ago · Santiago Trujillo Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda