sqlalchemy-teradata
sqlalchemy-teradata copied to clipboard
The number of supplied parameters does not match the expected number of parameters
I have a query that defines a CTE and joins two subqueries from that CTE. The CTE itself has 3 bind parameters in this instance. The subqueries each have 4. That's a total of 11 bind parameters in the query, and when I compile it, I see 11 ?s.
When I try to run it, I get the error ('PARAMS_MISMATCH', 'The number of supplied parameters (11) does not match the expected number of parameters (14).')
I'm assuming that this has to do with the fact that there are 3 bind parameters in the CTE (and that's why it's off by 3).
My temporary workaround is to just compile the statement with literal_binds and execute it that way.
Any idea if this is an issue with sqlalchemy-teradata or tdodbc?
minimal example:
import sqlalchemy as sa
dd = sa.table('some_table', sa.column('date_dim'))
mycte = dd.select().where(dd.c.date_dim == 100).cte('mycte')
sub1 = mycte.select().where(mycte.c.date_dim == 100).alias('sub1')
sub2 = mycte.select().where(mycte.c.date_dim == 200).alias('sub2')
join = sub1.join(sub2, sub1.c.date_dim == sub2.c.date_dim).select()
This would produce (if you had a table called some_table with a column date_dim) an error stating that you supplied 3 parameters but you expected 4.