vertica

Copying data to Vertica using python

怎甘沉沦 提交于 2019-12-12 16:30:45
问题 I use python and vertica-python library to COPY data to Vertica DB connection = vertica_python.connect(**conn_info) vsql_cur = connection.cursor() with open("/tmp/vertica-test-insert", "rb") as fs: vsql_cur.copy( "COPY table FROM STDIN DELIMITER ',' ", fs, buffer_size=65536) connection.commit() It inserts data, but only 5 rows, although the file contains more. Could this be related to db settings or it's some client issue? 回答1: Very likely that you have rows getting rejected. Assuming you are

T-SQL: Count number of failures until first success

旧城冷巷雨未停 提交于 2019-12-12 04:57:43
问题 I have a DB consisting of events with timestamps: row eventName taskName timestamp userName 1 fail ABC 10.5 John 2 fail ABC 18.0 John 3 fail ABC 19.0 Mike 4 fail XYZ 21.0 John 5 fail XYZ 23.0 Mike 6 success ABC 25.0 John 7 fail ABC 26.0 John 8 success ABC 28.0 John I'd like to count the number of failures until the first success, per user (and average, but that's beyond this question). In the example above, John attempted task ABC 2 times (rows 1 & 2) until succeeding (row 6). Subsequent

Run Raw SQL in Rails after connecting to Database

巧了我就是萌 提交于 2019-12-12 01:55:36
问题 I'd like my Rails app to run a raw sql command after it establishes the connection to the DB. In which file does that belong? One of the config/initializers? 回答1: I use monkeypatching to force strict mode for MySQL, the same approach should also work in your case. This code belongs in an initializer. class ActiveRecord::ConnectionAdapters::Mysql2Adapter private alias_method :configure_connection_without_autocommit, :configure_connection def configure_connection configure_connection_without

Encoding is not proper when query from Apache/PHP

走远了吗. 提交于 2019-12-11 23:02:50
问题 I have some problem with connection to my Vertica. I use PHP and PDO ODBC driver (thrue unixODBC). When I connect to Vertica via isql and select records from table all data are fine encoded - fields with UTF-8 (non ASCII symbols, for example cyrillic) correctly prints. If connect from web with PHP script and execute same query that fields has some unicode characters like this \u001A\u001A\u001A\u001A Each \u001A represent a one non ASCII symbol and can't be printed. I found that this problem

Rcpp package and Forecast package issues (old versions)

心已入冬 提交于 2019-12-11 19:16:37
问题 I have two linux machines with R version 3.0.0 I've installed the forecast package version 4.8 on both machines. Both machines have the same version of dependencies : >ip <- installed.packages() >ip[c("forecast","Rcpp","RcppArmadillo"),c("Package","Version")] Package Version forecast "forecast" "4.8" Rcpp "Rcpp" "0.10.2" RcppArmadillo "RcppArmadillo" "0.4.000.4" But when I run it on the other node I get the following error : >library(forecast) Error in loadNamespace(i, c(lib.loc, .libPaths())

Import Data to SQL using Python

六眼飞鱼酱① 提交于 2019-12-11 17:44:49
问题 I'm going to need to import 30k rows of data from a CSV file into a Vertica database. The code I've tried with is taking more than an hour to do so. I'm wondering if there's a faster way to do it? I've tried to import using csv and also by looping through a dataframe to insert, but it just isn't fast enough. Infact, it's way too slow. Could you please help me? rownum=df.shape[0] for x in range(0,rownum): a=df['AccountName'].values[x] b=df['ID'].values[x] ss="INSERT INTO Table (AccountName,ID)

LISTAGG in vertica

痴心易碎 提交于 2019-12-11 15:39:14
问题 Equivalent of LISTAGG in Vertica Hello Everyone! I'm trying to aggregate all the field values of a particular group in one field. For example, My input table looks like :- FIELD1 GROUP1 A 1 A 2 B 1 B 2 C 1 C 3 3 null and my output should look like :- 1 A,B,C 2 A,B 3 C I can currently achieve this on Oracle by using the following function SELECT GROUP1, LISTAGG(FIELD1, ',') WITHIN GROUP (ORDER BY FIELD1) AS GROUPED_FIELD FROM <INPUT_TABLE> GROUP BY GROUP1; Is there a way i can do this in

Insufficient Resources error while inserting into SQL table using Vertica

半世苍凉 提交于 2019-12-11 14:32:11
问题 I'm running a Python script to load data from a DataFrame into a SQL Table. However, the insert command is throwing this error: (pyodbc.Error) ('HY000', '[HY000] ERROR 3587: Insufficient resources to execute plan on pool fastlane [Request exceeds session memory cap: 28357027KB > 20971520KB]\n (3587) (SQLExecDirectW)') This is my code: df.to_sql('TableName',engine,schema='trw',if_exists='append',index=False) #copying data from Dataframe df to a SQL Table 回答1: Can you do the following for me:

Vertica performance degradation while loading parquet files over delimited files from s3 to vertica

瘦欲@ 提交于 2019-12-11 14:10:16
问题 I have parquet files for 2 Billion records with GZIP compression and the same data with SNAPPY compression. Also, I have Delimited files for the same 2 Billion records. We have 72 Vertica nodes in AWS prod, we are seeing a huge performance spike for parquet files while moving data from s3 to Vertica with COPY command than Delimited files. Parquet takes 7x more time than Delimited files eventhough delimited file size is 50X more than parquet. Below are the stats for the test we conducted.

Need help querying UTF8 strings from Vertica with PHP ODBC driver

僤鯓⒐⒋嵵緔 提交于 2019-12-11 12:07:38
问题 I've been having some trouble figuring out the best way to handle UTF8 characters in PHP. I'm able to load UTF8 data (chinese characters) into Vertica just fine, and can see them there when using a JDBC client, so I know the data is being recorded correctly. However, when I query via PHP, strings that contain UTF8 characters come through as nulls. However, I can do something like wrap the UTF8 field in a URI_PERCENT_ENCODE function, then do a urldecode on the data in PHP, which outputs the