rnowacoski opened a new issue, #3582:
URL: https://github.com/apache/arrow-adbc/issues/3582

   ### What happened?
   
   In 
[FlightSqlStatement.executeFlightInfo](https://github.com/apache/arrow-adbc/blob/main/java/driver/flight-sql/src/main/java/org/apache/arrow/adbc/driver/flightsql/FlightSqlStatement.java#L221)
 for regular queries it will use the `client` to call execute. Because the 
`client` in FlightSqlStatement is a `FlightSqlClientWithCallOptions` it 
includes the rpc headers from previous calls as call options. 
   
   However, for a prepared statement it uses 
`FlightSqlClient.PreparedStatement::execute` which uses a regular 
`FlientClient`. It also doesn't pass the Call Options to 
`FlightSqlClient.PreparedStatement::execute`. Therefore the RPC Headers which 
are stored as Call Options are not included in the query execution. 
   
   For a Flight SQL Server that uses token-based authentication this will 
result in an unauthenticated exception like below
   
   ```
   AdbcException{message=, status=UNAUTHENTICATED, sqlState='null', 
vendorCode=0, cause=null, details=1}
   ``` 
   
   ### Stack Trace
   
   _No response_
   
   ### How can we reproduce the bug?
   
   You need a Flight SQL Server that uses token-based authentication. Then you 
can use the code below to reproduce this issue.
   
   ```java
   String flightSqlUrl = "localhost:9090";
   String token = "TEST";
   
   Map<String, Object> parameters = new HashMap<>();
   parameters.put(AdbcDriver.PARAM_URI.getKey(), "grpc://"+flightSqlUrl);
   parameters.put(FlightSqlConnectionProperties.RPC_CALL_HEADER_PREFIX + 
"Authorization", "Bearer " + token);
   BufferAllocator rootAllocator = new RootAllocator();
   var adbcDatabase = new FlightSqlDriver(rootAllocator).open(parameters);
   
   // connect(), createStatement() and prepare() all work as expected
   try (
     final AdbcConnection = adbcDatabase.connect();
     final AdbcStatement statement = adbcConnection.createStatement()
   ) {
     statement.setSqlQuery(query);
     statement.prepare();
     // statment.executeQuery() is where this will fail due lack of 
authentication
     try (final AdbcStatement.QueryResult result = statement.executeQuery()) {
       final ArrowReader reader = result.getReader();
       final VectorSchemaRoot root = reader.getVectorSchemaRoot();
     }
   }
   ```
   
   ### Environment/Setup
   
   This is using the following dependencies
   ```
   "org.apache.arrow.adbc" % "adbc-driver-flight-sql" % "0.20.0",
   ```


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to