teradata

Query is working fine in query browser but not in python code

偶尔善良 提交于 2019-12-31 04:28:07
问题 I have a teradata sql query which is working fine in Teradata Studio Express's query browser but when I tried to run the same query in my python code I am getting following error: (3706, "[42000] [Teradata][ODBC Teradata Driver]Teradata DatabaseSyntax error: expected something between '(' and '('.") My query: td_query = """select hash_md5((XMLAGG(TRIM(h_age) ORDER BY h_age ASC) (VARCHAR(100))) )hash_age, hash_md5((XMLAGG(TRIM(h_marks) ORDER BY h_age ASC )(VARCHAR(100)))) hash_marks, hash_md5(

Retain values till there is a change in value in Teradata

最后都变了- 提交于 2019-12-30 14:44:10
问题 There is a transaction history table in teradata where balance gets changed only when there is a transaction Data as below: Cust_id Balance Txn_dt 123 1000 27MAY2018 123 350 31MAY2018 For eg,For a customer(123) on May 27 we have a balance of 1000 and on May 31 there is a transaction made by the customer so balance becomes 350. There is no record maintained for May 28 to May 30 with same balance as on May 27 . I want these days data also to be there (With same balance retained and the date is

SAS connection to Teradata Database using Teradata ODBC

烂漫一生 提交于 2019-12-30 11:09:47
问题 I'm trying to connect to Teradata in SAS. I set up an teradata ODBC on the machine. The assumption currently for me is that using ODBC is the only way for me to access the database. And here is the syntax of my connection command: Libname Teradata ODBC dsn = 'dsnname' uid = 'uid' pwd = 'pwd'; results: Error: The ODBC engine cannot be found. Error: Error in the LIBNAME statement. It keeps saying that the ODBC engine cannot be found. I'm really confused now. Is there anything wrong with the

SAS connection to Teradata Database using Teradata ODBC

南楼画角 提交于 2019-12-30 11:08:24
问题 I'm trying to connect to Teradata in SAS. I set up an teradata ODBC on the machine. The assumption currently for me is that using ODBC is the only way for me to access the database. And here is the syntax of my connection command: Libname Teradata ODBC dsn = 'dsnname' uid = 'uid' pwd = 'pwd'; results: Error: The ODBC engine cannot be found. Error: Error in the LIBNAME statement. It keeps saying that the ODBC engine cannot be found. I'm really confused now. Is there anything wrong with the

SQL Challenge/Puzzle: Given a stack trace - How to find the top element at each point in time?

江枫思渺然 提交于 2019-12-30 06:43:11
问题 My real life use-case was to merge nested ranges. I've drew some sketches and then I saw the resemblance between ranges starting and ending to stack PUSH and POP operations. I understood that solving this problem will also solve the original problem. The op column can actually be removed from the question. When val is NULL then it is a POP operation otherwise it is a PUSH operation. The Puzzle A table, stack_trace ,contains the following columns: i - Integer value that represents a point in

java.lang.RuntimeExceptionPyRaisable: java.lang.RuntimeException: Class com.teradata.jdbc.TeraDriver not found

一曲冷凌霜 提交于 2019-12-28 07:08:08
问题 I am trying to connect with Teradata database in Mac 10.14.2 using Jaydebeapi . I am getting following error. Earlier, I was facing issue in installing Jaydebeapi . After lot of trials and errors. I downgraded Python 3.7 to Python 3.6. Following are the code and corresponding error output Code import sys import os import string import jaydebeapi from time import gmtime, strftime from datetime import datetime, timedelta case_detail_server ='*******' amanita_server= '******' database_case

How to improve performance for slow Spark jobs using DataFrame and JDBC connection?

耗尽温柔 提交于 2019-12-27 11:45:26
问题 I am trying to access a mid-size Teradata table (~100 million rows) via JDBC in standalone mode on a single node (local[*]). I am using Spark 1.4.1. and is setup on a very powerful machine(2 cpu, 24 cores, 126G RAM). I have tried several memory setup and tuning options to make it work faster, but neither of them made a huge impact. I am sure there is something I am missing and below is my final try that took about 11 minutes to get this simple counts vs it only took 40 seconds using a JDBC

i am migrtaing database from sql server 2008 to teradata

我的未来我决定 提交于 2019-12-25 13:53:11
问题 I am migrating a database from Sql Server 2008 to Teradata and I am facing a problem: In Sql Server in the ddl of a table column is defined as follows: [rowguid] uniqueidentifier ROWGUIDCOL NOT NULL CONSTRAINT [DF_Address_rowguid] DEFAULT (NEWID()) This column uses newid() function to generate and insert random varchar value in the column [rowguid] if the user doesnt provide any input. There is no similar function in Teradata to generate this value. What can be used instead of of NEWID()

WHILE loop in Teradata procedure

孤街醉人 提交于 2019-12-25 12:50:35
问题 I'm trying to write a procedure that concatenates all rows in a table in the case in which the row number is unknown. I have this code but it is not working. CREATE PROCEDURE Test (OUT r VARCHAR(3000)) BEGIN DECLARE RowCnt INT; DECLARE CurrRow INT ; SET CurrRow = 1, r = 'SELECT ', RowCnt = (SELECT COUNT(*) FROM tableWithSQLStmnts ) WHILE CurrRow <= RowCnt DO BEGIN SET r = r + CASE WHEN CurrRow = 1 THEN 'MAX( CASE Seq WHEN ' + CAST( CurrRow AS VARCHAR ) + ' THEN SqlStmnt ELSE SPACE(0) END ) +

Count consecutive duplicate values by group

一曲冷凌霜 提交于 2019-12-25 09:02:26
问题 I have searched the site a bit for a solution to this question but have been unable to find an answer that fits precisely what I am looking for. I am attempting to count consecutive duplicate values for each ID number, ordered by the date. My current table resembles the first 3 columns of the table below, whereas the fourth column in what I would like to add. ID | date | value | consec_duplicates 1 1/1 1 0 1 1/2 2 0 1 1/3 2 1 1 1/4 2 2 1 1/5 3 0 1 1/6 3 1 2 1/14 1 0 2 1/15 2 0 2 1/16 3 0 2 1