66package org .opensearch .sql .opensearch .executor ;
77
88import com .google .common .base .Suppliers ;
9- import java .lang .reflect .Method ;
109import java .sql .PreparedStatement ;
1110import java .sql .ResultSet ;
1211import java .sql .ResultSetMetaData ;
2019import java .util .concurrent .ConcurrentHashMap ;
2120import java .util .concurrent .atomic .AtomicReference ;
2221import java .util .function .Supplier ;
23- import org .apache .calcite .avatica .AvaticaResultSet ;
24- import org .apache .calcite .avatica .util .Cursor ;
2522import org .apache .calcite .plan .RelOptUtil ;
2623import org .apache .calcite .rel .RelNode ;
2724import org .apache .calcite .rel .RelRoot ;
@@ -218,29 +215,6 @@ public void execute(
218215 });
219216 }
220217
221- /**
222- * Retrieves column accessors from AvaticaResultSet using reflection. This method accesses the
223- * private getAccessor method to obtain direct access to column data.
224- *
225- * @param rs the ResultSet to get accessors from
226- * @param columnCount the number of columns in the ResultSet
227- * @return list of Cursor.Accessor objects for each column
228- * @throws SQLException if reflection fails or column access is invalid
229- */
230- private List <Cursor .Accessor > getAccessors (ResultSet rs , int columnCount ) throws SQLException {
231- List <Cursor .Accessor > accessorList = new ArrayList <>();
232- try {
233- Method method = AvaticaResultSet .class .getDeclaredMethod ("getAccessor" , int .class );
234- method .setAccessible (true );
235- for (int i = 1 ; i <= columnCount ; i ++) {
236- accessorList .add ((Cursor .Accessor ) method .invoke (rs , i ));
237- }
238- } catch (Exception e ) {
239- throw new SQLException ("Unable to get accessors" , e );
240- }
241- return accessorList ;
242- }
243-
244218 /**
245219 * Process values recursively, handling geo points and nested maps. Geo points are converted to
246220 * OpenSearchExprGeoPointValue. Maps are recursively processed to handle nested structures.
@@ -282,7 +256,6 @@ private void buildResultSet(
282256 // Get the ResultSet metadata to know about columns
283257 ResultSetMetaData metaData = resultSet .getMetaData ();
284258 int columnCount = metaData .getColumnCount ();
285- List <Cursor .Accessor > accessorList = getAccessors (resultSet , columnCount );
286259 List <RelDataType > fieldTypes =
287260 rowTypes .getFieldList ().stream ().map (RelDataTypeField ::getType ).toList ();
288261 List <ExprValue > values = new ArrayList <>();
@@ -292,7 +265,7 @@ private void buildResultSet(
292265 // Loop through each column
293266 for (int i = 1 ; i <= columnCount ; i ++) {
294267 String columnName = metaData .getColumnName (i );
295- Object value = accessorList . get ( i - 1 ). getObject ();
268+ Object value = resultSet . getObject (columnName );
296269 Object converted = processValue (value );
297270 ExprValue exprValue = ExprValueUtils .fromObjectValue (converted );
298271 row .put (columnName , exprValue );
0 commit comments