|
25 | 25 | import com.google.api.services.bigquery.model.TableFieldSchema; |
26 | 26 | import com.google.common.base.Function; |
27 | 27 | import com.google.common.base.MoreObjects; |
| 28 | +import com.google.common.base.Preconditions; |
28 | 29 | import com.google.common.collect.Lists; |
29 | 30 | import java.io.Serializable; |
30 | 31 | import java.util.List; |
@@ -89,7 +90,7 @@ public static final class Builder { |
89 | 90 | private Long maxLength; |
90 | 91 | private Long scale; |
91 | 92 | private Long precision; |
92 | | - private Long timestampPrecision; |
| 93 | + private Long timestampPrecision = 6L; // Default to microsecond precision |
93 | 94 | private String defaultValueExpression; |
94 | 95 | private String collation; |
95 | 96 | private FieldElementType rangeElementType; |
@@ -263,6 +264,9 @@ public Builder setPrecision(Long precision) { |
263 | 264 | * <p>The default value is 6. Possible values are 6 (microsecond) or 12 (picosecond). |
264 | 265 | */ |
265 | 266 | public Builder setTimestampPrecision(Long timestampPrecision) { |
| 267 | + Preconditions.checkArgument( |
| 268 | + timestampPrecision == 6L || timestampPrecision == 12L, |
| 269 | + "Timestamp Precision must be 6 (microsecond) or 12 (picosecond)"); |
266 | 270 | this.timestampPrecision = timestampPrecision; |
267 | 271 | return this; |
268 | 272 | } |
@@ -384,7 +388,7 @@ public Long getPrecision() { |
384 | 388 | return precision; |
385 | 389 | } |
386 | 390 |
|
387 | | - /** Returns the for precision of TIMESTAMP type. */ |
| 391 | + /** Returns the precision for TIMESTAMP type. */ |
388 | 392 | public Long getTimestampPrecision() { |
389 | 393 | return timestampPrecision; |
390 | 394 | } |
|
0 commit comments