OmniSciDB  04ee39c94c
org.apache.calcite.rel.externalize.MapDRelJson Class Reference
+ Collaboration diagram for org.apache.calcite.rel.externalize.MapDRelJson:

Public Member Functions

 MapDRelJson (JsonBuilder jsonBuilder)
 
RelNode create (Map< String, Object > map)
 
Constructor getConstructor (String type)
 
Class typeNameToClass (String type)
 
String classToTypeName (Class<? extends RelNode > class_)
 
Object toJson (RelCollationImpl node)
 
Object toJson (RexFieldCollation node)
 
RelCollation toCollation (List< Map< String, Object >> jsonFieldCollations)
 
RelFieldCollation toFieldCollation (Map< String, Object > map)
 
RelDistribution toDistribution (Object o)
 
RelDataType toType (RelDataTypeFactory typeFactory, Object o)
 
Object toJson (AggregateCall node)
 

Static Public Attributes

static final List< String > PACKAGES
 

Package Functions

Object toJson (Object value)
 
RexNode toRex (RelInput relInput, Object o)
 
SqlAggFunction toAggregation (String agg, Map< String, Object > map)
 

Private Member Functions

Object toJson (RelDataType node)
 
Object toJson (RelDataTypeField node)
 
Object toJson (CorrelationId node)
 
Object toJson (final RexWindowBound window_bound)
 
Object toJson (RexNode node)
 
List< RexNode > toRexList (RelInput relInput, List operands)
 
SqlOperator toOp (String op, Map< String, Object > map)
 
String toJson (SqlOperator operator)
 

Private Attributes

final Map< String, Constructor > constructorMap
 
final JsonBuilder jsonBuilder
 

Detailed Description

Utilities for converting org.apache.calcite.rel.RelNode into JSON format.

Definition at line 72 of file MapDRelJson.java.

Constructor & Destructor Documentation

◆ MapDRelJson()

org.apache.calcite.rel.externalize.MapDRelJson.MapDRelJson ( JsonBuilder  jsonBuilder)
inline

Member Function Documentation

◆ classToTypeName()

String org.apache.calcite.rel.externalize.MapDRelJson.classToTypeName ( Class<? extends RelNode >  class_)
inline

Inverse of typeNameToClass.

Definition at line 144 of file MapDRelJson.java.

References Experimental.String.

Referenced by org.apache.calcite.rel.externalize.MapDRelJsonWriter.explain_().

144  {
145  final String canonicalName = class_.getName();
146  for (String package_ : PACKAGES) {
147  if (canonicalName.startsWith(package_)) {
148  String remaining = canonicalName.substring(package_.length());
149  if (remaining.indexOf('.') < 0 && remaining.indexOf('$') < 0) {
150  return remaining;
151  }
152  }
153  }
154  return canonicalName;
155  }
+ Here is the caller graph for this function:

◆ create()

RelNode org.apache.calcite.rel.externalize.MapDRelJson.create ( Map< String, Object >  map)
inline

Definition at line 88 of file MapDRelJson.java.

References org.apache.calcite.rel.externalize.MapDRelJson.getConstructor(), Experimental.String, and run-benchmark-import.type.

88  {
89  String type = (String) map.get("type");
90  Constructor constructor = getConstructor(type);
91  try {
92  return (RelNode) constructor.newInstance(map);
93  } catch (InstantiationException e) {
94  throw new RuntimeException("while invoking constructor for type '" + type + "'", e);
95  } catch (IllegalAccessException e) {
96  throw new RuntimeException("while invoking constructor for type '" + type + "'", e);
97  } catch (InvocationTargetException e) {
98  throw new RuntimeException("while invoking constructor for type '" + type + "'", e);
99  } catch (ClassCastException e) {
100  throw new RuntimeException("while invoking constructor for type '" + type + "'", e);
101  }
102  }
+ Here is the call graph for this function:

◆ getConstructor()

Constructor org.apache.calcite.rel.externalize.MapDRelJson.getConstructor ( String  type)
inline

Definition at line 104 of file MapDRelJson.java.

References org.apache.calcite.rel.externalize.MapDRelJson.typeNameToClass().

Referenced by org.apache.calcite.rel.externalize.MapDRelJson.create().

104  {
105  Constructor constructor = constructorMap.get(type);
106  if (constructor == null) {
107  Class clazz = typeNameToClass(type);
108  try {
109  // noinspection unchecked
110  constructor = clazz.getConstructor(RelInput.class);
111  } catch (NoSuchMethodException e) {
112  throw new RuntimeException(
113  "class does not have required constructor, " + clazz + "(RelInput)");
114  }
115  constructorMap.put(type, constructor);
116  }
117  return constructor;
118  }
final Map< String, Constructor > constructorMap
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ toAggregation()

SqlAggFunction org.apache.calcite.rel.externalize.MapDRelJson.toAggregation ( String  agg,
Map< String, Object >  map 
)
inlinepackage

Definition at line 517 of file MapDRelJson.java.

References org.apache.calcite.rel.externalize.MapDRelJson.toOp().

517  {
518  return (SqlAggFunction) toOp(agg, map);
519  }
SqlOperator toOp(String op, Map< String, Object > map)
+ Here is the call graph for this function:

◆ toCollation()

RelCollation org.apache.calcite.rel.externalize.MapDRelJson.toCollation ( List< Map< String, Object >>  jsonFieldCollations)
inline

Definition at line 177 of file MapDRelJson.java.

References org.apache.calcite.rel.externalize.MapDRelJson.toFieldCollation().

177  {
178  final List<RelFieldCollation> fieldCollations = new ArrayList<RelFieldCollation>();
179  for (Map<String, Object> map : jsonFieldCollations) {
180  fieldCollations.add(toFieldCollation(map));
181  }
182  return RelCollations.of(fieldCollations);
183  }
RelFieldCollation toFieldCollation(Map< String, Object > map)
+ Here is the call graph for this function:

◆ toDistribution()

RelDistribution org.apache.calcite.rel.externalize.MapDRelJson.toDistribution ( Object  o)
inline

Definition at line 194 of file MapDRelJson.java.

194  {
195  return RelDistributions.ANY; // TODO:
196  }

◆ toFieldCollation()

RelFieldCollation org.apache.calcite.rel.externalize.MapDRelJson.toFieldCollation ( Map< String, Object >  map)
inline

Definition at line 185 of file MapDRelJson.java.

References field(), Integer, and Experimental.String.

Referenced by org.apache.calcite.rel.externalize.MapDRelJson.toCollation().

185  {
186  final Integer field = (Integer) map.get("field");
187  final RelFieldCollation.Direction direction = Util.enumVal(
188  RelFieldCollation.Direction.class, (String) map.get("direction"));
189  final RelFieldCollation.NullDirection nullDirection = Util.enumVal(
190  RelFieldCollation.NullDirection.class, (String) map.get("nulls"));
191  return new RelFieldCollation(field, direction, nullDirection);
192  }
const rapidjson::Value & field(const rapidjson::Value &obj, const char field[]) noexcept
Definition: JsonAccessors.h:31
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ toJson() [1/10]

Object org.apache.calcite.rel.externalize.MapDRelJson.toJson ( RelCollationImpl  node)
inline

Definition at line 157 of file MapDRelJson.java.

Referenced by org.apache.calcite.rel.externalize.MapDRelJsonWriter.put(), and org.apache.calcite.rel.externalize.MapDRelJson.toJson().

157  {
158  final List<Object> list = new ArrayList<Object>();
159  for (RelFieldCollation fieldCollation : node.getFieldCollations()) {
160  final Map<String, Object> map = jsonBuilder.map();
161  map.put("field", fieldCollation.getFieldIndex());
162  map.put("direction", fieldCollation.getDirection().name());
163  map.put("nulls", fieldCollation.nullDirection.name());
164  list.add(map);
165  }
166  return list;
167  }
+ Here is the caller graph for this function:

◆ toJson() [2/10]

Object org.apache.calcite.rel.externalize.MapDRelJson.toJson ( RexFieldCollation  node)
inline

Definition at line 169 of file MapDRelJson.java.

References org.apache.calcite.rel.externalize.MapDRelJson.toJson().

169  {
170  final Map<String, Object> map = jsonBuilder.map();
171  map.put("field", toJson(node.left));
172  map.put("direction", node.getDirection().name());
173  map.put("nulls", node.getNullDirection().name());
174  return map;
175  }
+ Here is the call graph for this function:

◆ toJson() [3/10]

Object org.apache.calcite.rel.externalize.MapDRelJson.toJson ( AggregateCall  node)
inline

Definition at line 226 of file MapDRelJson.java.

References org.apache.calcite.rel.externalize.MapDRelJson.toJson().

226  {
227  final Map<String, Object> map = jsonBuilder.map();
228  map.put("agg", toJson(node.getAggregation()));
229  map.put("type", toJson(node.getType()));
230  map.put("distinct", node.isDistinct());
231  map.put("operands", node.getArgList());
232  return map;
233  }
+ Here is the call graph for this function:

◆ toJson() [4/10]

Object org.apache.calcite.rel.externalize.MapDRelJson.toJson ( Object  value)
inlinepackage

Definition at line 235 of file MapDRelJson.java.

References Integer, Experimental.String, and org.apache.calcite.rel.externalize.MapDRelJson.toJson().

235  {
236  if (value == null || value instanceof Number || value instanceof String
237  || value instanceof Boolean) {
238  return value;
239  } else if (value instanceof RexNode) {
240  return toJson((RexNode) value);
241  } else if (value instanceof CorrelationId) {
242  return toJson((CorrelationId) value);
243  } else if (value instanceof List) {
244  final List<Object> list = jsonBuilder.list();
245  for (Object o : (List) value) {
246  list.add(toJson(o));
247  }
248  return list;
249  } else if (value instanceof ImmutableBitSet) {
250  final List<Object> list = jsonBuilder.list();
251  for (Integer integer : (ImmutableBitSet) value) {
252  list.add(toJson(integer));
253  }
254  return list;
255  } else if (value instanceof AggregateCall) {
256  return toJson((AggregateCall) value);
257  } else if (value instanceof RelCollationImpl) {
258  return toJson((RelCollationImpl) value);
259  } else if (value instanceof RexFieldCollation) {
260  return toJson((RexFieldCollation) value);
261  } else if (value instanceof RelDataType) {
262  return toJson((RelDataType) value);
263  } else if (value instanceof RelDataTypeField) {
264  return toJson((RelDataTypeField) value);
265  } else if (value instanceof SemiJoinType) {
266  return value.toString();
267  } else if (value instanceof Operation) {
268  return value.toString();
269  } else {
270  throw new UnsupportedOperationException("type not serializable: " + value
271  + " (type " + value.getClass().getCanonicalName() + ")");
272  }
273  }
+ Here is the call graph for this function:

◆ toJson() [5/10]

Object org.apache.calcite.rel.externalize.MapDRelJson.toJson ( RelDataType  node)
inlineprivate

Definition at line 275 of file MapDRelJson.java.

References field(), and org.apache.calcite.rel.externalize.MapDRelJson.toJson().

275  {
276  if (node.isStruct()) {
277  final List<Object> list = jsonBuilder.list();
278  for (RelDataTypeField field : node.getFieldList()) {
279  list.add(toJson(field));
280  }
281  return list;
282  } else {
283  final Map<String, Object> map = jsonBuilder.map();
284  map.put("type", node.getSqlTypeName().name());
285  map.put("nullable", node.isNullable());
286  if (node.getSqlTypeName().allowsPrec()) {
287  map.put("precision", node.getPrecision());
288  }
289  if (node.getSqlTypeName().allowsScale()) {
290  map.put("scale", node.getScale());
291  }
292  return map;
293  }
294  }
const rapidjson::Value & field(const rapidjson::Value &obj, const char field[]) noexcept
Definition: JsonAccessors.h:31
+ Here is the call graph for this function:

◆ toJson() [6/10]

Object org.apache.calcite.rel.externalize.MapDRelJson.toJson ( RelDataTypeField  node)
inlineprivate

Definition at line 296 of file MapDRelJson.java.

References org.apache.calcite.rel.externalize.MapDRelJson.toJson().

296  {
297  final Map<String, Object> map = (Map<String, Object>) toJson(node.getType());
298  map.put("name", node.getName());
299  return map;
300  }
+ Here is the call graph for this function:

◆ toJson() [7/10]

Object org.apache.calcite.rel.externalize.MapDRelJson.toJson ( CorrelationId  node)
inlineprivate

Definition at line 302 of file MapDRelJson.java.

302  {
303  return node.getId();
304  }

◆ toJson() [8/10]

Object org.apache.calcite.rel.externalize.MapDRelJson.toJson ( final RexWindowBound  window_bound)
inlineprivate

Definition at line 306 of file MapDRelJson.java.

References org.apache.calcite.rel.externalize.MapDRelJson.toJson().

306  {
307  final Map<String, Object> map = jsonBuilder.map();
308  map.put("unbounded", toJson(window_bound.isUnbounded()));
309  map.put("preceding", toJson(window_bound.isPreceding()));
310  map.put("following", toJson(window_bound.isFollowing()));
311  map.put("is_current_row", toJson(window_bound.isCurrentRow()));
312  map.put("offset",
313  window_bound.getOffset() != null ? toJson(window_bound.getOffset()) : null);
314  map.put("order_key", toJson(window_bound.getOrderKey()));
315  return map;
316  }
+ Here is the call graph for this function:

◆ toJson() [9/10]

Object org.apache.calcite.rel.externalize.MapDRelJson.toJson ( RexNode  node)
inlineprivate

Definition at line 318 of file MapDRelJson.java.

References org.apache.calcite.rel.externalize.MapDRelJsonWriter.asJsonMap(), Experimental.String, and org.apache.calcite.rel.externalize.MapDRelJson.toJson().

318  {
319  final Map<String, Object> map;
320  switch (node.getKind()) {
321  case FIELD_ACCESS:
322  map = jsonBuilder.map();
323  final RexFieldAccess fieldAccess = (RexFieldAccess) node;
324  map.put("field", fieldAccess.getField().getName());
325  map.put("expr", toJson(fieldAccess.getReferenceExpr()));
326  return map;
327  case LITERAL:
328  final RexLiteral literal = (RexLiteral) node;
329  final Object value2 = literal.getValue2();
330  map = jsonBuilder.map();
331  if (value2 instanceof TimeUnitRange) {
332  map.put("literal", value2.toString());
333  } else {
334  if (value2 instanceof String) {
335  map.put("literal", ((String) value2).replace("\\", "\\\\"));
336  } else {
337  map.put("literal", value2);
338  }
339  }
340  map.put("type", literal.getTypeName().name());
341  map.put("target_type", literal.getType().getSqlTypeName().toString());
342  final Object value = literal.getValue();
343  if (value instanceof BigDecimal) {
344  map.put("scale", ((BigDecimal) value).scale());
345  map.put("precision", ((BigDecimal) value).precision());
346  } else {
347  map.put("scale", literal.getType().getScale());
348  map.put("precision", literal.getType().getPrecision());
349  }
350  map.put("type_scale", literal.getType().getScale());
351  map.put("type_precision", literal.getType().getPrecision());
352  return map;
353  case INPUT_REF:
354  map = jsonBuilder.map();
355  map.put("input", ((RexInputRef) node).getIndex());
356  return map;
357  case CORREL_VARIABLE:
358  map = jsonBuilder.map();
359  map.put("correl", ((RexCorrelVariable) node).getName());
360  map.put("type", toJson(node.getType()));
361  return map;
362  default:
363  if (node instanceof RexCall) {
364  final RexCall call = (RexCall) node;
365  map = jsonBuilder.map();
366  map.put("op", toJson(call.getOperator()));
367  final List<Object> list = jsonBuilder.list();
368  for (RexNode operand : call.getOperands()) {
369  list.add(toJson(operand));
370  }
371  map.put("operands", list);
372  map.put("type", toJson(node.getType()));
373  if (node instanceof RexSubQuery) {
374  final MapDRelJsonWriter subqueryWriter = new MapDRelJsonWriter();
375  ((RexSubQuery) node).rel.explain(subqueryWriter);
376  map.put("subquery", subqueryWriter.asJsonMap());
377  }
378  if (node instanceof RexOver) {
379  final RexWindow window = ((RexOver) node).getWindow();
380  final List<Object> partitionKeyList = jsonBuilder.list();
381  for (final RexNode partitionKey : window.partitionKeys) {
382  partitionKeyList.add(toJson(partitionKey));
383  }
384  map.put("partition_keys", partitionKeyList);
385  final List<Object> orderKeyList = jsonBuilder.list();
386  for (final RexFieldCollation orderKey : window.orderKeys) {
387  orderKeyList.add(toJson(orderKey));
388  }
389  map.put("order_keys", orderKeyList);
390  RexWindowBound lower_bound = window.getLowerBound();
391  RexWindowBound upper_bound = window.getUpperBound();
392  map.put("lower_bound", toJson(lower_bound));
393  map.put("upper_bound", toJson(upper_bound));
394  map.put("is_rows", toJson(window.isRows()));
395  }
396  if (call.getOperator() instanceof SqlFunction) {
397  switch (((SqlFunction) call.getOperator()).getFunctionType()) {
398  case USER_DEFINED_CONSTRUCTOR:
399  case USER_DEFINED_FUNCTION:
400  case USER_DEFINED_PROCEDURE:
401  case USER_DEFINED_SPECIFIC_FUNCTION:
402  map.put("class", call.getOperator().getClass().getName());
403  }
404  }
405  return map;
406  }
407  throw new UnsupportedOperationException("unknown rex " + node);
408  }
409  }
SQLTypes getType() const
+ Here is the call graph for this function:

◆ toJson() [10/10]

String org.apache.calcite.rel.externalize.MapDRelJson.toJson ( SqlOperator  operator)
inlineprivate

Definition at line 521 of file MapDRelJson.java.

521  {
522  // User-defined operators are not yet handled.
523  return operator.getName();
524  }

◆ toOp()

SqlOperator org.apache.calcite.rel.externalize.MapDRelJson.toOp ( String  op,
Map< String, Object >  map 
)
inlineprivate

Definition at line 492 of file MapDRelJson.java.

References Experimental.String.

Referenced by org.apache.calcite.rel.externalize.MapDRelJson.toAggregation(), and org.apache.calcite.rel.externalize.MapDRelJson.toRex().

492  {
493  // TODO: build a map, for more efficient lookup
494  // TODO: look up based on SqlKind
495  final List<SqlOperator> operatorList =
496  SqlStdOperatorTable.instance().getOperatorList();
497  for (SqlOperator operator : operatorList) {
498  if (operator.getName().equals(op)) {
499  return operator;
500  }
501  }
502  String class_ = (String) map.get("class");
503  if (class_ != null) {
504  try {
505  return (SqlOperator) Class.forName(class_).newInstance();
506  } catch (InstantiationException e) {
507  throw new RuntimeException(e);
508  } catch (IllegalAccessException e) {
509  throw new RuntimeException(e);
510  } catch (ClassNotFoundException e) {
511  throw new RuntimeException(e);
512  }
513  }
514  return null;
515  }
+ Here is the caller graph for this function:

◆ toRex()

RexNode org.apache.calcite.rel.externalize.MapDRelJson.toRex ( RelInput  relInput,
Object  o 
)
inlinepackage

Definition at line 411 of file MapDRelJson.java.

References Double, field(), Float, Integer, Experimental.String, org.apache.calcite.rel.externalize.MapDRelJson.toOp(), org.apache.calcite.rel.externalize.MapDRelJson.toRexList(), org.apache.calcite.rel.externalize.MapDRelJson.toType(), and run-benchmark-import.type.

Referenced by org.apache.calcite.rel.externalize.MapDRelJson.toRexList().

411  {
412  final RelOptCluster cluster = relInput.getCluster();
413  final RexBuilder rexBuilder = cluster.getRexBuilder();
414  if (o == null) {
415  return null;
416  } else if (o instanceof Map) {
417  Map map = (Map) o;
418  final String op = (String) map.get("op");
419  if (op != null) {
420  final List operands = (List) map.get("operands");
421  final Object jsonType = map.get("type");
422  final SqlOperator operator = toOp(op, map);
423  final List<RexNode> rexOperands = toRexList(relInput, operands);
424  RelDataType type;
425  if (jsonType != null) {
426  type = toType(cluster.getTypeFactory(), jsonType);
427  } else {
428  type = rexBuilder.deriveReturnType(operator, rexOperands);
429  }
430  return rexBuilder.makeCall(type, operator, rexOperands);
431  }
432  final Integer input = (Integer) map.get("input");
433  if (input != null) {
434  List<RelNode> inputNodes = relInput.getInputs();
435  int i = input;
436  for (RelNode inputNode : inputNodes) {
437  final RelDataType rowType = inputNode.getRowType();
438  if (i < rowType.getFieldCount()) {
439  final RelDataTypeField field = rowType.getFieldList().get(i);
440  return rexBuilder.makeInputRef(field.getType(), input);
441  }
442  i -= rowType.getFieldCount();
443  }
444  throw new RuntimeException("input field " + input + " is out of range");
445  }
446  final String field = (String) map.get("field");
447  if (field != null) {
448  final Object jsonExpr = map.get("expr");
449  final RexNode expr = toRex(relInput, jsonExpr);
450  return rexBuilder.makeFieldAccess(expr, field, true);
451  }
452  final String correl = (String) map.get("correl");
453  if (correl != null) {
454  final Object jsonType = map.get("type");
455  RelDataType type = toType(cluster.getTypeFactory(), jsonType);
456  return rexBuilder.makeCorrel(type, new CorrelationId(correl));
457  }
458  if (map.containsKey("literal")) {
459  final Object literal = map.get("literal");
460  final SqlTypeName sqlTypeName =
461  Util.enumVal(SqlTypeName.class, (String) map.get("type"));
462  if (literal == null) {
463  return rexBuilder.makeNullLiteral(sqlTypeName);
464  }
465  return toRex(relInput, literal);
466  }
467  throw new UnsupportedOperationException("cannot convert to rex " + o);
468  } else if (o instanceof Boolean) {
469  return rexBuilder.makeLiteral((Boolean) o);
470  } else if (o instanceof String) {
471  return rexBuilder.makeLiteral((String) o);
472  } else if (o instanceof Number) {
473  final Number number = (Number) o;
474  if (number instanceof Double || number instanceof Float) {
475  return rexBuilder.makeApproxLiteral(BigDecimal.valueOf(number.doubleValue()));
476  } else {
477  return rexBuilder.makeExactLiteral(BigDecimal.valueOf(number.longValue()));
478  }
479  } else {
480  throw new UnsupportedOperationException("cannot convert to rex " + o);
481  }
482  }
RexNode toRex(RelInput relInput, Object o)
RelDataType toType(RelDataTypeFactory typeFactory, Object o)
const rapidjson::Value & field(const rapidjson::Value &obj, const char field[]) noexcept
Definition: JsonAccessors.h:31
SqlOperator toOp(String op, Map< String, Object > map)
List< RexNode > toRexList(RelInput relInput, List operands)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ toRexList()

List<RexNode> org.apache.calcite.rel.externalize.MapDRelJson.toRexList ( RelInput  relInput,
List  operands 
)
inlineprivate

Definition at line 484 of file MapDRelJson.java.

References org.apache.calcite.rel.externalize.MapDRelJson.toRex().

Referenced by org.apache.calcite.rel.externalize.MapDRelJson.toRex().

484  {
485  final List<RexNode> list = new ArrayList<RexNode>();
486  for (Object operand : operands) {
487  list.add(toRex(relInput, operand));
488  }
489  return list;
490  }
RexNode toRex(RelInput relInput, Object o)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ toType()

RelDataType org.apache.calcite.rel.externalize.MapDRelJson.toType ( RelDataTypeFactory  typeFactory,
Object  o 
)
inline

Definition at line 198 of file MapDRelJson.java.

References Integer, Experimental.String, and run-benchmark-import.type.

Referenced by org.apache.calcite.rel.externalize.MapDRelJson.toRex().

198  {
199  if (o instanceof List) {
200  @SuppressWarnings("unchecked")
201  final List<Map<String, Object>> jsonList = (List<Map<String, Object>>) o;
202  final RelDataTypeFactory.FieldInfoBuilder builder = typeFactory.builder();
203  for (Map<String, Object> jsonMap : jsonList) {
204  builder.add((String) jsonMap.get("name"), toType(typeFactory, jsonMap));
205  }
206  return builder.build();
207  } else {
208  final Map<String, Object> map = (Map<String, Object>) o;
209  final SqlTypeName sqlTypeName =
210  Util.enumVal(SqlTypeName.class, (String) map.get("type"));
211  final Integer precision = (Integer) map.get("precision");
212  final Integer scale = (Integer) map.get("scale");
213  final RelDataType type;
214  if (precision == null) {
215  type = typeFactory.createSqlType(sqlTypeName);
216  } else if (scale == null) {
217  type = typeFactory.createSqlType(sqlTypeName, precision);
218  } else {
219  type = typeFactory.createSqlType(sqlTypeName, precision, scale);
220  }
221  final boolean nullable = (Boolean) map.get("nullable");
222  return typeFactory.createTypeWithNullability(type, nullable);
223  }
224  }
RelDataType toType(RelDataTypeFactory typeFactory, Object o)
+ Here is the caller graph for this function:

◆ typeNameToClass()

Class org.apache.calcite.rel.externalize.MapDRelJson.typeNameToClass ( String  type)
inline

Converts a type name to a class. E.g.

getClass("LogicalProject")

returns org.apache.calcite.rel.logical.LogicalProject.class.

Definition at line 124 of file MapDRelJson.java.

References Experimental.String.

Referenced by org.apache.calcite.rel.externalize.MapDRelJson.getConstructor().

124  {
125  if (!type.contains(".")) {
126  for (String package_ : PACKAGES) {
127  try {
128  return Class.forName(package_ + type);
129  } catch (ClassNotFoundException e) {
130  // ignore
131  }
132  }
133  }
134  try {
135  return Class.forName(type);
136  } catch (ClassNotFoundException e) {
137  throw new RuntimeException("unknown type " + type);
138  }
139  }
+ Here is the caller graph for this function:

Member Data Documentation

◆ constructorMap

final Map<String, Constructor> org.apache.calcite.rel.externalize.MapDRelJson.constructorMap
private
Initial value:
=
new HashMap<String, Constructor>()

Definition at line 73 of file MapDRelJson.java.

◆ jsonBuilder

final JsonBuilder org.apache.calcite.rel.externalize.MapDRelJson.jsonBuilder
private

◆ PACKAGES

final List<String> org.apache.calcite.rel.externalize.MapDRelJson.PACKAGES
static
Initial value:
= ImmutableList.of("org.apache.calcite.rel.",
"org.apache.calcite.rel.core.",
"org.apache.calcite.rel.logical.",
"org.apache.calcite.adapter.jdbc.",
"org.apache.calcite.adapter.enumerable.",
"org.apache.calcite.adapter.jdbc.JdbcRules$")

Definition at line 77 of file MapDRelJson.java.


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