Skip to content

GH-50000: [C++][FlightRPC] Use grpcpp/grpcpp.h not grpcpp/version_info.h for old gRPC#50001

Merged
kou merged 3 commits into
apache:mainfrom
rok:grpc_util_internal
May 20, 2026
Merged

GH-50000: [C++][FlightRPC] Use grpcpp/grpcpp.h not grpcpp/version_info.h for old gRPC#50001
kou merged 3 commits into
apache:mainfrom
rok:grpc_util_internal

Conversation

@rok

@rok rok commented May 20, 2026

Copy link
Copy Markdown
Member

Rationale for this change

gRPC 1.51.0 introduced grpcpp/version_info.h. Since we also use older versions we should guard against import in case of older version.

What changes are included in this PR?

Use grpcpp/grpcpp.h not grpcpp/version_info.h. grpcpp/grpcpp.h is provided by old gRPC.

Are these changes tested?

By CI.

Are there any user-facing changes?

No.

@rok
rok requested a review from lidavidm as a code owner May 20, 2026 10:38
@github-actions

Copy link
Copy Markdown

⚠️ GitHub issue #50000 has been automatically assigned in GitHub to PR creator.

@raulcd raulcd left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am wondering whether this is better than a guard as we have on other places:

#define GRPC_CPP_VERSION_CHECK(major, minor, patch)                             \
  ((GRPC_CPP_VERSION_MAJOR > (major) ||                                         \
    (GRPC_CPP_VERSION_MAJOR == (major) && GRPC_CPP_VERSION_MINOR > (minor)) ||  \
    ((GRPC_CPP_VERSION_MAJOR == (major) && GRPC_CPP_VERSION_MINOR == (minor) && \
      GRPC_CPP_VERSION_PATCH >= (patch)))))

#if GRPC_CPP_VERSION_CHECK(1, 80, 0)
#  include <grpcpp/version_info.h>
#endif

@github-actions github-actions Bot added awaiting changes Awaiting changes and removed awaiting committer review Awaiting committer review labels May 20, 2026
@github-actions github-actions Bot added awaiting change review Awaiting change review and removed awaiting changes Awaiting changes labels May 20, 2026
@rok

rok commented May 20, 2026

Copy link
Copy Markdown
Member Author

GRPC_CPP_VERSION_MAJOR/MINOR/PATCH are defined inside <grpcpp/version_info.h>. Without importing <grpcpp/version_info.h> the if GRPC_CPP_VERSION_CHECK(1, 80, 0) check will (I believe) always evaluate to 0 and not really do much.

@rok
rok requested a review from raulcd May 20, 2026 11:35

@kou kou left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, sorry...

#include "arrow/flight/visibility.h"
#include "arrow/util/macros.h"

// <grpcpp/version_info.h> was added in gRPC 1.80 and is the only place that

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seems that grpcpp/version_info.h is available since gRPC 1.51.0: grpc/grpc@8696d49

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, sorry. We seem to be using 1.30.2 in this case (row 499).

@github-actions github-actions Bot added awaiting changes Awaiting changes and removed awaiting change review Awaiting change review labels May 20, 2026
@kou

kou commented May 20, 2026

Copy link
Copy Markdown
Member

How about this?

diff --git a/cpp/src/arrow/flight/transport/grpc/util_internal.h b/cpp/src/arrow/flight/transport/grpc/util_internal.h
index 6ff3dadb53..7e306d574a 100644
--- a/cpp/src/arrow/flight/transport/grpc/util_internal.h
+++ b/cpp/src/arrow/flight/transport/grpc/util_internal.h
@@ -17,18 +17,23 @@
 
 #pragma once
 
-#include <grpcpp/version_info.h>
+#include <grpcpp/grpcpp.h>
 
 #include "arrow/flight/transport/grpc/protocol_grpc_internal.h"
 #include "arrow/flight/types.h"
 #include "arrow/flight/visibility.h"
 #include "arrow/util/macros.h"
 
-#define GRPC_CPP_VERSION_CHECK(major, minor, patch)                             \
-  ((GRPC_CPP_VERSION_MAJOR > (major) ||                                         \
-    (GRPC_CPP_VERSION_MAJOR == (major) && GRPC_CPP_VERSION_MINOR > (minor)) ||  \
-    ((GRPC_CPP_VERSION_MAJOR == (major) && GRPC_CPP_VERSION_MINOR == (minor) && \
-      GRPC_CPP_VERSION_PATCH >= (patch)))))
+// gRPC 1.51.0 or later defines GRPC_CPP_VERSION_MAJOR and so on.
+#ifdef GRPC_CPP_VERSION_MAJOR
+#  define GRPC_CPP_VERSION_CHECK(major, minor, patch)                             \
+    ((GRPC_CPP_VERSION_MAJOR > (major) ||                                         \
+      (GRPC_CPP_VERSION_MAJOR == (major) && GRPC_CPP_VERSION_MINOR > (minor)) ||  \
+      ((GRPC_CPP_VERSION_MAJOR == (major) && GRPC_CPP_VERSION_MINOR == (minor) && \
+        GRPC_CPP_VERSION_PATCH >= (patch)))))
+#else
+#  define GRPC_CPP_VERSION_CHECK(major, minor, patch) 0
+#endif
 
 #if GRPC_CPP_VERSION_CHECK(1, 80, 0)
 #  include <absl/status/status.h>

@github-actions github-actions Bot added awaiting change review Awaiting change review and removed awaiting changes Awaiting changes labels May 20, 2026
@rok

rok commented May 20, 2026

Copy link
Copy Markdown
Member Author

Thanks @kou, I love the explicit GRPC_CPP_VERSION_CHECK(major, minor, patch) 0! Applied your suggestion.

@kou

kou commented May 20, 2026

Copy link
Copy Markdown
Member

It's the idea by @spotaws in a0ff085 . :-)

@kou kou left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+1

@kou kou changed the title GH-50000: [C++][FlightRPC] <grpcpp/version_info.h> not found GH-50000: [C++][FlightRPC] Use grpcpp/grpcpp.h not grpcpp/version_info.h for old gRPC May 20, 2026
@github-actions github-actions Bot added awaiting merge Awaiting merge and removed awaiting change review Awaiting change review labels May 20, 2026
@kou
kou merged commit cca41a3 into apache:main May 20, 2026
60 checks passed
@kou kou removed the awaiting merge Awaiting merge label May 20, 2026
@conbench-apache-arrow

Copy link
Copy Markdown

After merging your PR, Conbench analyzed the 3 benchmarking runs that have been run so far on merge-commit cca41a3.

There were no benchmark performance regressions. 🎉

The full Conbench report has more details. It also includes information about 14 possible false positives for unstable benchmarks that are known to sometimes produce them.

@conbench-apache-arrow

Copy link
Copy Markdown

After merging your PR, Conbench analyzed the 4 benchmarking runs that have been run so far on merge-commit cca41a3.

There were no benchmark performance regressions. 🎉

The full Conbench report has more details. It also includes information about 14 possible false positives for unstable benchmarks that are known to sometimes produce them.

@conbench-apache-arrow

Copy link
Copy Markdown

After merging your PR, Conbench analyzed the 4 benchmarking runs that have been run so far on merge-commit cca41a3.

There were no benchmark performance regressions. 🎉

The full Conbench report has more details. It also includes information about 14 possible false positives for unstable benchmarks that are known to sometimes produce them.

Mottl pushed a commit to Mottl/arrow that referenced this pull request May 26, 2026
…on_info.h for old gRPC (apache#50001)

### Rationale for this change

`gRPC 1.51.0` introduced `grpcpp/version_info.h`. Since we also use older versions we should guard against import in case of older version.

### What changes are included in this PR?

Use `grpcpp/grpcpp.h` not `grpcpp/version_info.h`. `grpcpp/grpcpp.h` is provided by old gRPC.

### Are these changes tested?

By CI.

### Are there any user-facing changes?

No.
* GitHub Issue: apache#50000

Authored-by: Rok Mihevc <rok@mihevc.org>
Signed-off-by: Sutou Kouhei <kou@clear-code.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants