vertica

How to save the last checkpoint in the sql to be used for next row

只愿长相守 提交于 2019-12-06 17:33:29
问题 Is there any way I can store the last iterated row result and use that for next row iteration? For example I have a table say( Time_Table ). __ Key type timeStamp 1 ) 1 B 2015-06-28 09:00:00 2 ) 1 B 2015-06-28 10:00:00 3 ) 1 C 2015-06-28 11:00:00 4 ) 1 A 2015-06-28 12:00:00 5 ) 1 B 2015-06-28 13:00:00 Now suppose I have an exceptionTime of 90 minutes which is constant. If I start checking my Time_Table then: for the first row, as there is no row before 09:00:00, it will directly put this

How do I do a Crosstab in Vertica

狂风中的少年 提交于 2019-12-06 15:54:03
问题 What is the Vertica equivalent of crosstab or pivot table found in PostgreSQL and other RDBMS's? 回答1: Vertica doesn't currently (release 3.5.9 for future reference) have that capability. I talked with a co-worker and his suggestion was to play around with "cross join." The other option would be to distill your results as far as you could and then run a process outside of the database (perl, Java, C#, etc) that manipulated the data. Vertica is open to feature requests however. I don't believe

Top N per group query in Vertica

China☆狼群 提交于 2019-12-06 02:42:36
This is an old problem - looking for the best solution in Vertica. Imagine a table with columns:- A, B, C, D, E Columns A-D are ints or varchars and column E is a timestamptz column that has a default value of GETUTCDATE(). Sample content of the table:- 1, 2, "AAA", 4, 1404305559 1, 2, "BBB", 23, 1404305633 1, 2, "CCC", 62, 1404305705 <-- the max entry for (1,2,"CCC") 1, 2, "AAA", 123, 1404305740 <-- the max entry for (1,2,"AAA") 1, 2, "BBB", 91, 1404305778 <-- the max entry for (1,2,"BBB") So potentially there are repeating rows for the composite (A,B,C) value (with column D being a value and

How to save the last checkpoint in the sql to be used for next row

左心房为你撑大大i 提交于 2019-12-04 23:11:53
Is there any way I can store the last iterated row result and use that for next row iteration? For example I have a table say( Time_Table ). __ Key type timeStamp 1 ) 1 B 2015-06-28 09:00:00 2 ) 1 B 2015-06-28 10:00:00 3 ) 1 C 2015-06-28 11:00:00 4 ) 1 A 2015-06-28 12:00:00 5 ) 1 B 2015-06-28 13:00:00 Now suppose I have an exceptionTime of 90 minutes which is constant. If I start checking my Time_Table then: for the first row, as there is no row before 09:00:00, it will directly put this record into my target table. Now my reference point is at 9:00:00. For the second row at 10:00:00, the last

Vertica SQL insert multiple rows in one statement

断了今生、忘了曾经 提交于 2019-12-04 14:48:39
Was wondering whether it's possible to accomplish the following in one insert statement? drop table analytics.bw_covariance_matrix; create table analytics.bw_covariance_matrix ( row int, x1 float, x2 float, x3 float ); insert into analytics.bw_covariance_matrix VALUES (1, 4.01926965, -0.4686067, -0.07592112), insert into analytics.bw_covariance_matrix VALUES (2, -0.46860675, 4.1799267, -0.82461139); insert into analytics.bw_covariance_matrix VALUES (3, -0.07592112, -0.8246114, 4.37186211); You could UNION a SELECT to have a single INSERT statement: insert into analytics.bw_covariance_matrix

SQL issue - calculate max days sequence

早过忘川 提交于 2019-12-04 13:46:01
问题 There is a table with visits data: uid (INT) | created_at (DATETIME) I want to find how many days in a row a user has visited our app. So for instance: SELECT DISTINCT DATE(created_at) AS d FROM visits WHERE uid = 123 will return: d ------------ 2012-04-28 2012-04-29 2012-04-30 2012-05-03 2012-05-04 There are 5 records and two intervals - 3 days (28 - 30 Apr) and 2 days (3 - 4 May). My question is how to find the maximum number of days that a user has visited the app in a row (3 days in the

unixODBC giving error while running isql [Vertica]

老子叫甜甜 提交于 2019-12-04 02:57:16
问题 Hi I have configured the DSN settings for vertica in Ubuntu 10.10 32 bit version machine. The settings are all fine and I have cross checked them. Here is my odbc.ini file: [VerticaDSN] Description = VerticaDSN ODBC driver Driver = /opt/vertica/lib/libverticaodbc_unixodbc.so Servername = myservername Database = mydbname Port = 5433 UserName = myuname Password = ******* Locale = en_US Similarly I have a odbcinst.ini file. when I run the command: isql -v VerticaDSN I get the following error:

SQL issue - calculate max days sequence

对着背影说爱祢 提交于 2019-12-03 07:52:48
There is a table with visits data: uid (INT) | created_at (DATETIME) I want to find how many days in a row a user has visited our app. So for instance: SELECT DISTINCT DATE(created_at) AS d FROM visits WHERE uid = 123 will return: d ------------ 2012-04-28 2012-04-29 2012-04-30 2012-05-03 2012-05-04 There are 5 records and two intervals - 3 days (28 - 30 Apr) and 2 days (3 - 4 May). My question is how to find the maximum number of days that a user has visited the app in a row (3 days in the example). Tried to find a suitable function in the SQL docs, but with no success. Am I missing something

Unique Contrains in Vertica DB

半世苍凉 提交于 2019-12-02 10:38:07
问题 Disclaimer: My DB knowledge comes mostly from Mysql so I might misunderstand some things in vertica... I would like to know if there exist a technique of inserting/updating values in vertica while enforcing unique constrains across multiple sessions. Let's assume I have a table: 'id', 'unique_field', 'some_filed' And there is a unique constraint on unique_field. My understanding is that in vertica one first needs to do an insert and then do ANALYZE_CONSTRAINTS to verify if the constraint was

How do I write a pandas dataframe to Vertica?

爷,独闯天下 提交于 2019-12-02 04:55:54
问题 I have some data set in a pandas data frame that I wish to write to Vertica. I've already created my table using the vertica_python library. What is the best way to write my data frame to Vertica? 回答1: Often when connecting to Vertica, you can use Postgresql as a stand-in since certain parts of Vertica were originally based on Postgresql. from sqlalchemy import create_engine engine = create_engine('postgresql://user:pass@host:5433/MYDB') df.to_sql('table_name', engine) If this doesn't work