OmniSciDB  95562058bd
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
OmniSqlDataType.java
Go to the documentation of this file.
1 package com.mapd.parser.extension.ddl.omnisql;
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 OmniSqlDataType extends OmniSqlJson {
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
22  private Integer coordinateSystem;
23  @Expose
25 
26  public OmniSqlDataType(final SqlDataTypeSpec type,
27  final boolean notNull,
28  final OmniSqlArray array,
29  final OmniSqlEncoding encoding) {
30  requireNonNull(type);
31  if (type.getTypeNameSpec() instanceof OmniSqlTypeNameSpec) {
32  OmniSqlTypeNameSpec omniSqlTypeNameSpec =
33  (OmniSqlTypeNameSpec) type.getTypeNameSpec();
34  this.type = omniSqlTypeNameSpec.getName();
35  this.coordinateSystem = omniSqlTypeNameSpec.getCoordinate();
36  } else {
37  this.type = type.getTypeName().toString();
38  }
39  if (type.getTypeNameSpec() instanceof SqlBasicTypeNameSpec) {
40  SqlBasicTypeNameSpec typeNameSpec = (SqlBasicTypeNameSpec) type.getTypeNameSpec();
41  this.precision =
42  typeNameSpec.getPrecision() == -1 ? null : typeNameSpec.getPrecision();
43  this.scale = typeNameSpec.getScale() == -1 ? null : typeNameSpec.getScale();
44  }
45  if (array != null) {
46  this.array = new OmniSqlArray(this.type, array.getSize());
47  this.type = "ARRAY";
48  }
49  this.notNull = notNull;
50  this.encoding = encoding;
51  }
52 }
OmniSqlDataType(final SqlDataTypeSpec type, final boolean notNull, final OmniSqlArray array, final OmniSqlEncoding encoding)