diff --git a/cpp/src/arrow/flight/integration_tests/test_integration.cc b/cpp/src/arrow/flight/integration_tests/test_integration.cc index f38076822c7..25600b92cd4 100644 --- a/cpp/src/arrow/flight/integration_tests/test_integration.cc +++ b/cpp/src/arrow/flight/integration_tests/test_integration.cc @@ -1167,6 +1167,7 @@ const std::shared_ptr& GetQuerySchema() { .IsSearchable(true) .CatalogName("catalog_test") .Precision(100) + .Remarks("test column") .Build() .metadata_map())}); return kSchema; @@ -1187,6 +1188,7 @@ std::shared_ptr GetQueryWithTransactionSchema() { .IsSearchable(true) .CatalogName("catalog_test") .Precision(100) + .Remarks("test column") .Build() .metadata_map())}); return kSchema; diff --git a/cpp/src/arrow/flight/sql/column_metadata.cc b/cpp/src/arrow/flight/sql/column_metadata.cc index c855e2f09af..e9b9db05d86 100644 --- a/cpp/src/arrow/flight/sql/column_metadata.cc +++ b/cpp/src/arrow/flight/sql/column_metadata.cc @@ -55,6 +55,7 @@ const char* ColumnMetadata::kIsAutoIncrement = "ARROW:FLIGHT:SQL:IS_AUTO_INCREME const char* ColumnMetadata::kIsCaseSensitive = "ARROW:FLIGHT:SQL:IS_CASE_SENSITIVE"; const char* ColumnMetadata::kIsReadOnly = "ARROW:FLIGHT:SQL:IS_READ_ONLY"; const char* ColumnMetadata::kIsSearchable = "ARROW:FLIGHT:SQL:IS_SEARCHABLE"; +const char* ColumnMetadata::kRemarks = "ARROW:FLIGHT:SQL:REMARKS"; ColumnMetadata::ColumnMetadata( std::shared_ptr metadata_map) @@ -114,6 +115,10 @@ arrow::Result ColumnMetadata::GetIsSearchable() const { return StringToBoolean(is_case_sensitive); } +arrow::Result ColumnMetadata::GetRemarks() const { + return metadata_map_->Get(kRemarks); +} + ColumnMetadata::ColumnMetadataBuilder ColumnMetadata::Builder() { return ColumnMetadataBuilder{}; } @@ -185,6 +190,12 @@ ColumnMetadata::ColumnMetadataBuilder::IsSearchable(bool is_searchable) { return *this; } +ColumnMetadata::ColumnMetadataBuilder& ColumnMetadata::ColumnMetadataBuilder::Remarks( + const std::string& remarks) { + metadata_map_->Append(ColumnMetadata::kRemarks, remarks); + return *this; +} + ColumnMetadata::ColumnMetadataBuilder::ColumnMetadataBuilder() : metadata_map_(std::make_shared()) {} diff --git a/cpp/src/arrow/flight/sql/column_metadata.h b/cpp/src/arrow/flight/sql/column_metadata.h index 0eb53f3e0bb..fe29df90401 100644 --- a/cpp/src/arrow/flight/sql/column_metadata.h +++ b/cpp/src/arrow/flight/sql/column_metadata.h @@ -66,6 +66,9 @@ class ARROW_FLIGHT_SQL_EXPORT ColumnMetadata { /// \brief Constant variable to hold the value of the key that /// will be used in the KeyValueMetadata class. static const char* kIsSearchable; + /// \brief Constant variable to hold the value of the key that + /// will be used in the KeyValueMetadata class. + static const char* kRemarks; /// \brief Static initializer. static ColumnMetadataBuilder Builder(); @@ -110,6 +113,10 @@ class ARROW_FLIGHT_SQL_EXPORT ColumnMetadata { /// \return The IsSearchable. arrow::Result GetIsSearchable() const; + /// \brief Return the Remarks set in the KeyValueMetadata. + /// \return The Remarks. + arrow::Result GetRemarks() const; + /// \brief Return the KeyValueMetadata. /// \return The KeyValueMetadata. const std::shared_ptr& metadata_map() const; @@ -169,6 +176,11 @@ class ARROW_FLIGHT_SQL_EXPORT ColumnMetadata { /// \return A ColumnMetadataBuilder. ColumnMetadataBuilder& IsSearchable(bool is_searchable); + /// \brief Set the column description in the KeyValueMetadata object. + /// \param[in] remarks The comment describing column. + /// \return A ColumnMetadataBuilder. + ColumnMetadataBuilder& Remarks(const std::string& remarks); + ColumnMetadata Build() const; private: diff --git a/format/FlightSql.proto b/format/FlightSql.proto index ef1ae7513d4..25dc1318743 100644 --- a/format/FlightSql.proto +++ b/format/FlightSql.proto @@ -1212,6 +1212,7 @@ message CommandGetDbSchemas { * - ARROW:FLIGHT:SQL:IS_CASE_SENSITIVE - "1" indicates if the column is case-sensitive, "0" otherwise. * - ARROW:FLIGHT:SQL:IS_READ_ONLY - "1" indicates if the column is read only, "0" otherwise. * - ARROW:FLIGHT:SQL:IS_SEARCHABLE - "1" indicates if the column is searchable via WHERE clause, "0" otherwise. + * - ARROW:FLIGHT:SQL:REMARKS - A comment describing the column. This field has been added after all others, clients should be prepared to find it missing. * The returned data should be ordered by catalog_name, db_schema_name, table_name, then table_type, followed by table_schema if requested. */ message CommandGetTables { @@ -1678,6 +1679,7 @@ message ActionEndSavepointRequest { * - ARROW:FLIGHT:SQL:IS_CASE_SENSITIVE - "1" indicates if the column is case-sensitive, "0" otherwise. * - ARROW:FLIGHT:SQL:IS_READ_ONLY - "1" indicates if the column is read only, "0" otherwise. * - ARROW:FLIGHT:SQL:IS_SEARCHABLE - "1" indicates if the column is searchable via WHERE clause, "0" otherwise. + * - ARROW:FLIGHT:SQL:REMARKS - A comment describing the column. This field has been added after all others, clients should be prepared to find it missing. * - GetFlightInfo: execute the query. */ message CommandStatementQuery { @@ -1703,6 +1705,7 @@ message CommandStatementQuery { * - ARROW:FLIGHT:SQL:IS_CASE_SENSITIVE - "1" indicates if the column is case-sensitive, "0" otherwise. * - ARROW:FLIGHT:SQL:IS_READ_ONLY - "1" indicates if the column is read only, "0" otherwise. * - ARROW:FLIGHT:SQL:IS_SEARCHABLE - "1" indicates if the column is searchable via WHERE clause, "0" otherwise. + * - ARROW:FLIGHT:SQL:REMARKS - A comment describing the column. This field has been added after all others, clients should be prepared to find it missing. * - GetFlightInfo: execute the query. * - DoPut: execute the query. */ @@ -1739,6 +1742,7 @@ message TicketStatementQuery { * - ARROW:FLIGHT:SQL:IS_CASE_SENSITIVE - "1" indicates if the column is case-sensitive, "0" otherwise. * - ARROW:FLIGHT:SQL:IS_READ_ONLY - "1" indicates if the column is read only, "0" otherwise. * - ARROW:FLIGHT:SQL:IS_SEARCHABLE - "1" indicates if the column is searchable via WHERE clause, "0" otherwise. + * - ARROW:FLIGHT:SQL:REMARKS - A comment describing the column. This field has been added after all others, clients should be prepared to find it missing. * * If the schema is retrieved after parameter values have been bound with DoPut, then the server should account * for the parameters when determining the schema. @@ -1857,7 +1861,7 @@ message DoPutPreparedStatementResult { // statement should be considered invalid, and all subsequent requests for this prepared // statement must use this new handle. // The updated handle allows implementing query parameters with stateless services. - // + // // When an updated handle is not provided by the server, clients should contiue // using the previous handle provided by `ActionCreatePreparedStatementResonse`. optional bytes prepared_statement_handle = 1;