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

Public Member Functions

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

Static Public Member Functions

static SqlKeyConstraint unique (SqlParserPos pos, SqlIdentifier name, SqlNodeList columnList)
 
static SqlKeyConstraint primary (SqlParserPos pos, SqlIdentifier name, SqlNodeList columnList)
 
static SqlKeyConstraint shard (SqlParserPos pos, SqlIdentifier colName)
 
static SqlKeyConstraint sharedDict (SqlParserPos pos, SqlIdentifier colName, SqlIdentifier referencesCol)
 

Static Protected Attributes

static final SqlSpecialOperator PRIMARY
 

Package Functions

 SqlKeyConstraint (SqlParserPos pos, SqlIdentifier name, SqlNodeList columnList)
 
 SqlKeyConstraint (SqlParserPos pos, SqlIdentifier name, SqlNodeList columnList, SqlIdentifier referencesCol)
 

Private Attributes

final SqlIdentifier name
 
final SqlNodeList columnList
 
final SqlIdentifier referencesCol
 

Static Private Attributes

static final SqlSpecialOperator UNIQUE
 

Detailed Description

Parse tree for

,

PRIMARY KEY

constraints.

And

FOREIGN KEY

, when we support it.

Definition at line 41 of file SqlKeyConstraint.java.

Constructor & Destructor Documentation

com.mapd.parser.extension.ddl.SqlKeyConstraint.SqlKeyConstraint ( SqlParserPos  pos,
SqlIdentifier  name,
SqlNodeList  columnList 
)
inlinepackage
com.mapd.parser.extension.ddl.SqlKeyConstraint.SqlKeyConstraint ( SqlParserPos  pos,
SqlIdentifier  name,
SqlNodeList  columnList,
SqlIdentifier  referencesCol 
)
inlinepackage

Creates a SqlKeyConstraint between two (or more) columns

Definition at line 58 of file SqlKeyConstraint.java.

References com.mapd.parser.extension.ddl.SqlKeyConstraint.columnList, com.mapd.parser.extension.ddl.SqlKeyConstraint.name, and com.mapd.parser.extension.ddl.SqlKeyConstraint.referencesCol.

61  {
62  super(pos);
63  this.name = name;
64  this.columnList = columnList;
65  this.referencesCol = referencesCol;
66  }

Member Function Documentation

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

Definition at line 100 of file SqlKeyConstraint.java.

References com.mapd.parser.extension.ddl.SqlKeyConstraint.UNIQUE.

Referenced by com.mapd.parser.extension.ddl.SqlKeyConstraint.primary(), and com.mapd.parser.extension.ddl.SqlKeyConstraint.unparse().

100  {
101  return UNIQUE;
102  }

+ Here is the caller graph for this function:

static SqlKeyConstraint com.mapd.parser.extension.ddl.SqlKeyConstraint.primary ( SqlParserPos  pos,
SqlIdentifier  name,
SqlNodeList  columnList 
)
inlinestatic

Creates a PRIMARY KEY constraint.

Definition at line 75 of file SqlKeyConstraint.java.

References com.mapd.parser.extension.ddl.SqlKeyConstraint.getOperator(), com.mapd.parser.extension.ddl.SqlKeyConstraint.PRIMARY, and com.mapd.parser.extension.ddl.SqlKeyConstraint.SqlKeyConstraint().

76  {
77  return new SqlKeyConstraint(pos, name, columnList) {
78  @Override
79  public SqlOperator getOperator() {
80  return PRIMARY;
81  }
82  };
83  }
SqlKeyConstraint(SqlParserPos pos, SqlIdentifier name, SqlNodeList columnList)

+ Here is the call graph for this function:

static SqlKeyConstraint com.mapd.parser.extension.ddl.SqlKeyConstraint.shard ( SqlParserPos  pos,
SqlIdentifier  colName 
)
inlinestatic

Creates a SHARD KEY constraint

Definition at line 86 of file SqlKeyConstraint.java.

References com.mapd.parser.extension.ddl.SqlKeyConstraint.SqlKeyConstraint().

86  {
87  SqlNodeList colList = SqlNodeList.of(colName);
88  return new SqlKeyConstraint(pos, new SqlIdentifier("SHARD_KEY", pos), colList);
89  }
SqlKeyConstraint(SqlParserPos pos, SqlIdentifier name, SqlNodeList columnList)

+ Here is the call graph for this function:

static SqlKeyConstraint com.mapd.parser.extension.ddl.SqlKeyConstraint.sharedDict ( SqlParserPos  pos,
SqlIdentifier  colName,
SqlIdentifier  referencesCol 
)
inlinestatic

CReates a SHARED DICTIONARY constraint

Definition at line 92 of file SqlKeyConstraint.java.

References com.mapd.parser.extension.ddl.SqlKeyConstraint.SqlKeyConstraint().

93  {
94  SqlNodeList colList = SqlNodeList.of(colName);
95  return new SqlKeyConstraint(
96  pos, new SqlIdentifier("SHARED_DICT", pos), colList, referencesCol);
97  }
SqlKeyConstraint(SqlParserPos pos, SqlIdentifier name, SqlNodeList columnList)

+ Here is the call graph for this function:

String com.mapd.parser.extension.ddl.SqlKeyConstraint.toString ( )
inline

Definition at line 120 of file SqlKeyConstraint.java.

References com.mapd.parser.extension.ddl.SqlKeyConstraint.referencesCol.

120  {
121  EscapedStringJsonBuilder jsonBuilder = new EscapedStringJsonBuilder();
122  Map<String, Object> map = jsonBuilder.map();
123 
124  jsonBuilder.put(map, "type", "SQL_COLUMN_CONSTRAINT");
125 
126  jsonBuilder.put(map, "name", this.name == null ? null : this.name.toString());
127 
128  List<String> colNamesList = new ArrayList<String>();
129  for (int i = 0; i < columnList.size(); i++) {
130  SqlNode colNode = columnList.get(i);
131  colNamesList.add(colNode.toString());
132  }
133  jsonBuilder.put(map, "columns", colNamesList);
134 
135  Map<String, Object> referencesMap = jsonBuilder.map();
136  if (referencesCol != null) {
137  if (referencesCol.isSimple()) {
138  jsonBuilder.put(referencesMap, "column", referencesCol.toString());
139  } else {
140  jsonBuilder.put(referencesMap, "table", referencesCol.getComponent(0).toString());
141  jsonBuilder.put(
142  referencesMap, "column", referencesCol.getComponent(1).toString());
143  }
144  }
145  jsonBuilder.put(map, "references", referencesMap);
146 
147  return jsonBuilder.toJsonString(map);
148  }
static SqlKeyConstraint com.mapd.parser.extension.ddl.SqlKeyConstraint.unique ( SqlParserPos  pos,
SqlIdentifier  name,
SqlNodeList  columnList 
)
inlinestatic

Creates a UNIQUE constraint.

Definition at line 69 of file SqlKeyConstraint.java.

References com.mapd.parser.extension.ddl.SqlKeyConstraint.SqlKeyConstraint().

70  {
71  return new SqlKeyConstraint(pos, name, columnList);
72  }
SqlKeyConstraint(SqlParserPos pos, SqlIdentifier name, SqlNodeList columnList)

+ Here is the call graph for this function:

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

Definition at line 110 of file SqlKeyConstraint.java.

References com.mapd.parser.extension.ddl.SqlKeyConstraint.getOperator(), and com.mapd.parser.extension.ddl.SqlKeyConstraint.name.

110  {
111  if (name != null) {
112  writer.keyword("CONSTRAINT");
113  name.unparse(writer, 0, 0);
114  }
115  writer.keyword(getOperator().getName()); // "UNIQUE" or "PRIMARY KEY"
116  columnList.unparse(writer, 1, 1);
117  }

+ Here is the call graph for this function:

Member Data Documentation

final SqlNodeList com.mapd.parser.extension.ddl.SqlKeyConstraint.columnList
private
final SqlSpecialOperator com.mapd.parser.extension.ddl.SqlKeyConstraint.PRIMARY
staticprotected
Initial value:
=
new SqlSpecialOperator("PRIMARY KEY", SqlKind.PRIMARY_KEY)

Definition at line 45 of file SqlKeyConstraint.java.

Referenced by com.mapd.parser.extension.ddl.SqlKeyConstraint.primary().

final SqlIdentifier com.mapd.parser.extension.ddl.SqlKeyConstraint.referencesCol
private
final SqlSpecialOperator com.mapd.parser.extension.ddl.SqlKeyConstraint.UNIQUE
staticprivate
Initial value:
=
new SqlSpecialOperator("UNIQUE", SqlKind.UNIQUE)

Definition at line 42 of file SqlKeyConstraint.java.

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


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