OmniSciDB  a7179b2938
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
com.mapd.parser.extension.ddl.SqlColumnDeclaration Class Reference
+ Inheritance diagram for com.mapd.parser.extension.ddl.SqlColumnDeclaration:
+ Collaboration diagram for com.mapd.parser.extension.ddl.SqlColumnDeclaration:

Public Member Functions

SqlOperator getOperator ()
 
List< SqlNode > getOperandList ()
 
void unparse (SqlWriter writer, int leftPrec, int rightPrec)
 
String toString ()
 

Public Attributes

final SqlIdentifier name
 
final OmniSciSqlDataTypeSpec dataType
 
final SqlNode expression
 
final ColumnStrategy strategy
 

Package Functions

 SqlColumnDeclaration (SqlParserPos pos, SqlIdentifier name, OmniSciSqlDataTypeSpec dataType, SqlNode expression, ColumnStrategy strategy)
 

Private Member Functions

void exp (SqlWriter writer)
 

Static Private Attributes

static final SqlSpecialOperator OPERATOR
 

Detailed Description

Parse tree for

UNIQUE

,

PRIMARY KEY

constraints.

And

FOREIGN KEY

, when we support it.

Definition at line 49 of file SqlColumnDeclaration.java.

Constructor & Destructor Documentation

com.mapd.parser.extension.ddl.SqlColumnDeclaration.SqlColumnDeclaration ( SqlParserPos  pos,
SqlIdentifier  name,
OmniSciSqlDataTypeSpec  dataType,
SqlNode  expression,
ColumnStrategy  strategy 
)
inlinepackage

Member Function Documentation

void com.mapd.parser.extension.ddl.SqlColumnDeclaration.exp ( SqlWriter  writer)
inlineprivate

Definition at line 106 of file SqlColumnDeclaration.java.

Referenced by com.mapd.parser.extension.ddl.SqlColumnDeclaration.unparse().

106  {
107  if (writer.isAlwaysUseParentheses()) {
108  expression.unparse(writer, 0, 0);
109  } else {
110  writer.sep("(");
111  expression.unparse(writer, 0, 0);
112  writer.sep(")");
113  }
114  }

+ Here is the caller graph for this function:

List<SqlNode> com.mapd.parser.extension.ddl.SqlColumnDeclaration.getOperandList ( )
inline
SqlOperator com.mapd.parser.extension.ddl.SqlColumnDeclaration.getOperator ( )
inline

Definition at line 72 of file SqlColumnDeclaration.java.

References com.mapd.parser.extension.ddl.SqlColumnDeclaration.OPERATOR.

72  {
73  return OPERATOR;
74  }
String com.mapd.parser.extension.ddl.SqlColumnDeclaration.toString ( )
inline

Definition at line 117 of file SqlColumnDeclaration.java.

References com.mapd.parser.extension.ddl.omnisci.OmniSciTypeNameSpec.getIsArray().

117  {
118  EscapedStringJsonBuilder jsonBuilder = new EscapedStringJsonBuilder();
119  Map<String, Object> map = jsonBuilder.map();
120 
121  jsonBuilder.put(map, "type", "SQL_COLUMN_DECLARATION");
122 
123  jsonBuilder.put(map, "name", this.name == null ? null : this.name.toString());
124 
125  jsonBuilder.put(map,
126  "expression",
127  this.expression == null ? null : this.expression.toString());
128  jsonBuilder.put(map, "nullable", this.strategy == ColumnStrategy.NULLABLE);
129  jsonBuilder.put(map, "encodingType", this.dataType.getEncodingString());
130  jsonBuilder.put(map, "encodingSize", this.dataType.getEncodingSize());
131 
132  SqlTypeNameSpec dataTypeSpec = this.dataType.getTypeNameSpec();
133  if (dataTypeSpec instanceof OmniSciGeoTypeNameSpec) {
134  map = ((OmniSciGeoTypeNameSpec) dataTypeSpec).toJsonMap(map);
135  } else {
136  boolean isText = false;
137  if (dataTypeSpec instanceof OmniSciTypeNameSpec) {
138  OmniSciTypeNameSpec omniSciDataTypeSpec = (OmniSciTypeNameSpec) dataTypeSpec;
139  if (omniSciDataTypeSpec.getIsArray()) {
140  jsonBuilder.put(map, "arraySize", omniSciDataTypeSpec.getArraySize());
141  }
142  isText = omniSciDataTypeSpec.getIsText();
143  }
144  jsonBuilder.put(
145  map, "precision", ((SqlBasicTypeNameSpec) dataTypeSpec).getPrecision());
146  jsonBuilder.put(map, "scale", ((SqlBasicTypeNameSpec) dataTypeSpec).getScale());
147  if (isText) {
148  jsonBuilder.put(map, "sqltype", "TEXT");
149  } else {
150  jsonBuilder.put(map,
151  "sqltype",
152  this.dataType == null ? null : dataTypeSpec.getTypeName().toString());
153  }
154  }
155  return jsonBuilder.toJsonString(map);
156  }

+ Here is the call graph for this function:

void com.mapd.parser.extension.ddl.SqlColumnDeclaration.unparse ( SqlWriter  writer,
int  leftPrec,
int  rightPrec 
)
inline

Definition at line 82 of file SqlColumnDeclaration.java.

References com.mapd.parser.extension.ddl.SqlColumnDeclaration.dataType, com.mapd.parser.extension.ddl.SqlColumnDeclaration.exp(), com.mapd.parser.extension.ddl.SqlColumnDeclaration.expression, and com.mapd.parser.extension.ddl.SqlColumnDeclaration.strategy.

82  {
83  name.unparse(writer, 0, 0);
84  dataType.unparse(writer, 0, 0);
85  if (dataType.getNullable() != null && !dataType.getNullable()) {
86  writer.keyword("NOT NULL");
87  }
88  if (expression != null) {
89  switch (strategy) {
90  case VIRTUAL:
91  case STORED:
92  writer.keyword("AS");
93  exp(writer);
94  writer.keyword(strategy.name());
95  break;
96  case DEFAULT:
97  writer.keyword("DEFAULT");
98  exp(writer);
99  break;
100  default:
101  throw new AssertionError("unexpected: " + strategy);
102  }
103  }
104  }

+ Here is the call graph for this function:

Member Data Documentation

final SqlNode com.mapd.parser.extension.ddl.SqlColumnDeclaration.expression
final SqlSpecialOperator com.mapd.parser.extension.ddl.SqlColumnDeclaration.OPERATOR
staticprivate
Initial value:
=
new SqlSpecialOperator("COLUMN_DECL", SqlKind.COLUMN_DECL)

Definition at line 50 of file SqlColumnDeclaration.java.

Referenced by com.mapd.parser.extension.ddl.SqlColumnDeclaration.getOperator().

final ColumnStrategy com.mapd.parser.extension.ddl.SqlColumnDeclaration.strategy

The documentation for this class was generated from the following file: