下面的查询在hue中运行得很好,但通过c#的odbc失败。odbc驱动程序说了一些关于未知参数的东西,但我不知道那是什么。在日志中 ^
指向下列问号 LIMIT
关键字。我不得不修改日志中的查询以隐藏详细信息。
根据日志,查询似乎到达impala,impala抛出错误,而不是驱动程序。如果这是真的,那么为什么在hue中使用相同的查询呢(同样的意思是我复制粘贴 selectCommand.CommandText
并将问号替换为查询和执行中使用的相同数字。
另一方面,同一个应用程序有查询,其中odbc驱动程序使用问号格式将查询放在一起,并像charm一样工作。
我想不出能做什么了。任何帮助都将不胜感激。
查询:
SELECT
-- list of fields comma separated
FROM tableName
ORDER BY oneOfTheFields
LIMIT ?
OFFSET ?
c代码:
public async Task<List<ClusterMetadataIEdhEntity>> GetAllOffSetted(int limit, int offset)
{
if (limit == 0)
{
throw new ArgumentNullException();
}
List<ClusterMetadataIEdhEntity> result = new List<ClusterMetadataIEdhEntity>();
string select = $"SELECT " +
$"{someFieldName}, " +
$"{anotherFieldName} " +
$"FROM {tableName} " +
$"ORDER BY {colId} " +
$"LIMIT ? " +
$"OFFSET ?";
using (OdbcCommand selectCommand = new OdbcCommand(select, odbcConnection))
{
selectCommand.Parameters.Add("@limit", OdbcType.Int).Value = limit;
selectCommand.Parameters.Add("@offset", OdbcType.Int).Value = offset;
Console.WriteLine(selectCommand.CommandText);
DbDataReader reader = await selectCommand.ExecuteReaderAsync();
}
odbc驱动程序日志:
Dec 28 13:55:49.179 TRACE 775 Connection::SQLGetFunctions: +++++ enter +++++
Dec 28 13:55:49.179 TRACE 775 ConnectionState::SQLGetFunctions: +++++ enter +++++
Dec 28 13:55:49.217 TRACE 775 Connection::SQLAllocHandle: +++++ enter +++++
Dec 28 13:55:49.217 TRACE 775 ConnectionState4::SQLAllocHandle: +++++ enter +++++
Dec 28 13:55:49.217 TRACE 775 ConnectionState::SQLAllocHandle: +++++ enter +++++
Dec 28 13:55:49.217 TRACE 775 ImpalaConnection::CreateStatement: +++++ enter +++++
Dec 28 13:55:49.217 TRACE 775 ImpalaStatement::ImpalaStatement: +++++ enter +++++
Dec 28 13:55:49.217 TRACE 775 Statement::SQLGetStmtAttrW: +++++ enter +++++
Dec 28 13:55:49.217 INFO 775 Statement::SQLGetStmtAttrW: Attribute: SQL_ATTR_APP_ROW_DESC (10010)
Dec 28 13:55:49.217 TRACE 775 StatementStateAllocated::SQLGetStmtAttrW: +++++ enter +++++
Dec 28 13:55:49.217 TRACE 775 StatementState::SQLGetStmtAttrW: +++++ enter +++++
Dec 28 13:55:49.218 TRACE 775 Statement::SQLGetStmtAttrW: +++++ enter +++++
Dec 28 13:55:49.218 INFO 775 Statement::SQLGetStmtAttrW: Attribute: SQL_ATTR_APP_PARAM_DESC (10011)
Dec 28 13:55:49.218 TRACE 775 StatementStateAllocated::SQLGetStmtAttrW: +++++ enter +++++
Dec 28 13:55:49.218 TRACE 775 StatementState::SQLGetStmtAttrW: +++++ enter +++++
Dec 28 13:55:49.218 TRACE 775 Statement::SQLGetStmtAttrW: +++++ enter +++++
Dec 28 13:55:49.218 INFO 775 Statement::SQLGetStmtAttrW: Attribute: SQL_ATTR_IMP_ROW_DESC (10012)
Dec 28 13:55:49.218 TRACE 775 StatementStateAllocated::SQLGetStmtAttrW: +++++ enter +++++
Dec 28 13:55:49.218 TRACE 775 StatementState::SQLGetStmtAttrW: +++++ enter +++++
Dec 28 13:55:49.218 TRACE 775 Statement::SQLGetStmtAttrW: +++++ enter +++++
Dec 28 13:55:49.218 INFO 775 Statement::SQLGetStmtAttrW: Attribute: SQL_ATTR_IMP_PARAM_DESC (10013)
Dec 28 13:55:49.218 TRACE 775 StatementStateAllocated::SQLGetStmtAttrW: +++++ enter +++++
Dec 28 13:55:49.218 TRACE 775 StatementState::SQLGetStmtAttrW: +++++ enter +++++
Dec 28 13:55:49.219 TRACE 775 Statement::SQLSetStmtAttrW: +++++ enter +++++
Dec 28 13:55:49.219 INFO 775 Statement::SQLSetStmtAttrW: Attribute: SQL_ATTR_QUERY_TIMEOUT (0)
Dec 28 13:55:49.219 TRACE 775 StatementState::SQLSetStmtAttrW: +++++ enter +++++
Dec 28 13:55:49.219 TRACE 775 StatementAttributes::SetAttribute: +++++ enter +++++
Dec 28 13:55:49.222 TRACE 775 Connection::SQLGetInfoW: +++++ enter +++++
Dec 28 13:55:49.222 INFO 775 Connection::SQLGetInfoW: InfoType: SQL_DRIVER_ODBC_VER (77)
Dec 28 13:55:49.222 TRACE 775 Statement::SQLSetStmtAttrW: +++++ enter +++++
Dec 28 13:55:49.222 INFO 775 Statement::SQLSetStmtAttrW: Attribute: Unknown Attribute (1228)
Dec 28 13:55:49.222 TRACE 775 StatementState::SQLSetStmtAttrW: +++++ enter +++++
Dec 28 13:55:49.222 TRACE 775 StatementAttributes::SetAttribute: +++++ enter +++++
Dec 28 13:55:49.222 INFO 775 StatementAttributes::SetAttribute: Invalid attribute: 1228
Dec 28 13:55:49.223 ERROR 775 Statement::SQLSetStmtAttrW: [Cloudera][ODBC] (10210) Attribute identifier invalid or not supported: 1228
Dec 28 13:55:49.226 TRACE 775 Statement::SQLSetStmtAttrW: +++++ enter +++++
Dec 28 13:55:49.226 INFO 775 Statement::SQLSetStmtAttrW: Attribute: Unknown Attribute (1227)
Dec 28 13:55:49.226 TRACE 775 StatementState::SQLSetStmtAttrW: +++++ enter +++++
Dec 28 13:55:49.226 TRACE 775 StatementAttributes::SetAttribute: +++++ enter +++++
Dec 28 13:55:49.226 INFO 775 StatementAttributes::SetAttribute: Invalid attribute: 1227
Dec 28 13:55:49.226 ERROR 775 Statement::SQLSetStmtAttrW: [Cloudera][ODBC] (10210) Attribute identifier invalid or not supported: 1227
Dec 28 13:55:49.246 TRACE 775 Statement::SQLBindParameter: +++++ enter +++++
Dec 28 13:55:49.246 TRACE 775 StatementState::SQLBindParameter: +++++ enter +++++
Dec 28 13:55:49.246 TRACE 775 Statement::SQLBindParameter: +++++ enter +++++
Dec 28 13:55:49.246 TRACE 775 StatementState::SQLBindParameter: +++++ enter +++++
Dec 28 13:55:49.247 TRACE 775 Connection::SQLExecDirectW: +++++ enter +++++
Dec 28 13:55:49.247 TRACE 775 ConnectionState5::SQLExecDirectW: +++++ enter +++++
Dec 28 13:55:49.247 TRACE 775 ConnectionState::SQLExecDirectW: +++++ enter +++++
Dec 28 13:55:49.247 TRACE 775 Statement::SQLExectDirectW: +++++ enter +++++
Dec 28 13:55:49.247 TRACE 775 StatementStateAllocated::SQLExecDirectW: +++++ enter +++++
Dec 28 13:55:49.247 INFO 775 StatementState::InternalPrepare: Preparing query: SELECT fields FROM table ORDER BY id LIMIT ? OFFSET ?
Dec 28 13:55:49.247 TRACE 775 ImpalaStatement::CreateDataEngine: +++++ enter +++++
Dec 28 13:55:49.248 TRACE 775 ImpalaDataEngine::ImpalaDataEngine: +++++ enter +++++
Dec 28 13:55:49.248 TRACE 775 ImpalaDataEngine::Prepare: +++++ enter +++++
Dec 28 13:55:49.251 INFO 775 ImpalaDataEngine::Prepare: Trying to parse query: SELECT fields FROM table ORDER BY id LIMIT ? OFFSET ?
Dec 28 13:55:49.254 INFO 775 ImpalaDataEngine::Prepare: [Cloudera][SQLEngine] (31480) syntax error near 'SELECT fields FROM table ORDER BY id LIMIT ? OFFSET<<< ??? >>> ?'.
Dec 28 13:55:49.254 TRACE 775 ImpalaClient::IsNullCellInfosRequired: +++++ enter +++++
Dec 28 13:55:49.254 TRACE 775 ImpalaResultSet::ImpalaResultSet: +++++ enter +++++
Dec 28 13:55:49.254 TRACE 775 ImpalaNativeQueryExecutor::Execute: +++++ enter +++++
Dec 28 13:55:49.254 TRACE 775 ImpalaClient::ExecuteStatement: +++++ enter +++++
Dec 28 13:55:49.254 TRACE 775 ImpalaClient::ExecuteStatementInternal: +++++ enter +++++
Dec 28 13:55:49.254 DEBUG 775 ImpalaTCLIServiceThreadSafeClient::ExecuteStatement: TExecuteStatementReq
sessionHandle.sessionId.guid = be2667f4506840daaba657ad40304f53
statement = SELECT fields FROM table ORDER BY id LIMIT ? OFFSET ?
runAsync = true
Dec 28 13:55:49.254 TRACE 775 ImpalaTCLIServiceThreadSafeClient::ExecuteStatement: +++++ enter +++++
Dec 28 13:55:49.474 TRACE 775 ImpalaTCLIServiceThreadSafeClient::ExecuteStatement: +++++ leave +++++
Dec 28 13:55:49.475 ERROR 775 QueryExecutor::Execute: [Cloudera][ImpalaODBC] (110) Error while executing a query in Impala: [HY000] : AnalysisException: Syntax error in line 1:
... ORDER BY id LIMIT ? OFFSET ?
^
Encountered: Unexpected character
Expected: CASE, CAST, DEFAULT, EXISTS, FALSE, IF, INTERVAL, LEFT, NOT, NULL, REPLACE, RIGHT, TRUNCATE, TRUE, IDENTIFIER
暂无答案!
目前还没有任何答案,快来回答吧!