Skip to content

Commit 5440235

Browse files
authored
Merge pull request GoogleCloudPlatform#495 from GoogleCloudPlatform/tswast-bq
BigQuery REST samples to label datasets and tables.
2 parents 34a1592 + 26c61c6 commit 5440235

File tree

8 files changed

+463
-17
lines changed

8 files changed

+463
-17
lines changed

.travis.yml

+1
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ before_install:
4242
- openssl aes-256-cbc -K $encrypted_eb858daba67b_key -iv $encrypted_eb858daba67b_iv -in secrets.env.enc -out secrets.env -d
4343
&& set +x && source secrets.env && set -x
4444
|| true
45+
- export GOOGLE_CLOUD_PROJECT=java-docs-samples-tests
4546
# Skip the install step, since Maven will download the dependencies we need
4647
# when the test build runs.
4748
# http://stackoverflow.com/q/31945809/101923

bigquery/pom.xml

+6-17
Original file line numberDiff line numberDiff line change
@@ -75,23 +75,12 @@
7575
</properties>
7676

7777
<build>
78-
<sourceDirectory>src/main/java</sourceDirectory>
79-
<resources>
80-
<resource>
81-
<directory>src/main/resources</directory>
82-
</resource>
83-
</resources>
84-
<plugins>
85-
<plugin>
86-
<groupId>org.apache.maven.plugins</groupId>
87-
<artifactId>maven-compiler-plugin</artifactId>
88-
<version>3.2</version>
89-
<configuration>
90-
<source>5</source>
91-
<target>5</target>
92-
</configuration>
93-
</plugin>
94-
</plugins>
78+
<sourceDirectory>src/main/java</sourceDirectory>
79+
<resources>
80+
<resource>
81+
<directory>src/main/resources</directory>
82+
</resource>
83+
</resources>
9584
</build>
9685

9786
</project>

bigquery/rest/README.md

+52
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
# Getting Started with BigQuery with the REST API
2+
3+
Google's BigQuery Service features a REST-based API that allows developers to
4+
create applications to run ad-hoc queries on massive datasets. These sample
5+
Java applications demonstrate how to access the BigQuery API directly using the
6+
Google HTTP Client.
7+
8+
## Quickstart
9+
10+
Install [Maven](http://maven.apache.org/).
11+
12+
Build your project with:
13+
14+
mvn clean package -DskipTests
15+
16+
You can then run a given `ClassName` via:
17+
18+
mvn exec:java -Dexec.mainClass=com.example.bigquery.ClassName \
19+
-Dexec.args="any arguments to the app"
20+
21+
### Labeling a dataset
22+
23+
[Label a dataset](https://cloud.google.com/bigquery/docs/labeling-datasets).
24+
25+
mvn exec:java -Dexec.mainClass=com.example.bigquery.LabelsSample \
26+
-Dexec.args="project-id dataset-id label-key label-value"
27+
28+
## Testing
29+
30+
To run the tests for this sample, first set the `GOOGLE_CLOUD_PROJECT`
31+
environment variable. The project should have a dataset named `test_dataset`
32+
with a table named `test_table`.
33+
34+
export GOOGLE_CLOUD_PROJECT=my-project
35+
36+
Then run the tests with Maven.
37+
38+
mvn clean verify
39+
40+
## Products
41+
- [Google BigQuery][2]
42+
43+
## Language
44+
- [Java][3]
45+
46+
## Dependencies
47+
- [Google HTTP Client Library for Java][4]
48+
49+
[2]: https://cloud.google.com/bigquery
50+
[3]: https://java.com
51+
[4]: https://github.com/google/google-http-java-client
52+

bigquery/rest/pom.xml

+100
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,100 @@
1+
<!--
2+
Copyright 2016 Google Inc.
3+
4+
Licensed under the Apache License, Version 2.0 (the "License");
5+
you may not use this file except in compliance with the License.
6+
You may obtain a copy of the License at
7+
8+
http://www.apache.org/licenses/LICENSE-2.0
9+
10+
Unless required by applicable law or agreed to in writing, software
11+
distributed under the License is distributed on an "AS IS" BASIS,
12+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
See the License for the specific language governing permissions and
14+
limitations under the License.
15+
-->
16+
<project>
17+
<modelVersion>4.0.0</modelVersion>
18+
<version>1.0.0</version>
19+
20+
<groupId>com.google.cloud.samples</groupId>
21+
<artifactId>bigquery-rest-samples</artifactId>
22+
<packaging>jar</packaging>
23+
24+
<!-- Parent POM defines common plugins and properties. -->
25+
<parent>
26+
<artifactId>doc-samples</artifactId>
27+
<groupId>com.google.cloud</groupId>
28+
<version>1.0.0</version>
29+
<relativePath>../..</relativePath>
30+
</parent>
31+
32+
<properties>
33+
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
34+
</properties>
35+
36+
<dependencies>
37+
<dependency>
38+
<groupId>com.google.guava</groupId>
39+
<artifactId>guava</artifactId>
40+
<version>20.0</version>
41+
</dependency>
42+
<dependency>
43+
<groupId>com.google.api-client</groupId>
44+
<artifactId>google-api-client</artifactId>
45+
<version>1.22.0</version>
46+
<exclusions>
47+
<exclusion> <!-- exclude an old version of Guava -->
48+
<groupId>com.google.guava</groupId>
49+
<artifactId>guava-jdk5</artifactId>
50+
</exclusion>
51+
</exclusions>
52+
</dependency>
53+
<dependency>
54+
<groupId>com.google.http-client</groupId>
55+
<artifactId>google-http-client</artifactId>
56+
<version>1.22.0</version>
57+
<exclusions>
58+
<exclusion> <!-- exclude an old version of Guava -->
59+
<groupId>com.google.guava</groupId>
60+
<artifactId>guava-jdk5</artifactId>
61+
</exclusion>
62+
</exclusions>
63+
</dependency>
64+
<dependency>
65+
<groupId>com.google.oauth-client</groupId>
66+
<artifactId>google-oauth-client</artifactId>
67+
<version>1.22.0</version>
68+
<exclusions>
69+
<exclusion> <!-- exclude an old version of Guava -->
70+
<groupId>com.google.guava</groupId>
71+
<artifactId>guava-jdk5</artifactId>
72+
</exclusion>
73+
</exclusions>
74+
</dependency>
75+
76+
<!-- Test dependencies -->
77+
<dependency>
78+
<groupId>junit</groupId>
79+
<artifactId>junit</artifactId>
80+
<version>4.12</version>
81+
<scope>test</scope>
82+
</dependency>
83+
<dependency>
84+
<groupId>com.google.truth</groupId>
85+
<artifactId>truth</artifactId>
86+
<version>0.31</version>
87+
<scope>test</scope>
88+
</dependency>
89+
</dependencies>
90+
91+
<build>
92+
<sourceDirectory>src/main/java</sourceDirectory>
93+
<resources>
94+
<resource>
95+
<directory>src/main/resources</directory>
96+
</resource>
97+
</resources>
98+
</build>
99+
100+
</project>

0 commit comments

Comments
 (0)