This is an automated email from the ASF dual-hosted git repository.

zeroshade pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/arrow.git


The following commit(s) were added to refs/heads/main by this push:
     new adf33cc430 MINOR: [Go] Tweak Flight SQL demo server for ADBC Java 
Flight SQL (#34776)
adf33cc430 is described below

commit adf33cc430101d1d6878b546e1473431ca5f280c
Author: David Li <[email protected]>
AuthorDate: Sat Apr 1 17:21:33 2023 -0400

    MINOR: [Go] Tweak Flight SQL demo server for ADBC Java Flight SQL (#34776)
    
    
    
    ### Rationale for this change
    
    The ADBC Flight SQL driver/test suite depends on semantic error codes from 
the server.
    
    ### What changes are included in this PR?
    
    Return a more specific error in the SQLite Flight SQL example server.
    
    ### Are these changes tested?
    
    Yes
    
    ### Are there any user-facing changes?
    
    No
    
    Authored-by: David Li <[email protected]>
    Signed-off-by: Matt Topol <[email protected]>
---
 go/arrow/flight/flightsql/example/sql_batch_reader.go |  2 +-
 go/arrow/flight/flightsql/example/sqlite_server.go    |  6 ++++++
 go/arrow/flight/flightsql/sqlite_server_test.go       | 12 ++++++++++++
 3 files changed, 19 insertions(+), 1 deletion(-)

diff --git a/go/arrow/flight/flightsql/example/sql_batch_reader.go 
b/go/arrow/flight/flightsql/example/sql_batch_reader.go
index 45768e176b..3b307368a1 100644
--- a/go/arrow/flight/flightsql/example/sql_batch_reader.go
+++ b/go/arrow/flight/flightsql/example/sql_batch_reader.go
@@ -56,7 +56,7 @@ func getArrowTypeFromString(dbtype string) arrow.DataType {
                return arrow.PrimitiveTypes.Float64
        case "blob":
                return arrow.BinaryTypes.Binary
-       case "text", "date", "char":
+       case "text", "date", "char", "clob":
                return arrow.BinaryTypes.String
        default:
                panic("invalid sqlite type: " + dbtype)
diff --git a/go/arrow/flight/flightsql/example/sqlite_server.go 
b/go/arrow/flight/flightsql/example/sqlite_server.go
index 605c226845..303b6e3de4 100644
--- a/go/arrow/flight/flightsql/example/sqlite_server.go
+++ b/go/arrow/flight/flightsql/example/sqlite_server.go
@@ -643,6 +643,9 @@ func (s *SQLiteFlightSQLServer) 
DoPutPreparedStatementUpdate(ctx context.Context
        if len(args) == 0 {
                result, err := stmt.stmt.ExecContext(ctx)
                if err != nil {
+                       if strings.Contains(err.Error(), "no such table") {
+                               return 0, status.Error(codes.NotFound, 
err.Error())
+                       }
                        return 0, err
                }
 
@@ -653,6 +656,9 @@ func (s *SQLiteFlightSQLServer) 
DoPutPreparedStatementUpdate(ctx context.Context
        for _, p := range args {
                result, err := stmt.stmt.ExecContext(ctx, p...)
                if err != nil {
+                       if strings.Contains(err.Error(), "no such table") {
+                               return totalAffected, 
status.Error(codes.NotFound, err.Error())
+                       }
                        return totalAffected, err
                }
 
diff --git a/go/arrow/flight/flightsql/sqlite_server_test.go 
b/go/arrow/flight/flightsql/sqlite_server_test.go
index 3e274e32df..df86d9a0cf 100644
--- a/go/arrow/flight/flightsql/sqlite_server_test.go
+++ b/go/arrow/flight/flightsql/sqlite_server_test.go
@@ -566,6 +566,18 @@ func (s *FlightSqliteServerSuite) 
TestCommandPreparedStatementQueryWithParams()
        s.False(rdr.Next())
 }
 
+func (s *FlightSqliteServerSuite) TestCommandPreparedStatementUpdateNoTable() {
+       ctx := context.Background()
+       stmt, err := s.cl.Prepare(ctx, "INSERT INTO thisTableDoesNotExist 
(keyName, value) VALUES ('new_value', 2)")
+       s.NoError(err)
+       defer stmt.Close(ctx)
+
+       _, err = stmt.ExecuteUpdate(context.Background())
+       s.Error(err)
+       s.Equal(codes.NotFound, status.Code(err), "%#v", err.Error())
+       s.Contains(err.Error(), "no such table")
+}
+
 func (s *FlightSqliteServerSuite) 
TestCommandPreparedStatementUpdateWithParams() {
        ctx := context.Background()
        stmt, err := s.cl.Prepare(ctx, "INSERT INTO intTable (keyName, value) 
VALUES ('new_value', ?)")

Reply via email to