Teradata/PyTd

teradata.tdrest trims leading spaces

padhia opened this issue · 2 comments

Leading spaces seem to be always removed when running queries using teradata.tdrest module. For example, following code returns a result set with spaces removed from the first column but the length calculation includes the spaces.

import teradata

conn = teradata.tdrest.connect(host='localhost', system='mytd', username='dbc', password='******')
csr = conn.cursor()
csr.execute("select '    <- leading spaces' as col, length(col) as col_len")
print(csr.fetchone())
csr.close()
conn.close()

When I tried running the same query interactively using REST API /systems/{system}/queries, I get the same result so I am pretty sure the issue is not with the teradata.tdrest module, but is either with the REST API or some incorrect configuration that I can't seem to be able to figure out. However, if I change Format from OBJECT to CSV in the interactive POST method, the leading spaces are retained.

The above was tested with TD 15.10, TD REST API 15.00.00.02, teradata module at 15.10.0.17 on a Linux machine running Python 3.5.2.

This indeed looks like a bug with Teradata REST. I've reported the issue to the TDREST support team. I will update and close this issue once I have the bug reference number.

REST-455 was opened to track this issue.