amazon-redshift

Redshift table size

倾然丶 夕夏残阳落幕 提交于 2021-02-10 05:08:27
问题 This is more like a puzzling question for me and would like to understand why. I have two tables, almost identical the only differences are one column's data type and sortkey. table mbytes rows stg_user_event_properties_hist 460948 2378751028 stg_user_event_properties_hist_1 246442 2513860837 Even though they have almost same number of rows, size is close to double. Here are the table structures stg.stg_user_event_properties_hist ( id bigint, source varchar(20), time_of_txn timestamp, product

Redshift Time Datatype

你。 提交于 2021-02-08 10:18:24
问题 I am trying to create and load a TIME column not unlike other databases to store, only the time. i.e. 09:30:00, 14:23:16 According to this https://docs.aws.amazon.com/redshift/latest/dg/r_Datetime_types.html Redshift has a TIME data type. However trying to use it like the date and timestamp datatypes is proving challenging. select version(); version --------------------------------------------------------------------------------------------------------------------------- PostgreSQL 8.0.2 on

Redshift Truncate table and reset Identity?

喜夏-厌秋 提交于 2021-02-08 10:18:02
问题 I know in PostgresQL there is truncate table restart identity; but this doesn't work in Redshift. Is there something else to do this in Redshift? Otherwise I see it lot of pain to drop table and recreate and load. 回答1: Its not possible to reseed identity value in redshift like other sql databases. you have to create new table and move data there. 来源: https://stackoverflow.com/questions/64530857/redshift-truncate-table-and-reset-identity

How to ignore rows with moving 30 day interval?

梦想的初衷 提交于 2021-02-08 07:52:38
问题 I got stuck with a SQL problem. Let's say we have a dataset like this in Redshift : account_id day event_id 111 2019-01-01 1000 111 2019-01-02 1001 111 2019-01-02 1002 111 2019-01-10 1003 111 2019-01-25 1004 111 2019-02-05 1005 111 2019-02-24 1006 111 2019-02-28 1007 111 2019-03-02 1008 111 2019-03-15 1009 222 2019-01-01 1000 222 2019-01-02 1001 222 2019-01-02 1002 222 2019-01-10 1003 222 2019-01-25 1004 222 2019-02-05 1005 222 2019-02-24 1006 222 2019-02-28 1007 222 2019-03-02 1008 222 2019

How to change the default timezone in Amazon Redshift?

淺唱寂寞╮ 提交于 2021-02-07 09:17:02
问题 Setting a timestamp column to SYSDATE by default, stores it as UTC . Is it possible to change the timezone so SYSDATE stores dates and times to a different timezone? So far, I've checked the SET command but I'm not sure if it is possible to use it to change the timezone. 回答1: Basically, the answer is no. According to the documentation: TIMESTAMP values are UTC, not local time, in both user tables and Amazon Redshift system tables. Note Timestamps with time zones are not supported. If you need

How to change the default timezone in Amazon Redshift?

一曲冷凌霜 提交于 2021-02-07 09:17:00
问题 Setting a timestamp column to SYSDATE by default, stores it as UTC . Is it possible to change the timezone so SYSDATE stores dates and times to a different timezone? So far, I've checked the SET command but I'm not sure if it is possible to use it to change the timezone. 回答1: Basically, the answer is no. According to the documentation: TIMESTAMP values are UTC, not local time, in both user tables and Amazon Redshift system tables. Note Timestamps with time zones are not supported. If you need

How to change the default timezone in Amazon Redshift?

徘徊边缘 提交于 2021-02-07 09:16:03
问题 Setting a timestamp column to SYSDATE by default, stores it as UTC . Is it possible to change the timezone so SYSDATE stores dates and times to a different timezone? So far, I've checked the SET command but I'm not sure if it is possible to use it to change the timezone. 回答1: Basically, the answer is no. According to the documentation: TIMESTAMP values are UTC, not local time, in both user tables and Amazon Redshift system tables. Note Timestamps with time zones are not supported. If you need

redshift: count distinct customers over window partition

混江龙づ霸主 提交于 2021-02-07 01:25:52
问题 Redshift doesn't support DISTINCT aggregates in its window functions. AWS documentation for COUNT states this, and distinct isn't supported for any of the window functions. My use case: count customers over varying time intervals and traffic channels I desire monthly and YTD unique customer counts for the current year, and also split by traffic channel as well as total for all channels. Since a customer can visit more than once I need to count only distinct customers, and therefore the

redshift: count distinct customers over window partition

橙三吉。 提交于 2021-02-07 01:25:50
问题 Redshift doesn't support DISTINCT aggregates in its window functions. AWS documentation for COUNT states this, and distinct isn't supported for any of the window functions. My use case: count customers over varying time intervals and traffic channels I desire monthly and YTD unique customer counts for the current year, and also split by traffic channel as well as total for all channels. Since a customer can visit more than once I need to count only distinct customers, and therefore the

How to Insert TIMESTAMP Column into Redshift

ⅰ亾dé卋堺 提交于 2021-02-06 10:14:34
问题 I created a table in Redshift: create table myTable ( dateTime TIMESTAMP NOT NULL, ... ); However, when I try to insert a record that contains a dateTime of, I get an error from stl_load_errors . 20080215 04:05:06.789 Since I took this timestamp from the docs, I would've expected it to have worked. The error logs from Redshift show: Invalid timestamp format or value [YYYY-MM-DD HH24:MI:SS] However, I'd like to include 3 extra seconds, example: 2015-02-01 15:49:35.123 . How do I need to modify