amazon-redshift

aws lambda error loading redshift jdbc driver

白昼怎懂夜的黑 提交于 2020-01-05 08:31:09
问题 I get below error when trying to load Redshift jdbc jar from Aws Lambda. java.io.IOException: Unable to load driver: JAR expected but not found. java.sql.SQLException: No suitable driver found for jdbc:redshift://insightlyanalytics.c0ubofza4jil.us-west-2.redshift.amazonaws.com:5439/analytics;user=xxxh;password=xxx at java.sql.DriverManager.getConnection(DriverManager.java:689) at java.sql.DriverManager.getConnection(DriverManager.java:270) at com.insightly.GeoPerformanceReports

Redshift LIKE column value with %

徘徊边缘 提交于 2020-01-05 07:54:05
问题 I have a column that is a comma separated string of values. I want to join another table that only has one of the values. On redshift, how can I do a LIKE operator with '%' injected into the comparison? Ex: TableA: values_col = 'abc, def' TableB: value_col = 'def' SELECT * FROM TableA a JOIN TableB b ON b.value_col LIKE '%' || a.values_col || '%' The above concat doesn't seem to work. Any suggestions would be appreciated. Thanks. 回答1: You will get awful performance. You should fix your data

REGEXP_SUBSTR converted output is not casting as integer

拜拜、爱过 提交于 2020-01-04 15:52:20
问题 I tried extracting all the digits out of a 20 character string by using REGEXP_SUBSTR Sql function like below. select REGEXP_SUBSTR(substring(mycolumn,1,20), '^[0-9]', 1) || REGEXP_SUBSTR(substring(mycolumn,1,20), '^[0-9]', 2) || REGEXP_SUBSTR(substring(mycolumn,1,20), '^[0-9]', 3) ... ... || REGEXP_SUBSTR(substring(mycolumn,1,20), '^[0-9]', 20) from tbl; But when trying to cast it as bigint / decimal or any numeric data type it is failing with Invalid input syntax for type numeric or Invalid

Fix the MAU problem while calculating DAU and MAU on Amazon Redshift

∥☆過路亽.° 提交于 2020-01-04 06:25:26
问题 I am using the following query to calculate MAU and DAU, according to this post: WITH dau AS ( SELECT TRUNC(created_at) AS created_at, COUNT(DISTINCT member_id) AS dau FROM table ds WHERE ds.created_at BETWEEN '2018-09-03' AND '2018-09-08' GROUP BY TRUNC(created_at) ) SELECT created_at, dau, (SELECT COUNT(DISTINCT member_id) FROM table ds WHERE ds.created_at BETWEEN created_at - 29*INTERVAL '1 day' AND created_at) AS mau FROM dau ORDER BY created_at I try running this query and get the

Update statement: Error: Target table must be part of an equijoin predicate

喜夏-厌秋 提交于 2020-01-04 05:44:18
问题 I get this error when I try to update a column of Table 1 that is like a column of Table 2. Target table must be part of an equijoin predicate. update test set category = t1.category from category_type t1, test t2 where t2.link ilike '%' || t1.type || '%' and t2.link ilike '%.nike.com/%'; Category_Type Table shown below: type category sandals shoes boots shoes t-shirts apparel -pants apparel 回答1: I don't know Redshift, but in Postgres you must not repeat the target table in the FROM clause of

Redshift Extract Function issue

烂漫一生 提交于 2020-01-04 05:39:48
问题 While using this query: SELECT date_time FROM test_table where EXTRACT('epoch' FROM CONVERT_TIMEZONE(replace(timezone, '+', '-'),date_time::timestamp)) >= 1513036800 and EXTRACT('epoch' FROM CONVERT_TIMEZONE(replace(timezone, '+', '-'),date_time::timestamp)) <= 1513555200 limit 10 I am getting this error: An error occurred when executing the SQL command: [Amazon](500310) Invalid operation: Invalid data Details: ----------------------------------------------- error: Invalid data code: 8001

Travis CI/Pro: CIDR/IP Range?

此生再无相见时 提交于 2020-01-03 14:04:39
问题 We are using Travis Pro and we have some tests against Redshift. Is there a CIDR/IP range for Travis VMs that we can create a security rule for in Redshift? Obviously we won't open Redshift for any incoming IP... 回答1: This used to be not possible but with Travis' introduction of their new container-based infrastructure, they now publish the IP ranges of their machines. You can find them here: https://docs.travis-ci.com/user/ip-addresses/ For Travis Pro, you'd need to take the IP range listed

How to select multiple rows filled with constants in Amazon Redshift?

社会主义新天地 提交于 2020-01-03 08:14:14
问题 I have already tried the common PostgreSQL answer, but seems like it doesn't work with Redshift: SELECT * FROM VALUES (1) AS q (col1); ERROR: 42883: function values(integer) does not exist I need this because for some reason I can't use UNION ALL . Any help will be greatly appreciated. 回答1: The correct Postgres syntax would be: SELECT * FROM ( VALUES (1) ) AS q (col1); A set of parentheses was missing. But it seems Redshift does not even support a VALUES expression outside of INSERT (like

How to get column names and types from a PostgreSQL query (without running it)?

时光怂恿深爱的人放手 提交于 2020-01-03 06:35:20
问题 For any given (Postgres) SQL query, I need to be able to extract the column names and column types. I do not need the results of the query. And I need it to be quick (i.e. I don't want to have to wait for the query itself to finish - especially if it takes minutes or longer). I thought I had a solution: To extract the columns and types for the following query: with X as ( select nationality, count(*) from customers group by nationality ) select * from X I would wrap it as follows: select *

Why doesn't ACCEPTINVCHARS work here?

独自空忆成欢 提交于 2020-01-03 04:54:06
问题 I'm getting load errors when trying to load data into Redshift. My error is: Missing newline: Unexpected character 0x24 found at location nnn I'm using this command which includes the ACCEPTINVCHARS option, and the column in question is defined as VARCHAR(80) copy <dest_tbl> from <S3 source> CREDENTIALS <my_credentials> IGNOREHEADER 1 ENCODING UTF8 IGNOREBLANKLINES NULL AS '\\N' EMPTYASNULL BLANKSASNULL gzip ACCEPTINVCHARS timeformat 'auto' dateformat 'auto' MAXERROR 1 compupdate on; The