You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@arrow.apache.org by "srebhan (via GitHub)" <gi...@apache.org> on 2023/04/14 18:59:01 UTC

[GitHub] [arrow] srebhan commented on a diff in pull request #35137: GH-35136: [Go][FlightSQL] Support backends without `CreatePreparedStatement` implemented

srebhan commented on code in PR #35137:
URL: https://github.com/apache/arrow/pull/35137#discussion_r1167189459


##########
go/arrow/flight/flightsql/driver/driver.go:
##########
@@ -442,11 +442,54 @@ func (c *Connection) PrepareContext(ctx context.Context, query string) (driver.S
 		return nil, err
 	}
 
-	return &Stmt{
+	s := &Stmt{
 		stmt:    stmt,
 		client:  c.client,
 		timeout: c.timeout,
-	}, nil
+	}
+
+	return s, nil
+}
+
+func (c *Connection) QueryContext(ctx context.Context, query string, args []driver.NamedValue) (driver.Rows, error) {
+	if len(args) > 0 {
+		// We cannot pass arguments to the client so we skip a direct query.
+		// This will force the sql-framework to prepare and execute queries.
+		return nil, driver.ErrSkip
+	}
+
+	if _, set := ctx.Deadline(); !set && c.timeout > 0 {
+		var cancel context.CancelFunc
+		ctx, cancel = context.WithTimeout(ctx, c.timeout)
+		defer cancel()
+	}
+
+	info, err := c.client.Execute(ctx, query)
+	if err != nil {
+		return nil, err
+	}
+
+	rows := Rows{}
+	for _, endpoint := range info.Endpoint {
+		reader, err := c.client.DoGet(ctx, endpoint.GetTicket())

Review Comment:
   Refactored the code a bit as `func (s *Stmt) QueryContext(ctx context.Context, args []driver.NamedValue) (driver.Rows, error)` had the same issue.
   



-- 
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: github-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org