vertica

Find the first key by date field using sql and output also have other fields

偶尔善良 提交于 2019-12-24 19:24:14
问题 I want to query the first occurrence of every name according to the earliest date. The output should have the complete row. Please help me to write the query in sql. Input: Name | ID | payment_date | Pack ------+-------+-----------------+------- A | 11 | 31-Jan | P C | 13 | 31-Jan | Q B | 2 | 31-Jan | R C | 3 | 28-Jan | P D | 23 | 29-Jan | Q B | 11 | 30-Jan | R A | 17 | 25-Jan | P C | 13 | 26-Jan | Q D | 17 | 2-Feb | R B | 23 | 3-Feb | P A | 45 | 4-Feb | Q B | 3 | 5-Feb | R Output: Name | ID

Python Pandas to_csv Output Returns Single Character for String/Object Values

£可爱£侵袭症+ 提交于 2019-12-24 11:37:50
问题 I'm attempting to output the result into a pandas data frame. When I print the data frame, the object values appear correct, but when I use the to_csv function on the data frame, my csv output has only the first character for every string/object value. df = pandas.DataFrame({'a':[u'u\x00s\x00']}) df.to_csv('test.csv') I've also tried the following addition to the to_csv function: df.to_csv('test_encoded.csv', encoding= 'utf-8') But am getting the same results: >>> print df a 0 us (output in

How many Vertica Databases can run on a Host in the same time?

ぐ巨炮叔叔 提交于 2019-12-24 05:40:12
问题 I know in Oracle i can have multiple homes running on the same host ? Can this be done in Vertica to ? i am running CE vertion of Vertica and it seems i can not do this !! 回答1: They don't allow multiple databases within a single instance of vertica to be active; it makes sense that they wouldn't allow multiple instance of vertica, resulting in multiple databases, active at the same time. EDIT: Reasons I say it makes sense: Vertica can be resource intensive. It is designed to deal with A LOT

Unix time in PARTITION BY for Vertica

前提是你 提交于 2019-12-24 00:44:09
问题 I have Big table in vertica which has time_stamp (int) as unix timestamp. I want to partition this table on week basis (week start day Monday). Is there a better way to do this in one step rather than converting time_stamp from unix to TIMESTAMP (Vertica) then doing partitions ? 回答1: Optimally, you should be using the date/time type. You won't be able to use non-deterministic functions such as TO_TIMESTAMP in the PARTITION BY expression. The alternative is to use math to logically create the

How can I get the last issued sequence ID in vertica?

好久不见. 提交于 2019-12-23 16:30:12
问题 Background: I am migrating from postgreSQL to Vertica and found, that there are some issues in IDENTITY or AUTO_INCREMENT columns. One of these issues is, that vertica cannot assign values to IDENTITY columns or alter a column, that already has data into an IDENTITY column. Therefore I created a sequence and set the default value of the column to be unique doing: SELECT MAX(id_column) FROM MY_SCHEMA.my_table; which is 12345 CREATE SEQUENCE MY_SCHEMA.seq_id_column MINVALUE 12346 CACHE 1; ALTER

Unable to write data to Vertica Database using Python SqlAlchemy - Type “TEXT” does not exist

十年热恋 提交于 2019-12-23 02:52:30
问题 I am trying to upload pandas dataframe into Vertica Database was able to setup the engine and query database using sqlalchemy. But when I try to upload data from pandas dataframe get error message as Type "TEXT" does not exist. I am using windows 10, and created an ODBC connection. import sqlalchemy as sa engine = sa.create_engine('vertica+pyodbc:///?odbc_connect=%s' %(urllib.parse.quote('DSN=TESTDB'),)) sql_query = "select * from sample_table" df = pd.read_sql_query(sql_query, con=engine) #

Vertica: how can you concate values by some order?

我怕爱的太早我们不能终老 提交于 2019-12-18 07:23:20
问题 Suppose you have columns ID | A | B | C 1 | 3 | 1 | 2 2 | 5 | 9 | 1 3 | 1 | 2 | 3 and you want the columns concatenated such that the end result would look like ID | ABC_value_DESC | ABC_value_DESC_colnames 1 | 3,2,1 | A,C,B 2 | 9,5,1 | B,A,C 3 | 3,2,1 | C,B,A where you want to get the col values in Descending order within the new column ABC_value_DESC and then return corresponding name of column in the new column ABC_value_DESC_colnames . How can you do the concatenation of values of

Can I integrate a custom PDO wrapper in Laravel

牧云@^-^@ 提交于 2019-12-18 07:17:10
问题 My fellows at work and I are trying to develop a web application using Laravel with a Vertica database. The only problem is that as soon as you use bindValue or bindParam with this specific database, PHP crashes with a segmentation fault. So I've written a PDO wrapper class that redirects calls to the PHP_ODBC module and that actually works. I was now wondering how to integrate it in Laravel if such a thing is even possible. 回答1: Okay so after a lot of trial and error, my co-workers and I

Sampling without replacement with a different sample size per group in SQL

前提是你 提交于 2019-12-13 09:47:06
问题 Using the provided table I would like to randomly sample users per day. The number of users to be sampled is specified in the to_sample column and it is filled by another query. In this example I would like to sample 1 observation for day one and 2 observations for day two (but this will change with every execution of the query, so don't set your mind to these numbers). I would like the users assigned to different days to be different (no overlapping assignment). drop table if exists test;

Vertica date series is starting one month before specified date

删除回忆录丶 提交于 2019-12-13 05:21:18
问题 I work with a Vertica database and I needed to make a query that, given two dates, would give me a list of all months between said dates. For example, if I were to give the query 2015-01-01 and 2015-12-31, it would output me the following list: 2015-01-01 2015-02-01 2015-03-01 2015-04-01 2015-05-01 2015-06-01 2015-07-01 2015-08-01 2015-09-01 2015-10-01 2015-11-01 2015-12-01 After a bit of digging, I was able to discover the following query: SELECT date_trunc('MONTH', ts)::date as Mois FROM (