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

kou pushed a commit to branch main
in repository 
https://gitbox.apache.org/repos/asf/arrow-flight-sql-postgresql.git


The following commit(s) were added to refs/heads/main by this push:
     new 4cd01ee  Add support for Int64 (#66)
4cd01ee is described below

commit 4cd01ee12838b78d8b929fd4c45a903251f18daf
Author: Sutou Kouhei <[email protected]>
AuthorDate: Tue Aug 22 15:03:24 2023 +0900

    Add support for Int64 (#66)
    
    Closes GH-50
---
 src/afs.cc              | 14 ++++++++++++++
 test/test-flight-sql.rb |  2 ++
 2 files changed, 16 insertions(+)

diff --git a/src/afs.cc b/src/afs.cc
index 935df8a..ae53d72 100644
--- a/src/afs.cc
+++ b/src/afs.cc
@@ -750,6 +750,12 @@ class ArrowPGValueConverter : public arrow::ArrayVisitor {
                return arrow::Status::OK();
        }
 
+       arrow::Status Visit(const arrow::Int64Array& array)
+       {
+               datum_ = Int64GetDatum(array.Value(i_row_));
+               return arrow::Status::OK();
+       }
+
    private:
        int64_t i_row_;
        Datum& datum_;
@@ -767,6 +773,8 @@ class PGArrowValueConverter : public arrow::ArrayVisitor {
                                return arrow::int16();
                        case INT4OID:
                                return arrow::int32();
+                       case INT8OID:
+                               return arrow::int64();
                        default:
                                return 
arrow::Status::NotImplemented("Unsupported PostgreSQL type: ",
                                                                     
attribute_->atttypid);
@@ -783,6 +791,9 @@ class PGArrowValueConverter : public arrow::ArrayVisitor {
                        case INT4OID:
                                return 
static_cast<arrow::Int32Builder*>(builder)->Append(
                                        DatumGetInt32(datum));
+                       case INT8OID:
+                               return 
static_cast<arrow::Int64Builder*>(builder)->Append(
+                                       DatumGetInt64(datum));
                        default:
                                return 
arrow::Status::NotImplemented("Unsupported PostgreSQL type: ",
                                                                     
attribute_->atttypid);
@@ -872,6 +883,9 @@ class PreparedStatement {
                                case arrow::Type::INT32:
                                        pgTypes.push_back(INT4OID);
                                        break;
+                               case arrow::Type::INT64:
+                                       pgTypes.push_back(INT8OID);
+                                       break;
                                default:
                                        return arrow::Status::NotImplemented(
                                                "Unsupported Apache Arrow type: 
", field->type()->name());
diff --git a/test/test-flight-sql.rb b/test/test-flight-sql.rb
index a55243f..0c83ef9 100644
--- a/test/test-flight-sql.rb
+++ b/test/test-flight-sql.rb
@@ -31,6 +31,7 @@ class FlightSQLTest < Test::Unit::TestCase
 
   data("int16", ["smallint", Arrow::Int16Array, -2])
   data("int32", ["integer",  Arrow::Int32Array, -2])
+  data("int64", ["bigint",   Arrow::Int64Array, -2])
   def test_select_type
     pg_type, array_class, value = data
     values = array_class.new([value])
@@ -83,6 +84,7 @@ SELECT * FROM data
   data("int8",  ["smallint", Arrow::Int8Array,  [1, -2, 3]])
   data("int16", ["smallint", Arrow::Int16Array, [1, -2, 3]])
   data("int32", ["integer",  Arrow::Int32Array, [1, -2, 3]])
+  data("int64", ["bigint",   Arrow::Int64Array, [1, -2, 3]])
   def test_insert_type
     unless flight_sql_client.respond_to?(:prepare)
       omit("red-arrow-flight-sql 14.0.0 or later is required")

Reply via email to