Search code examples
sqlamazon-web-servicesamazon-redshiftamazon-redshift-spectrum

Redshift error : column is of type timestamp without time zone but expression is of type character


I am copying records from external table to a table inside redshift.

When i run the query against external table it fetches me all the columns and records

SELECT b.title,b.link,b.author,b.published_date,category
FROM  jatinspectrum.extable a, a.enteries b,b.category category

Now when i am trying to run copy the records it throwns an error

ERROR: column "published_date" is of type timestamp without time zone but expression is of type character varying Hint: You will need to rewrite or cast the expression.

my query for copying records ( here jatinanalysis is redshift table and jatinspectrum.extable is external table )

insert into jatinanalysis
select b.title,b.link,b.author,cast(b.published_date as timestamp),category
FROM  jatinspectrum.extable a, a.enteries b,b.category category

Solution

  • I was using wrong syntax

    insert into jatinanalysis (title,url,author,published_date,category)
    select b.title,b.link,b.author,b.published_date,category
    FROM  jatinspectrum.extable a, a.enteries b,b.category category