Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

302
Visualizações
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 Respostas
Responde à pergunta

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda