OmniSciDB  a5dc49c757
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
HeavySqlDataType.java
Go to the documentation of this file.
1 package com.mapd.parser.extension.ddl.heavysql;
2 
3 import static java.util.Objects.requireNonNull;
4 
5 import com.google.gson.annotations.Expose;
6 
7 import org.apache.calcite.sql.SqlBasicTypeNameSpec;
8 import org.apache.calcite.sql.SqlDataTypeSpec;
9 
10 public class HeavySqlDataType extends HeavySqlJson {
11  @Expose
12  private String type;
13  @Expose
15  @Expose
16  private Integer precision;
17  @Expose
18  private Integer scale;
19  @Expose
20  private boolean notNull;
21  @Expose
23  @Expose
25 
26  public HeavySqlDataType(final SqlDataTypeSpec type,
27  final boolean notNull,
28  final HeavySqlArray array,
29  final HeavySqlEncoding encoding) {
30  requireNonNull(type);
31  if (type.getTypeNameSpec() instanceof HeavySqlTypeNameSpec) {
32  HeavySqlTypeNameSpec typeNameSpec = (HeavySqlTypeNameSpec) type.getTypeNameSpec();
33  this.type = typeNameSpec.getName();
34  this.coordinateSystem = typeNameSpec.getCoordinate();
35  } else {
36  this.type = type.getTypeName().toString();
37  }
38  if (type.getTypeNameSpec() instanceof SqlBasicTypeNameSpec) {
39  SqlBasicTypeNameSpec typeNameSpec = (SqlBasicTypeNameSpec) type.getTypeNameSpec();
40  this.precision =
41  typeNameSpec.getPrecision() == -1 ? null : typeNameSpec.getPrecision();
42  this.scale = typeNameSpec.getScale() == -1 ? null : typeNameSpec.getScale();
43  }
44  if (array != null) {
45  this.array = new HeavySqlArray(this.type, array.getSize());
46  this.type = "ARRAY";
47  }
48  this.notNull = notNull;
49  this.encoding = encoding;
50  }
51 }
HeavySqlDataType(final SqlDataTypeSpec type, final boolean notNull, final HeavySqlArray array, final HeavySqlEncoding encoding)