-
Notifications
You must be signed in to change notification settings - Fork 102
Use Statement and Prestatments to execute the same query with different results #460
Comments
@STTianXiang I think this is because the prepared statement was not supported by our new SQL engine. Then your query was handled by legacy which doesn't support |
Hi,@dai-chen: |
Hi @STTianXiang , it seems our most recent 1.13.2 is a minor release without latest code. You have to wait for next major ODFE release or build from our |
Environment
server:opendistro version 1.13
client:jdbc jar maven
com.amazon.opendistroforelasticsearch.client
opendistro-sql-jdbc
1.13.0.0
query sql like this:
select
count(sql_id) as access_num,count(case when result_msg = 'QUERY SUCCESS' then 1 end) as success_num
from index_really_magneto_query_log_2021-03-30
When the query is executed in the Statement mode ,the field success_num returns normal data information;
But
When the query is executed in the PreparedStatement mode ,the field success_num returns 0 ;
String query="select " + " count(sql_id) as access_num, " + " count(case when result_msg = 'QUERY SUCCESS' then 1 end) as success_num " + " from index_really_magneto_query_log_2021-03-29 " ; PreparedStatement stmt=Conn.prepareStatement(query); ResultSet rs=stmt.executeQuery(); ResultSet rs=stmt.executeQuery(); if(rs.next()){ System.out.println(rs.getLong("success_num")); System.out.println(rs.getLong("access_num")); }
Print result like this:
0
2442
Statement stmt = Conn.createStatement(); ResultSet rs=stmt.executeQuery(query); if(rs.next()){ System.out.println(rs.getLong("success_num")); System.out.println(rs.getLong("access_num")); }
Print result like this:
2440
2442
The text was updated successfully, but these errors were encountered: