github-actions[bot] commented on code in PR #68768:
URL: https://github.com/apache/doris/pull/68768#discussion_r4219857277
##########
fe/fe-core/src/main/java/org/apache/doris/service/arrowflight/DorisFlightSqlProducer.java:
##########
@@ -468,12 +509,15 @@ public void createPreparedStatement(final
ActionCreatePreparedStatementRequest r
String query = request.getQuery();
// ADBC ExecuteSchema reads this dataset schema directly
without calling GetSchema.
// Analyze before registering a handle so failed
preparation does not retain a query.
- Schema schema = analyzeQuerySchema(connectContext, query);
+ org.apache.doris.common.Pair<Schema, Schema> prepared =
prepareQuerySchema(
+ connectContext, query);
+ Schema schema = prepared.first;
preparedStatementId = UUID.randomUUID().toString();
ByteString handle =
ByteString.copyFromUtf8(context.peerIdentity() + ":" + preparedStatementId);
Result result = new
Result(Any.pack(buildCreatePreparedStatementResult(handle,
- new Schema(Collections.emptyList()),
schema)).toByteArray());
- connectContext.addPreparedQuery(preparedStatementId,
query, schema);
+ prepared.second, schema)).toByteArray());
+ connectContext.addPreparedQuery(preparedStatementId,
query, schema,
Review Comment:
[P2] Preserve and validate the parameter schema promised by Prepare. This
sends prepared.second to clients but stores only the result schema and
parameter count. For SELECT name FROM v WHERE id = ?, replace v so id changes
from BIGINT to STRING while name stays STRING: DoPut accepts the old BIGINT
vector and all result-schema checks still pass, although a new Prepare would
advertise STRING. The stale numeric binding can match string id '01' where a
fresh string '1' binding would not. Store known parameter types and expire the
handle if they drift. This differs from the existing result-schema drift thread
because the output shape stays constant.
##########
fe/fe-core/src/main/java/org/apache/doris/service/arrowflight/FlightSqlQuerySchema.java:
##########
@@ -194,12 +235,26 @@ static Schema analyze(ConnectContext context, String
query) throws Exception {
Plan analyzed = cascades.getRewritePlan();
// PrepareCommandPlanner stops before the rewrite phase
that normally checks privileges.
new CheckPrivileges().rewriteRoot(analyzed,
cascades.getCurrentJobContext());
+ if (preparing) {
+ statementContext.getIdToComparisonSlot().forEach((id,
slot) ->
+ parameterTypes.putIfAbsent(id,
slot.getDataType()));
+ }
for (Slot slot : analyzed.getOutput()) {
fields.add(field(slot.getName(),
slot.getDataType().toCatalogDataType(), slot.nullable(),
true,
context.getSessionVariable().getTimeZone()));
}
}
- return new Schema(fields);
+ List<Field> parameterFields = new ArrayList<>();
+ for (int i = 0; preparing && i < parameterCount; i++) {
+ DataType type = parameterTypes.getOrDefault(
Review Comment:
[P2] Infer determinable parameter types beyond casts and direct comparisons.
With BIGINT id, SELECT id FROM t WHERE id IN (?) (or id BETWEEN ? AND ?) has no
explicit cast and its visitor never registers a comparison slot. The fixed
VARCHAR signature for name LIKE ? and a simple CASE id WHEN ? have the same
gap. This fallback advertises Arrow Null, so Arrow JDBC setLong/setString fails
before DoPut. The earlier CAST(?) path is fixed; collect these
operator/signature constraints before building the parameter schema and cover
JDBC binds.
--
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]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]