Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add connector.version as build property #121

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions spark-3.1-spanner-lib/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -46,4 +46,12 @@
<artifactId>jackson-databind</artifactId>
</dependency>
</dependencies>
<build>
<resources>
<resource>
<directory>src/main/resources</directory>
<filtering>true</filtering>
</resource>
</resources>
</build>
</project>
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Properties;
import org.apache.spark.sql.Dataset;
import org.apache.spark.sql.Encoder;
import org.apache.spark.sql.Encoders;
Expand Down Expand Up @@ -69,7 +70,20 @@ 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";
private static final Properties BUILD_PROPERTIES = loadBuildProperties();
private static final String USER_AGENT =
"spark-spanner/v".concat(BUILD_PROPERTIES.getProperty("connector.version"));

private static Properties loadBuildProperties() {
try {
Properties buildProperties = new Properties();
buildProperties.load(
SpannerUtils.class.getResourceAsStream("/spark-spanner-connector.properties"));
return buildProperties;
} finally {
return new Properties();
Copy link
Member

Choose a reason for hiding this comment

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

This will fail line 74

}
}

public static Connection connectionFromProperties(Map<String, String> properties) {
String connUriPrefix = "cloudspanner:";
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
#connector.version=${project.version}
connector.version=3.1
Copy link
Member

Choose a reason for hiding this comment

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

Any reason for that? the idea is to track the connector's version for the user agent

Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
connector.version=3.1