From ef0d989dc8761e225bb13e10c3c4de4098e80ab9 Mon Sep 17 00:00:00 2001 From: Emmanuel T Odeke Date: Fri, 22 Sep 2023 19:02:23 -0700 Subject: [PATCH] Make s/userAgent/USER_AGENT/g to Java constant names --- .../spark/spanner/SpannerPartitionReaderFactory.java | 2 +- .../java/com/google/cloud/spark/spanner/SpannerUtils.java | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/spark-3.1-spanner-lib/src/main/java/com/google/cloud/spark/spanner/SpannerPartitionReaderFactory.java b/spark-3.1-spanner-lib/src/main/java/com/google/cloud/spark/spanner/SpannerPartitionReaderFactory.java index 4f5c4b9c..c317d90d 100644 --- a/spark-3.1-spanner-lib/src/main/java/com/google/cloud/spark/spanner/SpannerPartitionReaderFactory.java +++ b/spark-3.1-spanner-lib/src/main/java/com/google/cloud/spark/spanner/SpannerPartitionReaderFactory.java @@ -30,7 +30,7 @@ public SpannerPartitionReaderFactory() {} @Override public PartitionReader createColumnarReader(InputPartition partition) { // Unsupported! - throw new RuntimeException("createColumnarReader not supported"); + throw new RuntimeException("columnar reads are not supported the Spark Spanner Connector"); } @Override diff --git a/spark-3.1-spanner-lib/src/main/java/com/google/cloud/spark/spanner/SpannerUtils.java b/spark-3.1-spanner-lib/src/main/java/com/google/cloud/spark/spanner/SpannerUtils.java index 1800ee82..8e255a35 100644 --- a/spark-3.1-spanner-lib/src/main/java/com/google/cloud/spark/spanner/SpannerUtils.java +++ b/spark-3.1-spanner-lib/src/main/java/com/google/cloud/spark/spanner/SpannerUtils.java @@ -51,6 +51,9 @@ public class SpannerUtils { public static Long SECOND_TO_DAYS = 60 * 60 * 24L; + // TODO: Infer the UserAgent's version from the library version dynamically. + private static String USER_AGENT = "spark-spanner/v0.0.1"; + public static Connection connectionFromProperties(Map properties) { String connUriPrefix = "cloudspanner:"; String emulatorHost = properties.get("emulatorHost"); @@ -74,14 +77,11 @@ public static Connection connectionFromProperties(Map properties return opts.getConnection(); } - // TODO: Infer the UserAgent's version from the library version dynamically. - private static String userAgent = "spark-spanner/v0.0.1"; - public static BatchClientWithCloser batchClientFromProperties(Map properties) { SpannerOptions.Builder builder = SpannerOptions.newBuilder() .setProjectId(properties.get("projectId")) - .setHeaderProvider(FixedHeaderProvider.create("user-agent", userAgent)); + .setHeaderProvider(FixedHeaderProvider.create("user-agent", USER_AGENT)); String emulatorHost = properties.get("emulatorHost"); if (emulatorHost != null) {