I'm having some trouble with Simba Spark ODBC Driver for C#, parameters work fine for a simple query but they do not work at all for the following nested query.
If I do a quick and dirty string replace of the parameters it works fine, so the query does work, it's the parameters.
SELECT *
FROM(
SELECT DISTINCT DateColumn1, TN, w.start AS DateColumn2, Status,
mean(Value) OVER (
PARTITION BY TN, w.start
ORDER BY DateColumn2 ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING
) AS Value
FROM
(
SELECT
DateColumn2,
WINDOW(DateColumn2, '10 minutes') w,
TN,
Status,
DateColumn1,
Value
FROM
some_table_name
WHERE
TN = ? AND
DateColumn1 BETWEEN ?
AND ?
)
)
And Here's the code that I use to call it. Assume that a connection and command has been successfully created
var command = await connectionManager.CreateCommand();
command.CommandText = theQuery;
command.Parameters.Add("@TN", OdbcType.Text).Value = tagName;
command.Parameters.Add("@from", OdbcType.Date).Value = from;
command.Parameters.Add("@to", OdbcType.Date).Value = to;
var reader = await command.ExecuteReaderAsync();
The same code works fine for a simple select * from ... where ...
query, but when I run it with the one above I get the following error which seems to indicate that the parameters couldn't be inserted, for some reason...
ERROR [HY000] [Simba][Hardy] (35) Error from server: error code: '0' error message: 'MALFORMED_REQUEST:
extraneous input '?' expecting {'(', '{', 'CALLED', 'CLONE', 'COLLECT', 'CONTAINS',
'CONVERT', 'COPY', 'COPY_OPTIONS', 'CREDENTIALS', 'DEEP', 'DEFINER', 'DELTA',
'DETERMINISTIC', 'ENCRYPTION', 'EXPECT', 'FAIL', 'FILES', 'FORMAT_OPTIONS'.
Do you have any ideas? It's complaining about the ?
, and I think I've given it everything it needs. But apparently not...