lidavidm commented on code in PR #48049: URL: https://github.com/apache/arrow/pull/48049#discussion_r2496724320
########## cpp/src/arrow/flight/sql/odbc/tests/columns_test.cc: ########## @@ -0,0 +1,962 @@ +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. +#include "arrow/flight/sql/odbc/tests/odbc_test_suite.h" + +#include "arrow/flight/sql/odbc/odbc_impl/platform.h" + +#include <sql.h> +#include <sqltypes.h> +#include <sqlucode.h> + +#include <gtest/gtest.h> + +namespace arrow::flight::sql::odbc { + +template <typename T> +class ColumnsTest : public T {}; + +class ColumnsMockTest : public FlightSQLODBCMockTestBase {}; +class ColumnsRemoteTest : public FlightSQLODBCRemoteTestBase {}; +using TestTypes = ::testing::Types<ColumnsMockTest, ColumnsRemoteTest>; +TYPED_TEST_SUITE(ColumnsTest, TestTypes); + +template <typename T> +class ColumnsOdbcV2Test : public T {}; + +class ColumnsOdbcV2MockTest : public FlightSQLOdbcV2MockTestBase {}; +class ColumnsOdbcV2RemoteTest : public FlightSQLOdbcV2RemoteTestBase {}; +using TestTypesOdbcV2 = ::testing::Types<ColumnsOdbcV2MockTest, ColumnsOdbcV2RemoteTest>; +TYPED_TEST_SUITE(ColumnsOdbcV2Test, TestTypesOdbcV2); + +namespace { +// Helper functions +void CheckSQLColumns( + SQLHSTMT stmt, const std::wstring& expected_table, + const std::wstring& expected_column, const SQLINTEGER& expected_data_type, + const std::wstring& expected_type_name, const SQLINTEGER& expected_column_size, + const SQLINTEGER& expected_buffer_length, const SQLSMALLINT& expected_decimal_digits, + const SQLSMALLINT& expected_num_prec_radix, const SQLSMALLINT& expected_nullable, + const SQLSMALLINT& expected_sql_data_type, const SQLSMALLINT& expected_date_time_sub, + const SQLINTEGER& expected_octet_char_length, + const SQLINTEGER& expected_ordinal_position, + const std::wstring& expected_is_nullable) { + CheckStringColumnW(stmt, 3, expected_table); // table name + CheckStringColumnW(stmt, 4, expected_column); // column name + + CheckIntColumn(stmt, 5, expected_data_type); // data type + + CheckStringColumnW(stmt, 6, expected_type_name); // type name + + CheckIntColumn(stmt, 7, expected_column_size); // column size + CheckIntColumn(stmt, 8, expected_buffer_length); // buffer length + + CheckSmallIntColumn(stmt, 9, expected_decimal_digits); // decimal digits + CheckSmallIntColumn(stmt, 10, expected_num_prec_radix); // num prec radix + CheckSmallIntColumn(stmt, 11, + expected_nullable); // nullable + + CheckNullColumnW(stmt, 12); // remarks + CheckNullColumnW(stmt, 13); // column def + + CheckSmallIntColumn(stmt, 14, expected_sql_data_type); // sql data type + CheckSmallIntColumn(stmt, 15, expected_date_time_sub); // sql date type sub + CheckIntColumn(stmt, 16, expected_octet_char_length); // char octet length + CheckIntColumn(stmt, 17, + expected_ordinal_position); // oridinal position + + CheckStringColumnW(stmt, 18, expected_is_nullable); // is nullable +} Review Comment: I suppose this is fine given the structure of the test -- 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]
