OmniSciDB  6686921089
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups 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 defaultValue
 
final ColumnStrategy strategy
 

Package Functions

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

Private Member Functions

void exp (SqlWriter writer)
 

Static Private Attributes

static final SqlSpecialOperator OPERATOR
 

Detailed Description

Parse tree for

,

PRIMARY KEY

constraints.

And

FOREIGN KEY

, when we support it.

Definition at line 46 of file SqlColumnDeclaration.java.

Constructor & Destructor Documentation

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

Member Function Documentation

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

Definition at line 97 of file SqlColumnDeclaration.java.

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

97  {
98  if (writer.isAlwaysUseParentheses()) {
99  defaultValue.unparse(writer, 0, 0);
100  } else {
101  writer.sep("(");
102  defaultValue.unparse(writer, 0, 0);
103  writer.sep(")");
104  }
105  }

+ 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 69 of file SqlColumnDeclaration.java.

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

69  {
70  return OPERATOR;
71  }
String com.mapd.parser.extension.ddl.SqlColumnDeclaration.toString ( )
inline

Definition at line 108 of file SqlColumnDeclaration.java.

References com.mapd.parser.extension.ddl.SqlColumnDeclaration.dataType, com.mapd.parser.extension.ddl.SqlColumnDeclaration.defaultValue, com.mapd.parser.extension.ddl.omnisci.OmniSciTypeNameSpec.getIsArray(), and com.mapd.parser.extension.ddl.SqlColumnDeclaration.name.

108  {
109  EscapedStringJsonBuilder jsonBuilder = new EscapedStringJsonBuilder();
110  Map<String, Object> map = jsonBuilder.map();
111 
112  jsonBuilder.put(map, "type", "SQL_COLUMN_DECLARATION");
113 
114  jsonBuilder.put(map, "name", name == null ? null : name.toString());
115 
116  jsonBuilder.put(
117  map, "default", defaultValue == null ? null : defaultValue.toString());
118  jsonBuilder.put(map, "nullable", !Boolean.FALSE.equals(dataType.getNullable()));
119  jsonBuilder.put(map, "encodingType", dataType.getEncodingString());
120  jsonBuilder.put(map, "encodingSize", dataType.getEncodingSize());
121 
122  SqlTypeNameSpec dataTypeSpec = dataType.getTypeNameSpec();
123  if (dataTypeSpec instanceof OmniSciGeoTypeNameSpec) {
124  map = ((OmniSciGeoTypeNameSpec) dataTypeSpec).toJsonMap(map);
125  } else {
126  boolean isText = false;
127  if (dataTypeSpec instanceof OmniSciTypeNameSpec) {
128  OmniSciTypeNameSpec omniSciDataTypeSpec = (OmniSciTypeNameSpec) dataTypeSpec;
129  if (omniSciDataTypeSpec.getIsArray()) {
130  jsonBuilder.put(map, "arraySize", omniSciDataTypeSpec.getArraySize());
131  }
132  isText = omniSciDataTypeSpec.getIsText();
133  }
134  jsonBuilder.put(
135  map, "precision", ((SqlBasicTypeNameSpec) dataTypeSpec).getPrecision());
136  jsonBuilder.put(map, "scale", ((SqlBasicTypeNameSpec) dataTypeSpec).getScale());
137  if (isText) {
138  jsonBuilder.put(map, "sqltype", "TEXT");
139  } else {
140  jsonBuilder.put(map,
141  "sqltype",
142  dataType == null ? null : dataTypeSpec.getTypeName().toString());
143  }
144  }
145  return jsonBuilder.toJsonString(map);
146  }

+ 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 79 of file SqlColumnDeclaration.java.

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

79  {
80  name.unparse(writer, 0, 0);
81  dataType.unparse(writer, 0, 0);
82  if (dataType.getNullable() != null && !dataType.getNullable()) {
83  writer.keyword("NOT NULL");
84  }
85  if (defaultValue != null) {
86  switch (strategy) {
87  case DEFAULT:
88  writer.keyword("DEFAULT");
89  exp(writer);
90  break;
91  default:
92  throw new AssertionError("unexpected: " + strategy);
93  }
94  }
95  }
#define DEFAULT

+ Here is the call graph for this function:

Member Data Documentation

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

Definition at line 47 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: